POKEIN如何识别客户端进行SERVER PUSH?其中的ClientID是IP吗?
我有一个网络应用程序,用户将在其中看到新消息的通知,我想将通知推送给已经登录的用户。
我已经看到我可以使用 PokeIn 的服务器推送来做到这一点,我已经尝试并理解了使用它的简单应用程序,但我没有得到 ClientID 的东西。
它保存在“OnClientConnected”中的ClientId是一个简单的整数,那么它如何识别客户端并调用它们的函数呢?
另外,据说它使用混合长轮询方法,有人可以解释一下这是什么吗?
如果没有足够的了解,我将无法实施。
将登录用户的 ClientID 保存在数据库中,然后使用它推送数据可以吗?
更新:
即使来自同一内部的请求 浏览器窗口或选项卡、ClientId 每次请求都会收到 是不同的,所以我必须包括 我的母版页和每个页面上的处理程序 请求,我必须映射 ClientId 收到登录用户,所以 我可以给他发消息。
我不能将 (ClientId 映射到 LoggedIn UserId) 仅在登录时一次 然后使用相同的 ClientId 给他发消息?
I have a web application, where users will see notifications for their new messages, I want to push the notifications to the users who are already logged in.
I have seen that I can do it using Server Push of PokeIn, I have tried and understood the simple application using it, but I am not getting the ClientID thing.
The ClientId it saves in "OnClientConnected" is a simple integer, so how does it recognizes clients and calls functions on them ?
Also, it is written that it uses a hybrid long polling approach, can somebody please explain me what is this?
I will not be able to implement without having sufficient knowledge of it.
Does saving the ClientID in the database for logged in user and then pushing data using this will do ?
UPDATE:
Even from requests within the same
browser window or tab, the ClientId
received every time on every request
is different, so I had to include the
Handler in my master page and on every
request, I had to map the ClientId
received to the Logged In user, so
that I can send messages to him.Can't I just map the (ClientId to
LoggedIn UserId) only once on LogIn
and then use that same ClientId to
send him messages ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
作为您更新的答案,当您需要客户端共享服务器端实例或客户端一致命名时,您可以自由使用 PokeIn 的联合功能。
As an answer for your update, you are free to use Joint feature of PokeIn when you need shared server side instances for the clients or consistent naming for the clients.
ClientID 代表您的应用程序的特定客户端视图的标识密钥,并且每次都会发生变化。
它可以帮助您通过按键管理和定位特定视图。另一方面,您仍然可以将 ASP.NET 会话 ID 与 PokeIn 客户端 ID 一起使用。
唯一的区别是,如果任何用户在同一浏览器的不同选项卡上打开您的应用程序,每个选项卡将有一个唯一的客户端 ID。其实,这是一个很棒的
您可能需要的功能。另一方面,当客户端断开连接时(几乎是立即),PokeIn 也会通知您。
您可以通过客户端 id 找到会话 id;
CometWorker.GetSessionId(string ClientId)
或会话 ID 的客户端 ID;
CometWorker.GetClientIdsBySessionId(string sessionId)
另外,如果您不想使用客户端 ID 系统(这非常有用),您可以选择“联合”选项。它可以帮助您发送和接收消息
具有您定义的名称的客户端。 (此处中有一个“联合”功能的示例)
由于 PokeIn 提供了多种连接选项,因此您不需要当您与 PokeIn 合作时,不必考虑其背后的方法。它只是提供好处
从各种解决方案中。更多信息可以访问:“FAQ”和“高级教程”(http://www.pokein.com/ Help/AdvancedTutorial.aspx)
最后,您不必将 PokeIn 客户端 ID 保存到数据库中。 PokeIn 有效地管理每个客户端的服务器端对象。
我建议您查看示例和教程。
ClientID represents the identification key of the specific client view of your application and subject to change on each time.
It helps you to manage and target specific views by keys. On the other hand, you can still use ASP.NET session ids with PokeIn client ids.
The only difference is, if any user opens your application on the different tabs of same browser, each tab will have a unique client id. Actually, this is a great
functionality you may need. On the other hand, PokeIn also notifies you when a client is disconnected (almost instantly)..
You may reach session id by the client id;
CometWorker.GetSessionId(string ClientId)
or client ids for a session id by;
CometWorker.GetClientIdsBySessionId(string sessionId)
Additionally, if you don't want to use client id system (which is very useful), you may choose the "Joint" option. It helps you the send and receive messages from
the client with the name you have defined. (There is a sample for the "Joint" feature in here)
Because PokeIn provides various connection options, you don't have to think about the approach behind it when you work with PokeIn. It simply provides benefits
from the various solutions. More information can be accessible from : "FAQ" and "Advanced Tutorial" (http://www.pokein.com/Help/AdvancedTutorial.aspx)
At last, you don't have to save PokeIn client id to the database. PokeIn manages your server side objects per each client efficiently.
I suggest you to check the samples and tutorials.