예제 #1
0
 //同步IP
 void UpdateSyncIpConnect()
 {
     byte[] ipData = null;
     if (syncIpConnection != null)
     {
         ipData = syncIpConnection.GetMsg();
     }
     //接受同步IP
     if (recvBroadCastIP == true)
     {
         if (ipData != null)
         {
             string   recvIpString = Encoding.UTF8.GetString(ipData);
             string[] strSplit     = recvIpString.Split('|');
             if (strSplit.Length == 3)
             {
                 string version = strSplit[0];
                 string ip      = strSplit[1];
                 string group   = strSplit[2];
                 if (version == Application.version && netGroup == group)
                 {
                     recvBroadCastIP = false;
                     syncIpConnection.Dispose();
                     syncIpConnection = null;
                     ConenctTcp(ip);
                 }
             }
         }
     }
 }
예제 #2
0
 public void Close()
 {
     Debug.LogWarning("关闭服务器");
     host.Dispose();
     host = null;
     if (syncIpConnection != null)
     {
         syncIpConnection.Dispose();
     }
 }
예제 #3
0
 void OnDestroy()
 {
     onBtnChange = null;
     if (sendUdp != null)
     {
         sendUdp.Dispose();
         sendUdp = null;
     }
     if (recvUdp != null)
     {
         recvUdp.Dispose();
         recvUdp = null;
     }
 }
예제 #4
0
 public void Close()
 {
     if (client != null)
     {
         client.Dispose();
     }
     if (server != null)
     {
         server.Close();
     }
     if (multidataConnection != null)
     {
         multidataConnection.Dispose();
     }
     if (syncIpConnection != null)
     {
         syncIpConnection.Dispose();
     }
 }