@Override public void onConnectionInit(Event event) { Connection conn = event.getConnection(); Session ssn = conn.session(); Sender snd = ssn.sender("sender"); conn.open(); ssn.open(); snd.open(); }
void init() throws NetworkException { synchronized (_lock) { _collector = Collector.Factory.create(); _transport = Transport.Factory.create(); _connection = Connection.Factory.create(); String id = _settings.getId(); _connection.collect(_collector); _connection.setContainer( id == null || id.trim().equals("") ? UUID.randomUUID().toString() : id); _connection.setHostname(_settings.getHost()); _transport.bind(_connection); Sasl sasl = _transport.sasl(); sasl.client(); sasl.setMechanisms(new String[] {"ANONYMOUS"}); _connection.open(); _connected.set(true); write(); } }
@Override public org.splash.messaging.Session createSession() throws NetworkException, MessagingException, TimeoutException { synchronized (_lock) { if (_closed.get()) { throw new MessagingException("Connection is closed"); } Session ssn = _connection.session(); SessionImpl session = new SessionImpl(this, ssn); _sessions.put(ssn, session); session.init(); return session; } }
@Override public void close() throws NetworkException, MessagingException, TimeoutException { synchronized (_lock) { if (!_closed.get()) { _closed.set(true); if (_connected.get()) { for (Session ssn : _sessions.keySet()) { _sessions.get(ssn).closeImpl(); } _sessions.clear(); _connection.close(); write(); closeNetworkConnection(); } } } }
@Override public String getRemoteID() { return _connection != null ? _connection.getRemoteContainer() : null; }
@Override public String getRemoteHostname() { return _connection != null ? _connection.getRemoteHostname() : null; }