https://github.com/squaremo/sockjs-bridge
Bridge for proxying SockJS connections into some other network
https://github.com/squaremo/sockjs-bridge
Last synced: about 2 months ago
JSON representation
Bridge for proxying SockJS connections into some other network
- Host: GitHub
- URL: https://github.com/squaremo/sockjs-bridge
- Owner: squaremo
- Created: 2012-04-24T15:39:40.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2012-04-30T14:11:10.000Z (about 14 years ago)
- Last Synced: 2025-06-09T07:04:50.445Z (about 1 year ago)
- Language: JavaScript
- Size: 109 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SockJS bridge
This is a server that proxies SockJS connections. Why bother? Well,
not everyone can have a SockJS server in their chosen language,
whereas TCP/ZeroMQ bindings are far more common. Also, you may wish to
deploy the bridge independently of your application, because of
Reasons.
## Debugging
$ npm install && node server.js
or
$ npm start
starts a server that listens for SockJS connections on port 8000 and
for applications on port 5000.
The Node.JS module `client` has a simple client that speaks the proxy
to app protocol. To simulate an application using the bridge, connect
a client to `localhost:5000`:
$ var client = require('./client').connect('tcp://localhost:5000');
$ client.on('open', function(id) { client.accept(id); });
$ client.on('recv', function(id, data) {console.log(data.toString());});
To send data to one or more connections, use
$ client.send(data, connectionId ...);
The `index.html` in the top directory simply includes the appropriate
script tag so you can open a connection. Try serving it through your
favourite web server, e.g.:
$ python -m SimpleHTTPServer 8080
Then you can point a browser at that page, open a JavaScript console
in the browser, and open a connection (as suggested on the page
itself):
> var sock = new SockJS('http://localhost:8000/socks');
> sock.onmesssage = function(msg) { console.log(msg); };