1.3.0 • Published 3 years ago

socket.io-with-get v1.3.0

Weekly downloads
3
License
GPL-3.0
Repository
github
Last release
3 years ago

socket.io-with-GET

socket.io superset who allow you to perform get request through websockets (for the browser you will find the code in socket-with-get.js)

use is really easy :

you can use it in the client :

(async ()=>{
	const socket = new Socket(io(':8080'));

	socket.on('name', async (data)=>{
		return "My name is Jhon... Jhon Doe...";
	});

	let data = await socket.get("ping", {start: new Date().getTime()}).catch(err=>{throw new Error(err)});
	let pingTime = new Date().getTime() - data.start;

	console.log(pingTime+" ms");
})().catch(err=>{throw new Error(err)});

(you must include the socket.io source code before include our code) (or use native websocket with socket-with-on)

and this on the server :

var io = require('socket.io')(8080);
var Socket = require('socket.io-with-get');

io.on('connection', async function(socket){
	socket = new Socket(socket);

	socket.on('ping', async (data)=>{
		return data;
	});

	let data = await socket.get("name", {}).catch(err=>throw new Error(err));
	console.log(data);
});
1.3.0

3 years ago

1.2.0

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago