public void BeginReceiveMessage() { if (this.PlayerGameMode == GameMode.OFFLINE) { return; } else if (this.PlayerGameMode == GameMode.ONLINE) { PlayerSocket = new ClientSocket(this.ServerIPAddress, this.ServerPort); PlayerSocket.BeginAsyncConnect(); PlayerSocket.OnReceive += new DelagateClientReceiveMessage(DecodeMessage); // 发送登录消息 Thread.Sleep(10); string loginMsg = MessageCode.LOGIN + "," + m_snake.SnakeBodyID; PlayerSocket.Send(loginMsg); } }