Ejemplo n.º 1
0
 /**
  *
  * @Title: shutdown
  * @Description: 关闭连接
  * @param @throws IOException    参数
  * @return void    返回类型
  */
 public void shutdownNow()
 {
     //如果客户端已经就绪并且激活(数据交互)
     if (clientSession.IsReady && clientSession.IsActive == true)
     {
         //发送多次关闭信息
         Shutdown shutdown = new Shutdown();
         shutdown.DestinationID = clientSession.Destination.SocketID;
         shutdown.SetSession(clientSession);
         try
         {
             clientEndpoint.DoSend(shutdown);
             //  TimeUnit.MILLISECONDS.sleep(100);
         }
         catch (Exception e)
         {
             //logger.log(Level.SEVERE, "ERROR: Connection could not be stopped!", e);
         }
         clientSession.Socket.GetReceiver().Stop();
         clientEndpoint.Stop();
         //cd 添加  客户端一旦关闭就无效了,可以不移除,该对象关闭则不能使用了
         clientEndpoint.RemoveSession(clientSession.SocketID);
         //关闭发送
         clientSession.Socket.GetSender().Stop();
         closed = true;
     }
     clientEndpoint.Stop();
 }
Ejemplo n.º 2
0
 public void ShutDown()
 {
     shutdown = true;
     endpoint.Stop();
 }