TCPSocket
Orbited provides a socket interface, using an Orbited daemon to proxy TCP streams to the web browser. This allows clients written in JavaScript to connect to networks servers and send and receive data.
Using TCPSocket
Orbited serves clients for several network protocols from the /static/protocols directory. You can implement your own network client by using TCPSocket interface directly.
Add the following script tags to your html file:
<script src="http://yourdomain:8000/static/Orbited.js"></script> <script>TCPSocket = Orbited.TCPSocket</script>
Orbited must be running on a subdomain of your web server's location, but you can also run orbited on the same ip/domain but a different port. If you are using Orbited in a cross-port setup, include this script tag:
Orbited.settings.port = 8000
If you are using Orbited on a different subdomain:
Orbited.settings.hostname = yoursubdomain.example.com
TCPSocket API
Methods
- TCPSocket()
- connect(host, port, isBinary=true)
- Orbited will only connect to addresses explicitly allowed in the configuration (see Configuration#accessSection).
- send(message)
- close()
Callbacks
- onclose(code)
- onopen()
- onread(message)
Closing Codes
- Orbited.Errors.ConnectionTimeout = 101
- Orbited.Errors.InvalidHandshake = 102
- Orbited.Errors.UserConnectionReset = 103
- Orbited.Errors.Unauthorized = 106
- Orbited.Statuses.ServerClosedConnection = 201