DVLP / signalr-no-jquery

120 stars 77 forks source link

signalr-no-window #3

Closed DuBistKomisch closed 7 years ago

DuBistKomisch commented 7 years ago

Are you aware of any fork which removes the need for window? I.e. allow running in node instead of a browser.

If not, I'll take a shot at doing it myself based on your fork. Would you be interested in a PR when I'm done?

DuBistKomisch commented 7 years ago

Well turns out it's a lot of work making something that will work in both browsers and node, since a lot of web standards aren't implemented in Node, so they'd all need shims (e.g. WebSocket, EventSource, XMLHttpRequest).

My fork is just going to work for my particular case where we just use the longPolling transport, with $.ajax implemented on top of the NPM request library, and strip out any other transports or browser considerations.

DVLP commented 7 years ago

Have you tried this one https://github.com/mwwhited/signalr-client-nodejs

DuBistKomisch commented 7 years ago

Yeah I saw that one on NPM. Looks like it's written from scratch and unmaintained, not based on the official client, so I don't really trust it.

lommez commented 7 years ago

Hi @DuBistKomisch ,

Did you implement that feature? I need an implementation of SignalR that doesnt use jQuery and also window.

DuBistKomisch commented 7 years ago

@lommez Yes, I forgot to link it before. I just published it to NPM for you: https://www.npmjs.com/package/signalr-node, the source link is on there too. Note that it only supports long polling. We just launched the feature we needed it for to production the other week and it's been working great so far.

lommez commented 7 years ago

Thanks @DuBistKomisch . Have you tried to use that library https://github.com/tmpvar/jsdom ? You could simulate the DOM and use the original signalrjs library. I didn´t tried yet. But later i will try.

By the way, do you plans to release a feature to support WebSockets in signalr-node?

DuBistKomisch commented 7 years ago

@lommez

I don't think JSDOM will help too much, you would have to rewrite signalr to use it anyway. It also doesn't look like it implements stuff like WebSockets, ServerEvents, etc.

We aren't going to use WebSockets for our product, so I'm not going to support them myself, but I'm happy to accept a PR for it.