Invitation problem

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

Jestervoo
Posts: 2
Joined: 10 May 2012, 15:32

Invitation problem

Postby Jestervoo » 10 May 2012, 15:48

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.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Invitation problem

Postby rjgtav » 10 May 2012, 21:55

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);
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.
Jestervoo
Posts: 2
Joined: 10 May 2012, 15:32

Re: Invitation problem

Postby Jestervoo » 11 May 2012, 08:24

Did as you said and nothing changed. The client is not receiving invitation events. :x but thanks
KrystalRe
Posts: 1
Joined: 31 May 2012, 11:56

Re: Invitation problem

Postby KrystalRe » 31 May 2012, 12:06

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?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Invitation problem

Postby Lapo » 04 Jun 2012, 07:12

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
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 20 guests