DataStreamListener
If a nSession is created with a nDataStreamListener then it will receive asynchronous callbacks via the onMessage implementation of the nDataStreamListener interface. The nDataStreamListener will receive events when:
An event is published directly to this particular nDataStream
An event is published to any nDataGroup which contains this nDataStream
An event is published to an nDataGroup which contains a nested nDataGroup containing this nDataStream
An example of how to create a session with an nDataStreamListener interface is shown below:
public class DataGroupClient implements nDataStreamListener
{
var mySession:nSession;
public function DataGroupClient(realmURLs:String, retryAttempts:int)
{
var nsa:nSessionAttributes = new nSessionAttributes(realmURLs, retryAttempts);
mySession = nSessionFactory.create(nsa, username, appName, errorCB);
mySession.init(sessionInitCallback, null, false, this);
}
////
// nDataStreamListener Implementation
////
//Callback received when event is available
public function onMessage(event:nConsumeEvent):void
{
//some code to process the message
}
public function sessionInitCallback(e:*){
// do something with the session if needed
}
public function errorCB(e:*}{
//Error handling function
}
}