Our system is based on the send of invitations between users. A user send an invitation to another user, if the invite accepts, immediately joins the game room and inviter learn the answer. Conversely, if the invitation to play expires or is rejected, user not know the answer because the INVITATION_REPLY event has not been fired.
STOP 0. Callback definition
Code: Select all
//...
smartFox.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);
//...
smartFox.AddEventListener(SFSEvent.INVITATION, OnInvitationReceived);
smartFox.AddEventListener(SFSEvent.INVITATION_REPLY, OnInvitationResponse);
smartFox.AddEventListener(SFSEvent.INVITATION_REPLY_ERROR, OnInvitationResponse);
STEP 1. SENDING INVITATION (CLIENT SIDE - INVITER)
Code: Select all
// Prepare the invitation
Sfs2X.Entities.User user1 = smartFox.UserManager.GetUserByName(MySelf);
Sfs2X.Entities.User user2 = smartFox.UserManager.GetUserByName(Invitee);
List<object> invitedUsers = new List<object>();
invitedUsers.Add(user1);
invitedUsers.Add(user2);
smartFox.AddEventListener(SFSEvent.ROOM_ADD,onRoomCreated);
smartFox.AddEventListener(SFSEvent.ROOM_CREATION_ERROR,onRoomCreationError);
SFSGameSettings settings = new SFSGameSettings("Game name");
settings.IsGame = true;
settings.MaxUsers = 2;
settings.MaxSpectators = 0;
settings.Extension = new RoomExtension(extensionId, extensionClass);
settings.InvitedPlayers.AddRange(invitedUsers);
smartFox.Send(new CreateSFSGameRequest(settings));
STEP 2. RECEIVING INVITATION (CLIENT SIDE - INVITEE)
Code: Select all
void OnInvitationReceived(BaseEvent evt)
{
Room room = (Room)evt.Params["..."];
string message = (string)evt.Params["..."];
//....
// Add invitation to invitation list of user
}
STEP 3. INVITATION RESPONSE (CLIENT SIDE - INVITEE)
Code: Select all
sfs2x.Send(new InvitationReplyRequest(Invitation, InvitationReply));
STEP 4. (CLIENT SIDE - INVITEE)
If the invitee accepts joins the game room.
STEP 5. INVITER VIEW RESULTS (CLIENT SIDE - INVITER)
If the invitee accepts, game start.
If the invitee refuses the invitation or the invitation expires inviter should display a message.
The problem is that if the invitee refuses the invitation or the invitation expires, on the inviter client side doesn't fire the INVITATION_REPLY event.
This is a screencast for three cases: ACCEPT - DECLINE - EXPIRED
SmartFoxServer version: 2.6.0
ClientAPI version: Unity/.Net/Mono C# API 1.0.7
Thanks in advance.