Pure JavaScript Module for Session Handling | NPM
Socket session handler for Socket.IO
Simple Implementation
const app =const http =const io = httpconst session_handler =/*** Connection returns - Token, ID and the Status (1 - connected, 0 - Disconnected)** { id: 'm3aEHZZK2f8WfG3uAAAA', token: '5200cc4a59795529', status: 1 }***/session_handlerhttp
This array contains all the concurrent sessions session_handler.sessions
session_handlersessions
The response will be
Disconnect timeout can be changed using the from
method options.
const session_handler =
Client Connection
You can connect from Web-Client, iOS or Android
HTML / JavaScript
const socket =
Java
public Socket {IO.Options opts = new IO.Options();opts.query = "token=" + tokenSocket mSocket = IO.;mSocket.;return mSocket;}
Installation
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. Node.js 0.10 or higher is required.
Installation is done using the
$ npm i io-session-handler
Sample Project - Demo
This is a demo project.
Advanced Usage | Push & Broadcast Messages
You can send broadcast message to all client sessions at once.
session_handler
The push method is capable of sending a push message to only a specific client session and this method returns a boolean value when the session is identified as valid.
let sent = session_handler
Once the message is delivered to the client, onMessageDelivered
method will be triggered with the token of the client and the data it received.
session_handler
The data onMessageDelivered
contains;
Client Implementation | Push & Broadcast Messages
Once the client received the push message it should emit to push_message_delivery
with the data it receives and the token to let the server understand it's delivered to a certain client.
The client should on the push_message
event to receive push messages from server
Android client library is available at SCM - SCMessaging