Example #1
0
        private void LogMessage <T>(MyEventEnum eventType, T inst)
            where T : struct, IMyEvent
        {
            MyLoggingTypeEnum loggingType;

            if (m_loggedMessages.TryGetValue((int)eventType, out loggingType))
            {
                switch (loggingType)
                {
                case MyLoggingTypeEnum.NONE:
                    break;

                case MyLoggingTypeEnum.NAME:
                    MyTrace.Send(TraceWindow.Multiplayer, "Received event " + eventType.ToString() + ", from " + (inst.SenderEndpoint != null ? inst.SenderEndpoint.ToString() : "null"));
                    break;

                case MyLoggingTypeEnum.FULL:
                    MyTrace.Send(TraceWindow.Multiplayer, inst.ToString());
                    break;

                default:
                    break;
                }
            }
        }
Example #2
0
        void AlertVerbose(string alertFormat, IPEndPoint endpoint, MyEventEnum eventType)
        {
            var    player     = MyMultiplayerPeers.Static[endpoint];
            string playerInfo = String.Format(" UserId: {0}, GameUserId: {1}, EndPoint: {2}", player.UserId, player.GameId, player.EndPoint);

            MyTrace.Send(TraceWindow.MultiplayerAlerts, eventType.ToString() + ": " + alertFormat + playerInfo);
        }
Example #3
0
        void AlertVerbose(string alertFormat, IPEndPoint endpoint, MyEventEnum eventType)
        {
            var player = Peers.Players.FirstOrDefault(p => p.Connection.RemoteEndpoint == endpoint);

            if (player != null)
            {
                string playerInfo = String.Format(" UserId: {0}, GameUserId: {1}, EndPoint: {2}", player.UserId, player.PlayerId, player.Connection.RemoteEndpoint);
                MyTrace.Send(TraceWindow.MultiplayerAlerts, eventType.ToString() + ": " + alertFormat + playerInfo);
            }
        }
Example #4
0
 public void Log(MyEventEnum eventType, MyLoggingTypeEnum logType = MyLoggingTypeEnum.NAME)
 {
     if (logType != MyLoggingTypeEnum.NONE)
     {
         m_loggedMessages[(int)eventType] = logType;
     }
     else
     {
         m_loggedMessages.Remove((int)eventType);
     }
 }
Example #5
0
        /// <summary>
        /// True when message should be passed to handler.
        /// False to prevent handler.
        /// </summary>
        bool MessageFilter(NetConnection connection, IPEndPoint endpoint, MyEventEnum eventType)
        {
            MyPlayerRemote player = connection.Tag as MyPlayerRemote;

            if (player != null)
            {
                // Accept known players
                return(true);
            }
            else if (connection == m_serverConnection)
            {
                // Accept server messages
                return(true);
            }
            else if (connection != null && (eventType == MyEventEnum.NEW_PLAYER || eventType == MyEventEnum.ENTER_GAME || eventType == MyEventEnum.GET_PLAYER_LIST || eventType == MyEventEnum.GET_PLAYER_LIST_RESPONSE))
            {
                // Accept incoming new players
                return(true);
            }
            return(false);
        }
Example #6
0
        private void ProcessCallbackMsg <T>(NetIncomingMessage msg, MyEventEnum eventType, IPEndPoint endpoint, EventCallback <T> callback)
            where T : struct, IMyEvent
        {
            if (callback == null)
            {
                return;
            }

            T inst = new T();

            inst.SenderEndpoint   = endpoint;
            inst.SenderConnection = msg.SenderConnection;
            if (ReadMessage(msg, ref inst))
            {
                LogMessage <T>(eventType, inst);
                callback(ref inst);
            }
            else
            {
                MyMwcCheaterAlert.AddAlert(MyMwcCheaterAlertType.EXCEPTION_DURING_READING_MESSAGE, msg.SenderEndpoint, "Invalid message, message type: " + (int)inst.EventType);
            }
        }
Example #7
0
 void Alert(string alertFormat, IPEndPoint endpoint, MyEventEnum eventType)
 {
     AlertVerbose(alertFormat, endpoint, eventType);
 }
Example #8
0
 void AlertVerbose(string alertFormat, IPEndPoint endpoint, MyEventEnum eventType)
 {
     var player = MyMultiplayerPeers.Static[endpoint];
     string playerInfo = String.Format(" UserId: {0}, GameUserId: {1}, EndPoint: {2}", player.UserId, player.GameId, player.EndPoint);
     MyTrace.Send(TraceWindow.MultiplayerAlerts, eventType.ToString() + ": " + alertFormat + playerInfo);
 }
Example #9
0
 void Alert(string alertFormat, IPEndPoint endpoint, MyEventEnum eventType)
 {
     AlertVerbose(alertFormat, endpoint, eventType);
 }