I am unable to get the client listeners to fire for events sent by the extension. For SFS events such as LOGIN, ROOM_JOIN, USER_ENTER_ROOM, they're firing alright, but for events sent by my Extension such as "START", "MOVE", they're not. I come to know from the trace on the server side that the code is being executed. But the client side handler method does not fire.
Server Extension Code as follows:
Code: Select all
public class MyExtension extends SFSExtension {
@Override
public void init() {
trace(" MyExtension.init() - Registering Request Handler");
addRequestHandler("START", StartRequestHandler.class);
}
}
public class StartRequestHandler extends BaseClientRequestHandler {
@Override
public void handleClientRequest(User sender, ISFSObject param) {
int round = param.getInt("round");
trace(sender.getName() + " has asked to start round " + round);
ISFSObject resObj = new SFSObject();
resObj.putInt("round",round);
send("START",resObj,sender);
}
}
Client code added to the dispatch method of SFSEventHandler in BasicClient example of standard Java Client released as follows:
Code: Select all
public void dispatch(BaseEvent event) throws SFSException
{
System.out.println("Event.getType:" + event.getType());
.
.
else if (event.getType().equals(SFSEvent.ROOM_JOIN))
{
System.out.println("Room joined: " + event.getArguments().get("room"));
System.out.println("Now asking server to start");
ISFSObject obj = new SFSObject();
obj.putInt("round", 1);
sfs.send(new ExtensionRequest("START",obj));
}
else if (event.getType().equals("START"))
{
int round = (Integer)event.getArguments().get("round");
System.out.println("Server accepts your request to start round " + round);
}
}
The client output is:
Event.getType:connection
Connected. Now sending login request.
Event.getType:login
Logged in. Now joining 'The Lobby' room
Event.getType:roomJoin
Room joined: [Room: The Lobby, Id: 2, GroupId: default]
Now asking server to start
The server output is:
Guest#3 has asked to start round 1
The standard java client example released has only SFS Events, though I am sure Responses to Client Requests and Extension sent events work in a similar fashion. I have surely missed out something elementary. Are there any configuration changes I have to do, do these events have to be registered on the admin portal as zone/room variables?
Can some one please tell me what am I missing? I have been stuck on it for a couple of days.
Thanks.