Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 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))
     {
         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);
 }
Exemplo n.º 5
0
        // This class contains high-level infos about connected clients

        internal void Ping()
        {
            _sender.OnPingReceived();
        }
Exemplo n.º 6
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)
         {
             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);
 }