1.0.1 • Published 7 years ago

web2socket v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

web2socket

Broadcasts data sent through web requests to all connected socket clients.

Install

npm i web2socket

Usage

Send web requests to the root URL of your running instance of web2socket.

GET query params or POST body will be broadcasted to all connected socket clients.

For example, if you send the following GET request:

http://localhost:3000?ip=192.168.0.27&name=ROCK

A message will be broadcasted to all connected socket clients containing:

{ ip: '192.168.0.27', name: 'ROCK' }

If you want to send the same data using JSON in a POST request you could make the request to http://localhost:3000 and send:

{
	"ip": "192.168.0.27",
	"name": "METAL!"
}

Socket clients will receive exactly the same data.

Local test

To test socket messaging you can start web2socket on one shell: npm start

Start a client on another shell: node src/socket-client.js

And run the test client on another one: node src/socket-client-test.js

Enjoy!