App Engine渠道API连接和断开连接

时间:2012-06-07 03:06:09

标签: java google-app-engine channel-api

我已在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创建处理程序?我想在用户断开连接时通知或提醒已连接的用户。

1 个答案:

答案 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