Navigation

    Colyseus
    • Login
    • Search
    • Recent
    • Tags
    • Users
    1. Home
    2. Imallic
    3. Best
    • Profile
    • More
      • Continue chat with Imallic
      • Flag Profile
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups

    Best posts made by Imallic

    RE: Getting error when leaving room on OnDestroy (Unity)

    @endel, I have created the pull request: https://github.com/gamestdio/colyseus-unity3d/pull/40

    posted in Questions & Help •
    RE: Colyseus.js Websocket is not defined

    I know this topic is 3 months old, but I have found a workaround so if anyone searches for this they will have an answer.

    The reason your unit test is not working is that WebSocket is not globally installed when you run it in say Jest for example.

    A quick work around would be to define it globally.

    // npm install ws
    
    const globalAny: any = global; // This way we don't get an error in TypeScript saying WebSocket is not a defined property on global
    globalAny.WebSocket = require('ws');
    

    Also, it appears as though the colyseus.js client makes use of the window.local storage object. A quick polyfill you could do would look something like this

    globalAny.window = {
        localStorage: {
            getItem: () => {},
            setItem: () => {}
        },
    

    };

    posted in Questions & Help •