Esempio n. 1
0
 static void Main(string[] args)
 {
     Console.WriteLine("Starting console thread");
     InitializeConsoleThread();
     ServerHandleData.InitializePacketListener();
     ServerTCP.InitializeServer();
 }
Esempio n. 2
0
        private void ReceiveCallback(IAsyncResult result)
        {
            try {
                int readBytes = myStream.EndRead(result);

                if (readBytes <= 0)
                {
                    Console.WriteLine("Closing connection due to empty packets");
                    CloseConnection();
                    return;
                }

                byte[] newBytes = new byte[readBytes];
                Buffer.BlockCopy(recieveBuffer, 0, newBytes, 0, readBytes);

                ServerHandleData.HandleData(connectionID, newBytes);
                myStream.BeginRead(recieveBuffer, 0, socket.ReceiveBufferSize, ReceiveCallback, null);
            } catch (Exception e) {
                //Database.LogError(e.Message);
                CloseConnection();
            }
        }