Skip to content

A very simple alternative to Socket.io which is very small, easy, and fast.

License

Notifications You must be signed in to change notification settings

AJS-development/SimpleSockets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2c0baeb · Nov 28, 2018

History

21 Commits
Sep 25, 2018
Jul 19, 2017
Jul 19, 2017
Sep 25, 2018
Jul 18, 2017
Jul 19, 2017
Nov 28, 2018
Nov 28, 2018
Nov 28, 2018

Repository files navigation

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

<script src=""></script>

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

About

A very simple alternative to Socket.io which is very small, easy, and fast.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published