[SOLVED] multiple servers using orbiter

All Union Platform questions, comments, feature requests, and bug reports.

multiple servers using orbiter  

Postby stevemann » Tue 27 Nov 2012 05:01

We are successfully adding multiple server connections in Reactor using connectionManager, so that if one falls out for any reason, the clients will then automatically connect to the other one. Works extremely well.

However we can't seem to find how to do the same thing with Orbiter. There is no real documentation for it apart from comments in the orbiter js file itself, and these are a bit confusing.

Can someone explain the correct procedure for adding connections to multiple servers in Orbiter? Thank you!

-Steve
stevemann
 
Posts: 20
Joined: Sat 26 May 2012 02:32

Re: multiple servers using orbiter

Postby colin » Sat 08 Dec 2012 14:21

hi steve,
Most of the Reactor API is identical to the Orbiter API, but adding connections manually is one area where the two APIs differ slightly. Here's an example showing how to create a WebSocket connection to server1.com with a backup HTTP connection to server2.com. The server2.com connection will not be used unless the server1.com connection fails.

Code: Select all
  // Add a WebSocket connection explicitly
  var connection1 = new net.user1.orbiter.WebSocketConnection("server1.com");
  orbiter.getConnectionManager().addConnection(connection1);

  // Add an HTTP connection explicitly
  var connection2;
  if (orbiter.getSystem().hasHTTPDirectConnection()) {
    connection2 = new net.user1.orbiter.HTTPDirectConnection("server2.com", 80);
  } else {
    connection2 = new net.user1.orbiter.HTTPIFrameConnection("server2.com", 80);
  }
  orbiter.getConnectionManager().addConnection(connection2);

  // Connect, starting with connection1
  orbiter.connect();


Please let me know if you discover any other areas where the Reactor documentation can not be applied to Orbiter JavaScript development.

colin
colin
 
Posts: 232
Joined: Mon 17 Oct 2011 18:47


Return to Union Platform

Online

Users browsing this forum: No registered users and 1 guest