Hi.
I want to send an invitation from the server, but on the client, nothing happens. The user enters the room, but the listeners(INVITATION) does not work
Client:
init
....
sfsClient.addEventListener(SFSEvent.INVITATION, this);
sfsClient.addEventListener(SFSEvent.INVITATION_REPLY, this);
sfsClient.addEventListener(SFSEvent.INVITATION_REPLY_ERROR, this);
...
RoomExtension extension = new RoomExtension(EXTENSION_ID, EXTENSIONS_CLASS);
SFSGameSettings settings = new SFSGameSettings("new room");
settings.setGroupId(GAME_ROOMS_GROUP_NAME);
settings.setGame(true);
settings.setMaxUsers(2);
settings.setMaxSpectators(0);
settings.setExtension(extension);
sfsClient.send(new CreateSFSGameRequest(settings));
...
room is created successfully
...
SFSObject toSend = new SFSObject();
toSend.putUtfString("user name", userName);
sfsClient.send(new ExtensionRequest("invite", toSend, sfsClient.getLastJoinedRoom()));
-------------------
Server:
invite handler
....
User recipient = getApi().getUserByName(name);
Invitation invitation = new SFSInvitation(user, recipient, GameCreationParam.WAITING_TIME);
InvitationCallback invitationCallback = new SFSGameInvitationCallback(getParentExtension().getParentRoom(), 1, true);
invitationCallback.onAccepted(invitation, new SFSObject());
invitationCallback.onRefused(invitation, new SFSObject());
invitationCallback.onExpired(invitation);
getInvitationManager().startInvitation(invitation, invitationCallback);
-----------------------------------
Help please. Thanks in advance.
Invitation problem
Re: Invitation problem
Hi.
Maybe the invitation is being sent because you call the InvitationCallback.onExpire() method. Try removing the following lines and then try again:
Maybe the invitation is being sent because you call the InvitationCallback.onExpire() method. Try removing the following lines and then try again:
Code: Select all
invitationCallback.onAccepted(invitation, new SFSObject());
invitationCallback.onRefused(invitation, new SFSObject());
invitationCallback.onExpired(invitation);
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Re: Invitation problem
Did as you said and nothing changed. The client is not receiving invitation events. but thanks
Re: Invitation problem
Jestervoo wrote:Did as you said and nothing changed. The client is not receiving invitation events. but thanks
I encounteres the same problem. Have you managed to solve yours?
Re: Invitation problem
You don't need to create the Room and then send an invitation manually. You can do that in one shot. In order to invite people in a private game you must:
1) set the game as private
2) provide the min. number of players needed to start the game
3) provide the users you want to invite and/or the room groups in which to search other players randomly
4) provide the invitation parameters.
I don't see any of that in your code.
Plus this is incorrect:
You are not supposed to invoke the callback yourself, that's the job of the API
Please make sure to check the documentation first:
http://docs2x.smartfoxserver.com/api-do ... tings.html
1) set the game as private
2) provide the min. number of players needed to start the game
3) provide the users you want to invite and/or the room groups in which to search other players randomly
4) provide the invitation parameters.
I don't see any of that in your code.
Plus this is incorrect:
invitationCallback.onAccepted(invitation, new SFSObject());
invitationCallback.onRefused(invitation, new SFSObject());
invitationCallback.onExpired(invitation);
You are not supposed to invoke the callback yourself, that's the job of the API
Please make sure to check the documentation first:
http://docs2x.smartfoxserver.com/api-do ... tings.html
Return to “SFS2X Java / Android API”
Who is online
Users browsing this forum: No registered users and 20 guests