public static void createChannel(BayeuxServer bayeux, String channelName){ bayeux.createChannelIfAbsent(channelName, new ServerChannel.Initializer() { public void configureChannel(ConfigurableServerChannel channel) { channel.setPersistent(true); System.out.println(channel.getChannelId()); } }); } }
public TimeServlet(BayeuxServer bayeuxServer) { this.bayeuxServer = bayeuxServer; this.channels = new ArrayList<ServerChannel>(); for (SystemTopics topic : SystemTopics.values()) { MarkedReference<ServerChannel> created = bayeuxServer.createChannelIfAbsent("/System/" + topic, new ConfigurableServerChannel.Initializer() { @Override public void configureChannel(ConfigurableServerChannel channel) { channel.setPersistent(true); } }); this.channels.add(topic.ordinal(), created.getReference()); } this.logDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); this.updateTimer = new Timer("System.Time.ClientNotifier"); this.updateTimer.scheduleAtFixedRate(new ClientNotifier(), 1000, 1000); this.session = bayeuxServer.newLocalSession(TimeServlet.class.getName()); this.session.handshake(); }
MarkedReference<ServerChannel> initializedChannel = bayeuxServer.createChannelIfAbsent(channel); RemoteCallCallback remoteCallCallback = new RemoteCallCallback(bayeuxServer, localSession, bean, method, paramNames, channelId, channel); initializedChannel.getReference().addListener(remoteCallCallback);
MarkedReference<ServerChannel> initializedChannel = bayeuxServer.createChannelIfAbsent(channel); ListenerCallback listenerCallback = new ListenerCallback(localSession, bean, method, paramNames, channelId, channel, listener.receiveOwnPublishes()); initializedChannel.getReference().addListener(listenerCallback);
}; MarkedReference<ServerChannel> initializedChannel = bayeuxServer.createChannelIfAbsent(channelName, init);