Skip to content

Instantly share code, notes, and snippets.

@scripting
Last active February 15, 2016 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save scripting/35753801e540e1d16c5f to your computer and use it in GitHub Desktop.
Save scripting/35753801e540e1d16c5f to your computer and use it in GitHub Desktop.

I need a way to write WebSocket client code that runs on a server in Node.js.

What it must do: Exactly what this browser-based app does, only running on a server, without the UI stuff.

https://github.com/scripting/1999client/blob/master/code.js#L133

It would make so much sense if Node implemented exactly the browser API for WebSockets, native. So much of Node works that way. But this is one of those times when it doesn't.

There are a few toolkits that do WebSockets on the server. But there isn't simple clean sample code that I've been able to convert to this application. I tried! :-)

Any help much appreciated!

@btucker
Copy link

btucker commented Feb 14, 2016

Dave, is this what you're looking for? https://github.com/theturtle32/WebSocket-Node#client-example

@scripting
Copy link
Author

Yes I tried that. I need working code that does what my example does. Exactly.

@xicubed
Copy link

xicubed commented Feb 15, 2016

Can you use the Google Closure lib? https://developers.google.com/closure/library/?

I try to do my JavaScript in ClojureScript (which compiles down into JS using Closure) which bundles that library in by default to handle a bunch of stuff when needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment