SignalR, JQuery and Node

后端 未结 1 1760
没有蜡笔的小新
没有蜡笔的小新 2021-01-22 15:05

In a project I\'m currently working on, we are using Electron as a host. In the Electron main process, which is a normal Node process we need to connect to a downstream back-en

相关标签:
1条回答
  • 2021-01-22 15:20

    Introducing a dependency on jsdom and providing a dom to jquery via that seems to do the trick:

    var jsdom = require('jsdom').jsdom, document = jsdom('<html></html>');
    global.window = document.defaultView;
    global.window.WebSocket = require("ws");
    

    If the above is imported before the signalr script, it works fine.

    UPDATE: need to make WebSockets available on window object so websockets transport will work

    Good luck with it ;)

    0 讨论(0)
提交回复
热议问题