且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用可由Javascript订阅者使用的CometD Java客户端发布消息

更新时间:2022-05-06 22:20:39

remote.deliver()将回答发送到远程会话(即客户端)在服务频道上发布的。

remote.deliver() sends the "answer" to the remote session (i.e. the client) that published on the service channel.

您应该将未经请求的消息发布到正常频道(服务器端尚不存在)。所以,你应该写类似

You should publish an unsolicited message to a normal channel (which on the server side does not exist yet). So, you should write something like

String channelName = "whatever - not beginning with /service";
getBayeux().createIfAbsent(channelName);
getBayeux().getChannel(channelName).publish(getServerSession(), output, null);