Parse() public method

public Parse ( byte data ) : void
data byte
return void
Beispiel #1
0
 internal void ReceiveMessage(byte[] data, ServerSocket con)
 {
     //Debug.WriteLine("[Message] {0}", data[4]);
     // Check if this is the first message received
     if (!State.Instance.SaidHello(con))
     {
         var acceptableMessages = new byte[]
         {
             1,     // Error
             4,     // Hello
             5,     // HelloAgain
             92,    // Ping
         };
         //TODO Maybe we shouldn't kill the connection here
         //     Basically, if someone dc's it's possible that
         //     a network call gets sent up on accident before HelloAgain,
         //     which effectivly kills the game.
         //     Maybe need a flag on the player saying they at least said
         //     hello once.
         // A new connection must always start with a hello message, refuse the connection
         if (acceptableMessages.Contains(data[4]) == false)
         {
             var pi = State.Instance.GetClient(con);
             pi.Kick(false, L.D.ServerMessage__FailedToSendHelloMessage);
             State.Instance.RemoveClient(pi);
             return;
         }
     }
     // Set the lSender field
     _sender = con;
     _sender.OnPingReceived();
     // Parse and handle the message
     _binParser.Parse(data);
 }
Beispiel #2
0
 internal void ReceiveMessage(byte[] data, ServerSocket con)
 {
     //Debug.WriteLine("[Message] {0}", data[4]);
     // Check if this is the first message received
     if (!State.Instance.SaidHello(con))
     {
         var acceptableMessages = new byte[]
         {
             1,     // Error
             4,     // Hello
             5,     // HelloAgain
             92,    // Ping
         };
         // A new connection must always start with a hello message, refuse the connection
         if (acceptableMessages.Contains(data[4]) == false)
         {
             var pi = State.Instance.GetClient(con);
             pi.Kick("You must shake hands. No one likes an anti social connection.");
             State.Instance.RemoveClient(pi);
             return;
         }
     }
     // Set the lSender field
     _sender = con;
     _sender.OnPingReceived();
     // Parse and handle the message
     _binParser.Parse(data);
 }
Beispiel #3
0
        // Show the management GUI
        //        internal void ShowGUI(System.Windows.Forms.Form parent)
        //        {
        //            ManagementForm cf = new ManagementForm(clients);
        //            cf.ShowDialog(parent);
        //        }

        // Handle a Binary message
        internal void ReceiveMessage(byte[] data, TcpClient lSender, Server.Connection con)
        {
            // Check if this is the first message received
            if (!_clients.ContainsKey(lSender))
            {
                // A new connection must always start with a hello message, refuse the connection
                if (data[4] != (byte)2)
                {
                    lSender.GetStream().Close();
                    return;
                }
            }
            // Set the lSender field
            _sender     = lSender;
            _connection = con;
            // Parse and handle the message
            _binParser.Parse(data);
        }
Beispiel #4
0
 internal void ReceiveMessage(byte[] data, ServerSocket con)
 {
     //Debug.WriteLine("[Message] {0}", data[4]);
     // Check if this is the first message received
     if (!State.Instance.SaidHello(con))
     {
         // A new connection must always start with a hello message, refuse the connection
         if (data[4] != (byte)3 && data[4] != (byte)4)
         {
             State.Instance.GetClient(con).Kick("You must shake hands. No one likes an anti social connection.");
             return;
         }
     }
     // Set the lSender field
     _sender = con;
     _sender.OnPingReceived();
     // Parse and handle the message
     _binParser.Parse(data);
 }