Package org.cometd.bayeux.server

Examples of org.cometd.bayeux.server.ServerChannel


    for (final IPushNode<?> pnode : pnodes)
    {
      @SuppressWarnings("unchecked")
      final CometdPushNode<EventType> node = (CometdPushNode<EventType>)pnode;

      final ServerChannel cchannel = _getBayeuxServerChannel(node);
      if (cchannel == null)
      {
        LOG.warn("No cometd channel found for {}", node);
        continue;
      }

      @SuppressWarnings("unchecked")
      final PushNodeState<EventType> state = (PushNodeState<EventType>)_nodeStates.get(node);
      if (state != null)
      {
        synchronized (state.queuedEventsLock)
        {
          state.queuedEvents.add(ctx);
        }
        cchannel.publish(null, "pollEvents", state.node.getCometdChannelEventId());
      }
    }
  }
View Full Code Here


  @Override
  public <EventType> void publish(final IPushNode<EventType> node, final EventType event)
  {
    if (node instanceof CometdPushNode)
    {
      final ServerChannel cchannel = _getBayeuxServerChannel((CometdPushNode<?>)node);
      if (cchannel == null)
        LOG.warn("No cometd channel found for {}", node);
      else
      {
        @SuppressWarnings("unchecked")
        final PushNodeState<EventType> state = (PushNodeState<EventType>)_nodeStates.get(node);
        if (state != null)
        {
          synchronized (state.queuedEventsLock)
          {
            state.queuedEvents.add(new CometdPushEventContext<EventType>(event, null,
              this));
          }
          cchannel.publish(null, "pollEvents", state.node.getCometdChannelEventId());
        }
      }
    }
    else
      LOG.warn("Unsupported push node type {}", node);
View Full Code Here

   * AJAX request roundtrip.
   */
  public <EventType> void publishJavascript(final CometdPushNode<EventType> node,
    final String javascript)
  {
    final ServerChannel channel = _getBayeuxServerChannel(node);
    if (channel == null)
      LOG.warn("No cometd channel found for {}", node);
    else
      channel.publish(null, "javascript:" + javascript, node.getCometdChannelEventId());
  }
View Full Code Here

            exchange.setIn(message);

            consumer.getProcessor().process(exchange);

            if (ExchangeHelper.isOutCapable(exchange)) {
                ServerChannel channel = getBayeux().getChannel(channelName);
                ServerSession serverSession = getServerSession();

                ServerMessage.Mutable outMessage = binding.createCometdMessage(channel, serverSession, exchange.getOut());
                remote.deliver(serverSession, outMessage);
            }
View Full Code Here

    if (null == broker)
      throw new IOException("no broker to handle this service " + serviceName);

    HashMap<String, Object> data = new HashMap<String, Object>();
    data.put("error", true);
    ServerChannel ch = broker.getResponseChannel();
    client.deliver(broker.getServer(), ch.getId(), data, null);
  }
View Full Code Here

    };

    String rosterUnavailableChannel =
            this.sessionHandler.getRosterUnavailableChannel();
    server.createIfAbsent(rosterUnavailableChannel, initializer);
    ServerChannel channel = server.getChannel(rosterUnavailableChannel);
    if (channel == null) {
      return;
    }

    ServerSession from = this.sessionManager.getServerSession();

    Integer siteId = (Integer) client.getAttribute("siteid");
    String username = (String) client.getAttribute("username");

    Map<String, Object> data = new HashMap<String, Object>();
    data.put("siteId", siteId);
    data.put("username", username);

    log.fine(data.toString());

    channel.publish(from, data, null);
  }
View Full Code Here

    HashMap<String, Object> data = new HashMap<String, Object>();
    data.put("value", obj);
    data.put("error", false);

    ServerChannel channel = this.getResponseChannel();
    for (ServerSession client : this.subscribers) {
      client.deliver(this.server, channel.getId(), data, null);
    }
  }
View Full Code Here

  }

  public ServerChannel getResponseChannel() {

    String channelName = "/bot/" + this.serviceName;
    ServerChannel serverChannel = this.bayeuxServer.getChannel(channelName);
    if (serverChannel != null)
      return serverChannel;

    ServerChannel.Initializer initializer = new ServerChannel.Initializer()
    {
View Full Code Here

      }
    };
    this.server.createIfAbsent(this.syncAppChannel, initializer);
    this.server.createIfAbsent(this.syncEngineChannel, initializer);

    ServerChannel sync = server.getChannel(this.syncAppChannel);
    sync.addListener(this);
    sync = server.getChannel(this.syncEngineChannel);
    sync.addListener(this);

    this.sessionModerator = SessionModerator.getInstance(this,
        (String)config.get("sessionModerator"), confKey);
    if (null == this.sessionModerator) {
      config.put("moderatorIsUpdater", false);
View Full Code Here

   * ending. The server removes itself as a listener to sync channels.
   */
  public void endSession() {
    log.info("SessionHandler::endSession ***********");

    ServerChannel sync = this.server.getChannel(this.syncAppChannel);
    sync.removeListener(this);

    sync = server.getChannel(this.syncEngineChannel);
    sync.removeListener(this);

    // The following ordering must be observed!
    this.sessionModerator.endSession();
    if (null != this.operationEngine)
      this.operationEngine.shutdown();
View Full Code Here

TOP

Related Classes of org.cometd.bayeux.server.ServerChannel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.