- Notifications
You must be signed in to change notification settings - Fork0
luixal/sse
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Server-Sent Events are a way of sending information from a server to its clients using just HTTP. Also, it has no dependencies for clients as all major browsers support it out of the box.
This repo contains some code projects showing example of how to work with it:
You need to use at least two pieces for the example to work: a server and a client.
First, you need to run the server, just get into thesse-server
directory and install its dependencies:
npm i
then, just run the server:
npm start
you should see something like this:
SSE Example Server listening on 5001
that means that the server is running and listening for connections.
There are two similar clients that only differ in the front tooling used in each one. You just need to open in your brower theindex.html
located in any of the client directories:sse-client/vue
orsse-client/jquery
and you should start seeing message.
Every 5 seconds, the server fetches a joke fromChuckNorris API and sends that joke as an SSE message to the clients.
Also, in the terminal you have opened your server, you can type some text and, when hittingenter
, that text will be sent