1.1.0 • Published 5 years ago

simplesockets v1.1.0

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
5 years ago

SimpleSockets

Ever got tired of:

  1. Handling websockets
  2. Dealing with protocols
  3. Socket.io's inflexibility
  4. Sluggish Performance

Simple Sockets solves all your problems! It is very simple, very customisable, easy, and fast.

Usage:

Server:

npm install simplesockets

Browser:

browser/SimpleSockets.js

Setup

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
})

Documentation

new SimpleSockets(options) (server)

The server

  • options - Websocket options (uws)
Server.close();

Close the server

Server.on(event,function)

Add events

Server.addParser(parser)

add custom parser

1.1.0

5 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago