server-sent-events

Change source (url) of Server-Sent event

こ雲淡風輕ζ 提交于 2019-11-29 22:35:20
问题 How can I change the source set in declaration of EventSource ? I have tried something like this: var source = new EventSource("/blahblah.php?path=" + (window.location.pathname)); // Few lines later... source.url = "/blahblah.php?path=" + url; But, source.url stays the same... Is this even possible? Or maybe there are alternative ways to do that? 回答1: No, it is not possible. A new URL passed to EventSource() creates a new EventSource object. 回答2: guest271314 suggested me much solutions to

Is there a Microsoft equivalent for HTML5 Server-Sent Events?

守給你的承諾、 提交于 2019-11-29 19:37:10
I am using HTML5 Server-Sent Events as follows: SSEUpdate = new EventSource("http://example.com/update.php"); SSEUpdate.onmessage = function(e){ console.log(e.data); } It does not work in IE11. (Error in console: 'EventSource' is undefined ) Is there an identical Microsoft equivalent, or do I have to do something completely different? In a word, no. Microsoft has not included SSE or an equivalent of SSE in any version of IE. IMO, you have two good options: Use a polyfill - My tests with this polyfill in IE10 and IE11 were all successful. Since it starts with if ("EventSource" in global) return

What is the difference between web sockets, long polling, server-sent events and forever frame?

我的梦境 提交于 2019-11-29 18:59:21
问题 I'm currently exploring SignalR, this technology supports transports (web wockets, long polling ,server-sent events and forever frame). I have understood the terminology web sockets and long polling. But what is Server-Sent Events and Forever Frame? How all four differ from each other? 回答1: Transports and fallbacks of SignalR: WebSocket Full-duplex Websocket is a full-duplex communication channels over a single TCP connection. When both server and browser support, it is the only transport

How to make EventSource available inside SharedWorker in FireFox?

廉价感情. 提交于 2019-11-29 14:37:21
I am trying to implement Server-Sent Events (SSE) inside a SharedWorker. The implementation is working with no problems in Google Chrome. However, it does not work in FireFox at all. When I try get it to work in FireFox I get this error in the console. error { target: SharedWorker, isTrusted: true, message: "ReferenceError: EventSource is not defined", filename: "https://example.com/add-ons/icws/js/worker.js", lineno: 28, colno: 0, currentTarget: SharedWorker, eventPhase: 2, bubbles: false, cancelable: true, defaultPrevented: false } How can I make EventSource available inside the SharedWorker

Server Sent Event Client with additional Cookie

狂风中的少年 提交于 2019-11-29 06:18:21
I am trying to unit test a Server Sent Event resource with an additional cookie. I am already using Jersey for the EventSource and JavaX for the client. The following code works fine: WebTarget target = ClientBuilder.newBuilder() .register(SseFeature.class) .build() .target("http://localhost:8080/sse"); EventSource eventSource = EventSource.target(target).build(); EventListener listener = new EventListener() { @Override public void onEvent(InboundEvent inboundEvent) { LOG.info(inboundEvent.readData(String.class)); } }; eventSource.register(listener); eventSource.open(); serverEventManager.send

Angular 2 spring boot server side events

隐身守侯 提交于 2019-11-29 01:57:39
Can somebody please provide me an example for spring boot server side events? Basically I need to push server side events to browser. I'm using angular 2 and spring boot backend. Please provide me 1 sample example, I'm unable to find good examples. @Controller public class SSEController { private final List<SseEmitter> emitters = new ArrayList<>(); @RequestMapping(path = "/stream", method = RequestMethod.GET) public SseEmitter stream() throws IOException { SseEmitter emitter = new SseEmitter(); emitters.add(emitter); emitter.onCompletion(() -> emitters.remove(emitter)); return emitter; } } How

Long Polling with Spring's DeferredResult

我与影子孤独终老i 提交于 2019-11-29 01:56:57
The client periodically calls an async method (long polling), passing it a value of a stock symbol, which the server uses to query the database and return the object back to the client. I am using Spring's DeferredResult class, however I'm not familiar with how it works. Notice how I am using the symbol property (sent from client) to query the database for new data (see below). Perhaps there is a better approach for long polling with Spring? How do I pass the symbol property from the method deferredResult() to processQueues() ? private final Queue<DeferredResult<String>> responseBodyQueue =

How does Server-Sent-Events work

给你一囗甜甜゛ 提交于 2019-11-29 01:06:56
问题 I tried an SSE (Server-Sent-Events) using java on tomcat 8.0. Here are few things I noticed. I click a button that automatically makes a request to the servlet. Servlet's GET method gets executed which returns an event stream. Once the full stream is received, the page again automatically makes another request which receives the same data again!!! I don't have an infinite loop there!!! What is actually happening on the server? In normal scenarios, tomcat creates a thread to handle every

SSE and Servlet 3.0

China☆狼群 提交于 2019-11-28 20:38:27
I have registered a typical SSE when page loads: Client: sseTest: function(){ var source = new EventSource('mySSE'); source.onopen = function(event){ console.log("eventsource opened!"); }; source.onmessage = function(event){ var data = event.data; console.log(data); document.getElementById('sse').innerHTML+=event.data + "<br />"; }; } My Javascript-Debugger says, that "eventsource opened!" was successfully. My Server Code is a Servlet 3.0: import java.io.IOException; import java.io.PrintWriter; import java.util.Random; import javax.servlet.ServletException; import javax.servlet.http

Is there a Microsoft equivalent for HTML5 Server-Sent Events?

本秂侑毒 提交于 2019-11-28 15:20:16
问题 I am using HTML5 Server-Sent Events as follows: SSEUpdate = new EventSource("http://example.com/update.php"); SSEUpdate.onmessage = function(e){ console.log(e.data); } It does not work in IE11. (Error in console: 'EventSource' is undefined ) Is there an identical Microsoft equivalent, or do I have to do something completely different? 回答1: In a word, no. Microsoft has not included SSE or an equivalent of SSE in any version of IE. IMO, you have two good options: Use a polyfill - My tests with