Page 1 of 1

Invitation problem

Posted: 10 May 2012, 15:48
by Jestervoo
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.

Re: Invitation problem

Posted: 10 May 2012, 21:55
by rjgtav
Hi.
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);

Re: Invitation problem

Posted: 11 May 2012, 08:24
by Jestervoo
Did as you said and nothing changed. The client is not receiving invitation events. :x but thanks

Re: Invitation problem

Posted: 31 May 2012, 12:06
by KrystalRe
Jestervoo wrote:Did as you said and nothing changed. The client is not receiving invitation events. :x but thanks
I encounteres the same problem. Have you managed to solve yours?

Re: Invitation problem

Posted: 04 Jun 2012, 07:12
by Lapo
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:
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