示例#1
0
 public void Disconnected()
 {
     if (state == TCP_Connection_State.TCPC_Connected)
     {
         this.state = TCP_Connection_State.TCPC_Disconnected;
     }
 }
示例#2
0
 //---------------------------------------------------------------------------------------------//
 //Public functions:
 //---------------------------------------------------------------------------------------------//
 public void Connected()
 {
     NET_Debug.InjectMessage("[NET_TCP_CN]", "[OK] Connected");
     state            = TCP_Connection_State.TCPC_Connected;
     this.thread      = new Thread(TCP_ConnectionThread);
     this.thread.Name = "[NET_TCP] connection thread";
     this.thread.Start();
 }
示例#3
0
 //---------------------------------------------------------------------------------------------//
 //Private functions:
 //---------------------------------------------------------------------------------------------//
 private void TCP_ConnectionThread()
 {
     NET_Debug.InjectMessage("[NET_TCP_CN]", "[OK] Thread started");
     //While connection established
     while (state == TCP_Connection_State.TCPC_Connected)
     {
         TCP_Receive();
         TCP_Sending();
     }
     client.Client.Disconnect(true);
     stream.Close();
     stream.Dispose();
     client.Close();
     NET_Debug.InjectMessage("[NET_TCP_CN]", "[OK] Thread ended");
     this.state = TCP_Connection_State.TCPC_DeleteMe;
 }
示例#4
0
 public void Disconnect(int playerID)
 {
     if (state == TCP_Connection_State.TCPC_Connected)
     {
         NET_Debug.InjectMessage("[NET_TCP_CN]", "[OK] Disconnected");
         NET_Messages.NET_Message_Disconnect disconnectMessage = new NET_Messages.NET_Message_Disconnect(DateTime.Now);
         NET_DataPack pack = new NET_DataPack();
         pack.SetData("PlayerID", playerID);
         disconnectMessage.SetData(pack.SerializeData());
         lock (tcpOUT_MessageQueue)
         {
             tcpOUT_MessageQueue.Enqueue(disconnectMessage);
         }
         TCP_Sending();
         this.state = TCP_Connection_State.TCPC_Disconnected;
     }
 }