Last active
July 5, 2020 14:29
-
-
Save aslamanver/0f92539db8077cd39db5387a54b9918e to your computer and use it in GitHub Desktop.
Simple Usage | Socket.IO Session Handler for Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const app = require('express')() | |
const http = require('http').Server(app) | |
const io = require('socket.io')(http) | |
// Initialization | |
const session_handler = require('io-session-handler').from(io) | |
/** | |
* Connection returns - Token, ID and the Status (1 - connected, 0 - Disconnected) | |
* | |
* { id: '123', token: '5200cc4a59795529', status: 1 } | |
* | |
**/ | |
session_handler.connectionListener((connection) => { | |
console.log(connection) | |
}) | |
http.listen(3000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment