Skip to content

Clientapi

Greg edited this page Mar 10, 2014 · 7 revisions

global cloak object

cloak.configure(config)

Configuration options are given in ClientConfiguration.

Example:

cloak.configure({
  messages: {
    bar: function(arg) {
      console.log('bar from server');
    }
  },
  serverEvents: {
    begin: function() {
      console.log('begin');
    }
  }
});

cloak.run(host)

cloak.run('http://localhost:8090');

cloak.message(name, arg)

Sends a message to the server. The message handler on the server gets called if there is one for this message name.

cloak.connected()

Returns true or false

cloak.currentUser()

Get the unique id of the current user. This is the same value as user.id on the server.

cloak.stop()

Disconnect and do not attempt to reconnect.