/** * Send messages to the router destroying the session and disconnecting * */ public void disconnect(I2PSessionImpl session) throws I2PSessionException { if (session.isClosed()) return; DestroySessionMessage dmsg = new DestroySessionMessage(); dmsg.setSessionId(session.getSessionId()); session.sendMessage_unchecked(dmsg); // use DisconnectMessage only if we fail and drop connection... // todo: update the code to fire off DisconnectMessage on socket error //DisconnectMessage msg = new DisconnectMessage(); //msg.setReason("Destroy called"); //session.sendMessage(msg); }
public DataStructure createStructureToRead() { return new DestroySessionMessage(); } }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { SessionId id = new SessionId(); try { id.readBytes(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } setSessionId(id); }
private void handleDestroySession(DestroySessionMessage message) { SessionId id = message.getSessionId(); if (id != null) { _runner.removeSession(id); } else { if (_log.shouldLog(Log.WARN)) _log.warn("destroy session with null ID"); } int left = _runner.getSessionIds().size(); if (left <= 0 || id == null) { _runner.stopRunning(); } else { if (_log.shouldLog(Log.INFO)) _log.info("Still " + left + " sessions left"); } }
return new CreateSessionMessage(); case DestroySessionMessage.MESSAGE_TYPE: return new DestroySessionMessage(); case DisconnectMessage.MESSAGE_TYPE: return new DisconnectMessage();
public DataStructure createDataStructure() throws DataFormatException { DestroySessionMessage msg = new DestroySessionMessage(); msg.setSessionId((SessionId)(new SessionIdTest()).createDataStructure()); return msg; } public DataStructure createStructureToRead() { return new DestroySessionMessage(); }