1.2.0 • Published 7 years ago

@kiyasov/sticky-session v1.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
7 years ago

stickySession

A simple performant way to use socket.io with a cluster.

Installation

npm install @kiyasov/sticky-session --save-dev

Usage

import http from "http";
import cluster from "cluster";
import StickySession from "../lib";
import SocketIO from "socket.io";
import express from "express";
import SocketIORedis from "socket.io-redis";

let stickySession = new StickySession({
  listen: [3000, '127.0.0.1'],
  workers: 4
});

const app = express();
const server = http.Server(app);
const socket = SocketIO(server);

socket.adapter(SocketIORedis({ host: '127.0.0.1', port: 6379 }));

if (!stickySession.listen(server)) {
  // Master code
  server.once("listening", () => console.log("server started on 3000 port"));
} else {
  socket.on("connection", client => {
      console.log('a user connected');
      
      client.on("disconnect", client => {
        console.log('a user disconnect');
      });
  });
}

Simple

1.2.0

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 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