我已在Channel API for Java文档中阅读了跟踪客户端连接和断开连接部分。
它有以下代码:
// In the handler for _ah/channel/connected/
ChannelService channelService = ChannelServiceFactory.getChannelService();
ChannelPresence presence = channelService.parsePresence(req);
如何为_ah/channel/connected/
或_ah/channel/disconnected
创建处理程序?我想在用户断开连接时通知或提醒已连接的用户。
答案 0 :(得分:1)
您只需像任何其他处理程序一样创建这些处理程序。
将app.yaml放入:
- url: /_ah/channel/connected/
servlet: com.[MY_APP].server.channel.ChannelConnected
name: ChannelConnected
- url: /_ah/channel/disconnected/
servlet: com.[MY_APP].server.channel.ChannelDisconnected
name: ChannelDisconnected