/** * Create a new SAM message-based session handler on an existing I2PSession * * @since 0.9.25 */ public SAMMessageSessionHandler(I2PSession sess) throws I2PSessionException { _session = sess; _session.addMuxedSessionListener(this, listenProtocol, listenPort); }
/** * Build a Session according to information * registered with the given nickname. * * Caller MUST call start(). * * @param nick nickname of the session * @throws IOException * @throws DataFormatException */ public MasterSession(String nick, SAMv3DatagramServer dgServer, SAMv3Handler handler, Properties props) throws IOException, DataFormatException, SAMException { super(nick); for (int i = 0; i < INVALID_OPTS.length; i++) { String p = INVALID_OPTS[i]; if (props.containsKey(p)) throw new SAMException("MASTER session options may not contain " + p); } dgs = dgServer; sessions = new ConcurrentHashMap<String, SAMMessageSess>(4); this.handler = handler; I2PSession isess = socketMgr.getSession(); // if we get a RAW session added with 0/0, it will replace this, // and we won't add this back if removed. isess.addMuxedSessionListener(this, I2PSession.PROTO_ANY, I2PSession.PORT_ANY); streamAcceptor = new StreamAcceptor(); }
/** * Loads the DHT from file. * Can't be restarted after stopping? */ public synchronized void start() { if (_isRunning) return; _session.addMuxedSessionListener(this, I2PSession.PROTO_DATAGRAM_RAW, _rPort); _session.addMuxedSessionListener(this, I2PSession.PROTO_DATAGRAM, _qPort); _knownNodes.start(); _tracker.start(); PersistDHT.loadDHT(this, _dhtFile, _backupDhtFile); // start the explore thread _isRunning = true; // no need to keep ref, it will eventually stop new Cleaner(); new Explorer(5*1000); _txPkts.set(0); _rxPkts.set(0); _txBytes.set(0); _rxBytes.set(0); _started = _context.clock().now(); _nodesLastSaved = _started; }
/** * Create a new SAM message-based session handler * * @param destStream Input stream containing the destination keys * @param props Properties to setup the I2P session * @throws I2PSessionException */ public SAMMessageSessionHandler(InputStream destStream, Properties props) throws I2PSessionException { if (_log.shouldLog(Log.DEBUG)) _log.debug("Instantiating new SAM message-based session handler"); I2PClient client = I2PClientFactory.createClient(); if (!props.containsKey("inbound.nickname") && !props.containsKey("outbound.nickname")) { props.setProperty("inbound.nickname", "SAM UDP Client"); props.setProperty("outbound.nickname", "SAM UDP Client"); } _session = client.createSession(destStream, props); if (_log.shouldLog(Log.DEBUG)) _log.debug("Connecting I2P session..."); _session.connect(); if (_log.shouldLog(Log.DEBUG)) _log.debug("I2P session connected"); _session.addMuxedSessionListener(this, listenProtocol, listenPort); }
rv.addMuxedSessionListener(_connectionManager.getMessageHandler(), protocol, defaultOptions.getLocalPort()); if (_log.shouldLog(Log.WARN)) _log.warn("Added subsession " + rv);
_session.addMuxedSessionListener(_messageHandler, protocol, defaultOptions.getLocalPort()); _outboundQueue = new PacketQueue(_context, _timer); _recentlyClosed = new LHMCache<Long, Object>(64);
i2pSession.addMuxedSessionListener(dispatcher, I2PSession.PROTO_DATAGRAM, I2PSession.PORT_ANY);
rv.addMuxedSessionListener(_connectionManager.getMessageHandler(), protocol, defaultOptions.getLocalPort()); if (_log.shouldLog(Log.WARN)) _log.warn("Added subsession " + rv);
_session.addMuxedSessionListener(_messageHandler, protocol, defaultOptions.getLocalPort()); _outboundQueue = new PacketQueue(_context, _timer); _recentlyClosed = new LHMCache<Long, Object>(64);