Skip to content

Latest commit

 

History

History
89 lines (60 loc) · 2.33 KB

README.md

File metadata and controls

89 lines (60 loc) · 2.33 KB

Learn WebSockets

Learn how to use WebSockets to create real-time apps.

Why?

Instant feedback in your apps.

What?

WebSockets allows you to build web/mobile applications where data can be sent between client/server in a much more efficient way than "traditional" HTTP. When a client connects to the WebSocket-enabled server it can send and receive messages with minimal overhead. Crucially where HTTP is a (stateless) request-response protocol, WebSockets allow the client to subscribe to a stream of data, which means that updates can be receive after the initial response. This makes WebSockets perfect for building Real-Time Apps!

How ?

HapiNES

To run the examples you will need two terminal windows (one to run the server.js and the other for client.js)

### Simple Connection to Server

In the first terminal window, boot the server:

PORT=8000 node nes/server.js

Then in the second window run the client:

PORT=8000 node nes/client.js

Publish Subscribe

Same again, 2 terminal windows (note: have them both ready at the same time...)

  1. Boot the server:
PORT=8000 node nes/pubsub-server.js
  1. Then run the client :
PORT=8000 node nes/pubsub-client.js

Publish Subscribe with Auth-based Filter

Same again, 2 terminal windows (note: have them both ready at the same time...)

  1. Boot the server:
PORT=8000 node nes/sub-filter-server.js
  1. Then run the client :
PORT=8000 node nes/sub-filter-client.js

## FAQ

Can we use WebSockets Every where?

Sadly, no. http://caniuse.com/#feat=websockets caniuse-websockets

### Can we ignore Opera Mini...?

Apparently not... Opera Mini accounts for almost 5% of the market!

http://caniuse.com/usage-table caniuse-stats

More detailed trend: https://www.netmarketshare.com/browser-market-share.aspx?qprid=1&qpcustomb=1 mobile-stats-opera-mini

Where are all the Opera Mini users? http://raddevon.com/articles/where-are-opera-mini-users