问题标签 [server-sent-events]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
java - Server Sent Events on Play framework using Java
I am completely new Play framework and Scala. I am trying to push some events from the server to the browser using Html5 -server sent events and play framework.
I came across this example in Scala. I tried implementing action composition in java by extending play.mvc.Action.Simple. I am not sure how to set the response headers in the action composition.
http://benquasmalltalk.blogspot.fr/2012/04/hub-interesting-but-undocumented.html
The data I am sending is coming from a database and not an enumeration. Any pointers will be helpful
php - 什么是长轮询、Websocket、服务器发送事件 (SSE) 和 Comet?
我已经尝试阅读一些文章,但我对这些概念还不是很清楚。
有人想向我解释一下这些技术是什么:
- 长轮询
- 服务器发送的事件
- 网络套接字
- 彗星
我每次遇到的一件事是,服务器保持连接打开并将数据推送到客户端。连接如何保持打开状态,客户端如何获取推送的数据?(客户如何使用数据,也许一些代码可能会有所帮助?)
现在,我应该将其中哪一个用于实时应用程序。我听说过很多关于 websockets(使用 socket.io [一个 node.js 库])的信息,但为什么不是 PHP 呢?
java - 服务器发送的事件在 Google Chrome 中不起作用
这是我的服务器 JSP 代码“Server_Date.jsp”
这是我的客户端 jsp 页面“Client_Serverdate.jsp”
请帮助我,此代码在 Mozilla Firefox、Opera 中运行良好,但在 Google Chrome 中无法运行(我也检查了 18.x 和 20.x)。
它会转到我已经用 print 语句检查过的服务器页面,但它没有出现document.getElementById("result").innerHTML = event.data;
。
html - Responding to a HTTP Get with an SSE
I am experimenting with HTML5 and node.js. I have tested out Server Sent Events and they worked fine(Refering to this example).
Next I tried replying to a button press with an SSE. On pressing the "Increment" button I pick a number from a text box and pass it to the server using a GET message. The server will then respond with an event containing the incremented number. The eventListener will then update the text box with the received number. I have also added a "Message area" on the HTML page to log messages.
That was the plan. But when I click the button the browser shows a "downloading" operation is in progress in the bottom of the window but it never completes and the result is not updated on the screen nor is the message displayed in the bottom of the page.
The events work fine when i send them at the load of the page. But when I send it in response to a GET message the HTML page doesn't show any response.
Here is the HTML section.
I have added handlers for messages and for a "temperature event" which will update the Temperature box
In the node.js script i am sending a message and a TemperatureValueUpdate
I have also responded to the "/events" URL on the page load with a 200 reply:
I have even tried the following
- Sending a 202/204 response before sending the events
- sending a response.end() before/after sending the events
- Sending a 'Content-Type': 'text/event-stream' before each event
But they don't produce the desired result. What am I doing wrong here?
android - 本机应用程序中的服务器发送事件?
有什么方法可以在原生 Android 应用程序中使用服务器发送的事件?
server-sent-events - 如何“暂停”服务器发送事件?
如何暂停服务器发送事件连接?甚至有可能,还是我必须关闭 SSE 然后重新打开它并再次分配所有事件处理程序?
例如我想做的(这都是理论上的,我不知道暂停/重启函数名称):
c# - 使用 C# 监听文本/事件流
我正在编写一个 C# 类来包装一个简单的 Web 服务。RESTful 的东西很容易总结,但现在我需要在服务器上的某些东西发生变化时引发一个事件。
我已经设置了服务器以使事件流可用,但我不知道如何在 C# 中获取流。
目前我正在做这样的事情:
在我的测试中,该事件被拾取一次,但不是两次。服务器上的事件本质上是一个开关——有些事情发生了,它继续,其他事情发生了,它熄灭了。我知道切换是有效的,因为我已经将事件流连接到一个普通的网页来测试它。
我应该如何处理 C# 中的事件流?
编辑 1:我已经更新了代码以修复 TimVK 指出的错误,但事件流仍然没有被第二次拾取。
javascript - SSE(服务器发送事件)断开连接
我正在尝试将 SSE(在 chrome 中)用于股票应用程序。似乎在我发现或编写的每个示例中,连接每 3-4 秒关闭一次。即使在以下位置运行示例: http ://www.w3schools.com/html5/tryit.asp?filename=tryhtml5_sse
您可以看到每 3-4 秒更新一次。这不是由于服务器实现(本例中为“demo_sse.php”),而是由于每 3-4 秒发生一次重新连接。
如果我在上面的示例中添加以下内容:
你可以清楚的看到readyState为0,意思是:“连接还没有建立,或者已经关闭,用户代理正在重新连接。” (取自官方 EventSorce API 文档)。
我自己也为服务器端编写了一个脚本,这是代码(使用python Bottle web框架)。
我得到同样的东西。每 3-4 秒重新连接一次。
所以我感兴趣的是如何通过会话保持连接。
谢谢你的帮助,奥马尔。
python - 如何让多个客户端监听服务器发送的事件?
我试图了解服务器发送的事件。我网站的其余部分使用cherrypy 提供服务,所以我也想让他们在这个平台上工作。
我用来公开 SSE 的方法:
在 chrome (win 7) 和 chromium (ubuntu 12.04) 上进行测试,这将为流提供服务,并且使用它的页面工作正常。但是,它一次只能运行一个系统。如果我同时让 chrome 和 chromium 读取流,则只有第一个获取流,另一个获取任何内容。如何让两个系统同时访问流?