socket.io-cookies-parser
v1.1.1
Published
`Socket.IO Cookies Parser` help us handle cookie for Socket.IO[](https://socket.io/)
Downloads
3
Maintainers
Readme
Socket.IO Cookies Parser
Socket.IO Cookies Parser
help us handle cookie for Socket.IO
Note: After setup success, socket.request.cookies was parsed to JSON object.
Functions:
/**
* @method namespaceCookieParser setup socket midleware for namespace instance
* @param socket Socket
*/
function namespaceCookieParser(socket: Socket): void;
/**
* @method ioCookieParser setup socket midleware for io instance
* @param socket Socket
* @param next (err?: ExtendedError | undefined) => void
*/
function ioCookieParser(socket: Socket, next: (err?: ExtendedError | undefined) => void): void;
Example:
//ES6
import socketio from "socket.io";
import { namespaceCookieParser, ioCookieParser } from "socket.io-cookies-parser";
...
const io = new socketio.Server();
io.use(ioCookieParser);
...
const client = io.of("/client", namespaceCookieParser);
...