检测(在服务器端)Flex 客户端何时与 BlazeDS 目标断开连接 [英] Detecting (on the server side) when a Flex client disconnects from BlazeDS destination

查看:35
本文介绍了检测(在服务器端)Flex 客户端何时与 BlazeDS 目标断开连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以轻松检测(在服务器端)Flex 客户端何时与 BlazeDS 目标断开连接?我的情况很简单,我想尝试使用它来计算每个会话的每个客户端连接多长时间.我还需要能够区分客户端(即,不仅仅是计算我在 ds-console 中看到的当前连接客户端的数量).

I'd like to know whether it's possible to easily detect (on the server side) when Flex clients disconnect from a BlazeDS destination please? My scenario is simply that I'd like to try and use this to figure out how long each of my clients are connected for each session. I need to be able to differentiate between clients as well (ie so not just counting the number of currently connected clients which I see in ds-console).

虽然我可以在客户端的我正在注销"过程中进行编程,但我不知道如果客户端只是导航到另一个网页而不是通过所述注销过程,这是否会触发.

Whilst I could program in a "I'm now logging out" process in my clients, I don't know whether this will fire if the client simply navigates away to another web page rather than going though said logout process.

任何人都可以建议是否有一种简单的方法可以在服务器端进行此类监控.

Can anyone suggest if there's an easy way to do this type of monitoring on the server side please.

非常感谢,亚历克斯

推荐答案

唯一正确的方法是以某种方式实现心跳机制.您可以按照之前的建议将 http 中的 keep-alive 与 session expire 结合使用,但我的意见是使用 BlazeDS 的消息传递机制(在 X 秒发送消息).您可以控制时间间隔和其他方面(也许您想检测客户端是否在几个小时内没有做任何事情,并在您的客户端仍然连接的情况下使会话无效).

The only way to do it right is to implement the heartbeat mechanism in a way or another. You can use the keep-alive from http coupled with session expire as suggested before but my opinion is to use the messaging mechanism from BlazeDS (send a message at X seconds). You can control the time interval and other aspects (maybe you want to detect if the client is not doing anything for several hours and to invalidate the session even if your client is still connected).

如果您想在客户端断开连接时立即收到通知(聊天应用程序),那么解决方案是使用套接字 (RTMP) 或某种模拟(http 流),它会立即检测客户端是否断开连接,但是这种断开连接可以是暂时的(可能网络中断了一秒钟,之后就可以了,您也应该检测到这一点).

If you want to be notified instantly (chat application) when a client is disconnecting a solution is to have a socket (RTMP) or some emulation (http streaming) which will detect instantly if the client is disconnected, however this disconnection can be temporary (maybe the network was down for one second, and after that is ok, and you should also detect that).

这篇关于检测(在服务器端)Flex 客户端何时与 BlazeDS 目标断开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆