Esempio n. 1
0
 @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();
 }
Esempio n. 2
0
 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();
   }
 }
Esempio n. 3
0
 @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;
   }
 }
Esempio n. 4
0
 @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();
       }
     }
   }
 }
Esempio n. 5
0
 @Override
 public String getRemoteID() {
   return _connection != null ? _connection.getRemoteContainer() : null;
 }
Esempio n. 6
0
 @Override
 public String getRemoteHostname() {
   return _connection != null ? _connection.getRemoteHostname() : null;
 }