Пример #1
0
 public void sendMessage(ObjectExchange data) throws IOException {
   synchronized (this) {
     if (writer != null && !socket.isClosed()) {
       //  data.friend_id  =   transactionId;
       writer.writeObject(data);
       writer.flush();
     }
   }
 }
Пример #2
0
 public void closedSession() {
   try {
     if ((socket == null) || socket.isClosed()) {
       return;
     }
     sendMessage(
         new ObjectExchangeWrap(OUT_SESSION_CLOSE, null, transactionId).getObjectExchange());
     writer.close();
     reader.close();
     socket.close();
     this.interrupt();
     System.out.println("Showdown input and output");
   } catch (Exception e) {
     System.out.println("try shutdown error");
     System.out.println(e.getMessage());
   }
 }