EventReceiver

Overview

EventReceiver is used at client side to poll and receive server events. To enable event polling create an instance of EventReceiver passing channel and message as parameters, then add event handlers and start polling.

var channel = new RemObjects.SDK.HTTPClientChannel("http://" + document.location.host + "/BIN");
var message = new RemObjects.SDK.BinMessage();
var svc = new HTTPChatService(channel, message);
var er = new RemObjects.SDK.EventReceiver(channel, message, "", 1000);

er.addHandler("OnLogin", function (event) {
    log(event.aUserInfo.UserID + " just logged in.");
});
er.addHandler("OnLogout", function (event) {
    log(event.aUserID + " just logged out.");
});
er.addHandler("OnSendMessage", function (event) {
    log(event.aSenderUserID + " : " + event.aMessage);
});

er.setActive(true);

Location

RemObjectsSDK.js


Instance Methods


constructor EventReceiver

Creates an instance.

function constructor EventReceiver(aChannel, aMessage, aServiceName, aTimeout)

Parameters:


addHandler

Registers event handler. When event is received, callback function is called with event object as a parameter. Event object members are defined in the RODL.

function addHandler(anEventName, aCallback)

Parameters:

  • anEventName: string
  • aCallback: function(event)

getActive

Returns boolean value.

function getActive(aValue)

Parameters:

  • aValue:

getTimeout

function getTimeout()

intPollServer

Polls the server. Used internally.

function intPollServer()

setActive

Sets fActive. If true, starts polling the server and vice versa.

function setActive(aValue)

Parameters:

  • aValue: boolean

setTimeout

function setTimeout(aValue)

Parameters:

  • aValue: