Ever got tired of:
- Handling websockets
- Dealing with protocols
- Socket.io's inflexibility
- Sluggish Performance
Simple Sockets solves all your problems! It is very simple, very customisable, easy, and fast.
Server:
npm install simplesockets
Browser:
browser/SimpleSockets.js
<script src=""></script>
Server
const SimpleSockets = require("simplesockets");
var options = { // websocket options
port: 8080
}
var server = new SimpleSockets(options)
server.on("connection",function(client) {
console.log(`Client (IP: ${client.IP}) connected!`)
client.emit("hello","world");
client.on("hi",function(m) {
client.close(0,"bye")
})
});
Client
var socket = new SimpleSocket("ws://localhost:8080");
socket.on("connection",function() {
console.log("Connected!");
})
socket.on("hello",function(a) {
console.log(a) // world
socket.emit("hi");
})
socket.on("disconnect",function(code,reason) {
console.log(reason) // bye
})
The server
- options - Websocket options (uws)
Close the server
Add events
add custom parser