Skip to content

Instantly share code, notes, and snippets.

@alex-hladun
Last active November 1, 2021 23:10

Revisions

  1. alex-hladun revised this gist Nov 1, 2021. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions SocketManager.ts
    Original file line number Diff line number Diff line change
    @@ -14,11 +14,8 @@ Class SocketManager {
    }

    generateSocketServer = (server: http.Server) => {
    // Socket server property
    this.io = new Server(server, {
    cors: {
    // Would change origin to eventual DNS for react app if
    // uploaded to S3 instead of served.
    origin: "http://localhost:3000",
    methods: ["GET", "POST"],
    credentials: true
  2. alex-hladun revised this gist Sep 30, 2021. 1 changed file with 16 additions and 16 deletions.
    32 changes: 16 additions & 16 deletions SocketManager.ts
    Original file line number Diff line number Diff line change
    @@ -13,20 +13,20 @@ Class SocketManager {
    this.generateSocketServer(server);
    }

    generateSocketServer = (server: http.Server) => {
    // Socket server property
    this.io = new Server(server, {
    cors: {
    // Would change origin to eventual DNS for react app if
    // uploaded to S3 instead of served.
    origin: "http://localhost:3000",
    methods: ["GET", "POST"],
    credentials: true
    },
    allowEIO3: true, // Whether to enable compatibility with Socket.IO v2 clients.
    maxHttpBufferSize: 1024, // max message payload size (prevents clients from sending gigabytes of data)
    pingInterval: 45 * 1000, // 45 seconds (less than ALB timeout)
    pingTimeout: 4 * 60 * 1000 // 4 minutes
    });
    };
    generateSocketServer = (server: http.Server) => {
    // Socket server property
    this.io = new Server(server, {
    cors: {
    // Would change origin to eventual DNS for react app if
    // uploaded to S3 instead of served.
    origin: "http://localhost:3000",
    methods: ["GET", "POST"],
    credentials: true
    },
    allowEIO3: true, // Whether to enable compatibility with Socket.IO v2 clients.
    maxHttpBufferSize: 1024, // max message payload size (prevents clients from sending gigabytes of data)
    pingInterval: 45 * 1000, // 45 seconds (less than ALB timeout)
    pingTimeout: 4 * 60 * 1000 // 4 minutes
    });
    };
    };
  3. alex-hladun revised this gist Sep 30, 2021. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions SocketManager.ts
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,18 @@
    import { Server, Socket } from "socket.io";

    Class SocketManager {
    io: SocketIO.Server;
    pubClient: redis.RedisClient;
    sessionStore: RedisSessionStore;
    serverConfig: IServerConfig;
    redisEnabled: boolean;
    dynamoEnabled: boolean;

    constructor(server: http.Server) {
    this.serverConfig = config;
    this.generateSocketServer(server);
    }

    generateSocketServer = (server: http.Server) => {
    // Socket server property
    this.io = new Server(server, {
    @@ -15,3 +29,4 @@ generateSocketServer = (server: http.Server) => {
    pingTimeout: 4 * 60 * 1000 // 4 minutes
    });
    };
    };
  4. alex-hladun created this gist Sep 30, 2021.
    17 changes: 17 additions & 0 deletions SocketManager.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@

    generateSocketServer = (server: http.Server) => {
    // Socket server property
    this.io = new Server(server, {
    cors: {
    // Would change origin to eventual DNS for react app if
    // uploaded to S3 instead of served.
    origin: "http://localhost:3000",
    methods: ["GET", "POST"],
    credentials: true
    },
    allowEIO3: true, // Whether to enable compatibility with Socket.IO v2 clients.
    maxHttpBufferSize: 1024, // max message payload size (prevents clients from sending gigabytes of data)
    pingInterval: 45 * 1000, // 45 seconds (less than ALB timeout)
    pingTimeout: 4 * 60 * 1000 // 4 minutes
    });
    };