Exemplo n.º 1
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     if (Interlocked.Increment(ref isDisposed) == 1)
     {
         try
         {
             using (tcpClient)
             {
                 pub.Dispose(ref userChangeCallback);
                 pub.Dispose(ref messageCallback);
                 if (User != null)
                 {
                     tcpClient.logout();
                 }
             }
             tcpClient = null;
         }
         finally
         {
             if (OnDisposed != null)
             {
                 OnDisposed();
             }
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 客户端
 /// </summary>
 /// <param name="user">用户名</param>
 public client(string user)
 {
     tcpClient = new server.tcpClient();
     if (tcpClient.login(user).Value)
     {
         User = user;
         userChangeCallback = tcpClient.getUsers(userChange);
         messageCallback    = tcpClient.receive(receive);
     }
     else
     {
         Dispose();
     }
 }