About the Event

Started by x199x, April 15, 2012, 04:05:50 PM

Previous topic - Next topic

x199x

hi,victor
  When the Event generate in the Server. We can see the Event in the Console. Does the console active "ask" the Server whether an Event generate circularly? Or the Server active "tell" the Console in time when an Event is generate ?
  I saw the code,it may be the second situation. But I am writing my own client with java api. I don't know how I can get it in java api when the Server "tell" the client a Event is generations.?
Thanks!

Victor Kirhenshtein

Hi!

Server sends notification to client when new event created. Client must be subscribed to event notifications. Simple code for receive event notifications can looks like this:



// subscribe
session.subscribe(CHANNEL_EVENTS);

// add notification handler
session.addListener(new SessionListener() {
@Override
public void notificationHandler(final SessionNotification n)
{
if (n.getCode() == NXCNotification.NEW_EVENTLOG_RECORD)
{
Event e = (Event)n.getObject();
// do what you need with event object
}
}
});


Remember that notification handler called in background communication thread and should not perform any long-running tasks.

Best regards,
Victor

x199x