adonisjs / adonis-websocket-client

Websocket client for AdonisJs framework.
52 stars 48 forks source link

WebSocket client for NodeJS #71

Closed psalkowski closed 4 years ago

psalkowski commented 4 years ago

Hi,

How to use websocket client when running nodejs process? I'm creating daemon that will communicate via websocket (sending commands from GUI to daemon). Is there any way to use this library for that?

As far as I tested, it throws error on windows is not defined. I have found some workaround here: https://github.com/adonisjs/adonis-websocket-client/issues/67#issuecomment-595994360 but then I receive another issue: WebSocket is not defined.

psalkowski commented 4 years ago

I have found the solution. We need to import https://www.npmjs.com/package/ws and make it global. I did that via webpack by adding plugin:

    plugins: [
        new webpack.ProvidePlugin({
            WebSocket: 'ws'
        }),
    ],