public void sendMessage(ObjectExchange data) throws IOException { synchronized (this) { if (writer != null && !socket.isClosed()) { // data.friend_id = transactionId; writer.writeObject(data); writer.flush(); } } }
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()); } }