How to process SFSGame Invitation replies and expired
How to process SFSGame Invitation replies and expired
Hi all. We are developing a card game that has many ways of confrontation (invitation, tournament,...). One way consist on invitations, for example user A sends an invitation to user B. How can I process the invitation replies (and invitation expired) on client side 'A'? Thanks in advance.
Re: How to process SFSGame Invitation replies and expired
Hi,
I apologize for the delay.
The client side API provides the necessary events to receive the invitation responses:
SFSEvent.INVITATION
SFSEvent.INVITATION_REPLY
SFSEvent.INVITATION_REPLY_ERROR
Also you have the InvitationRequest object to send the invitation to a group of players
You can check them in the documentation here:
http://docs2x.smartfoxserver.com/api-do ... Index.html
And get an overview here:
http://docs2x.smartfoxserver.com/Advanc ... s/game-api
I apologize for the delay.
The client side API provides the necessary events to receive the invitation responses:
SFSEvent.INVITATION
SFSEvent.INVITATION_REPLY
SFSEvent.INVITATION_REPLY_ERROR
Also you have the InvitationRequest object to send the invitation to a group of players
You can check them in the documentation here:
http://docs2x.smartfoxserver.com/api-do ... Index.html
And get an overview here:
http://docs2x.smartfoxserver.com/Advanc ... s/game-api
Re: How to process SFSGame Invitation replies and expired
Hi Lapo, in first place thanks for reply.
I have defined this event handlers on side client:
Them all are defined with the same method in order to test if events are catched correctly.
The following diagram represents the idea: It seems that "OnInvitationResponse" method is fired only in send invitation case. When receiver respond to invitation it seems nothing happens (both accept and decline) and sender does not know what happens. What is the correct way to manage this events?
Thanks in advance.
Héctor Navarro.
I have defined this event handlers on side client:
Code: Select all
smartFox.AddEventListener(SFSEvent.INVITATION, OnInvitationResponse);
smartFox.AddEventListener(SFSEvent.INVITATION_REPLY, OnInvitationResponse);
smartFox.AddEventListener(SFSEvent.INVITATION_REPLY_ERROR, OnInvitationResponse);The following diagram represents the idea: It seems that "OnInvitationResponse" method is fired only in send invitation case. When receiver respond to invitation it seems nothing happens (both accept and decline) and sender does not know what happens. What is the correct way to manage this events?
Thanks in advance.
Héctor Navarro.
Re: How to process SFSGame Invitation replies and expired
Can you provide a step by step description of how your test works?
Are you sure there's no server side errors?
The first two events should fire regularly. INVITATION_REPLY_ERROR is not implemented at the moment. We have decided not to send any errors back to the client.
Are you sure there's no server side errors?
The first two events should fire regularly. INVITATION_REPLY_ERROR is not implemented at the moment. We have decided not to send any errors back to the client.
Re: How to process SFSGame Invitation replies and expired
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
STEP 1. SENDING INVITATION (CLIENT SIDE - INVITER)
STEP 2. RECEIVING INVITATION (CLIENT SIDE - INVITEE)
STEP 3. INVITATION RESPONSE (CLIENT SIDE - INVITEE)
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.
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);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));Code: Select all
void OnInvitationReceived(BaseEvent evt)
{
Room room = (Room)evt.Params["..."];
string message = (string)evt.Params["..."];
//....
// Add invitation to invitation list of user
}Code: Select all
sfs2x.Send(new InvitationReplyRequest(Invitation, InvitationReply));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.
Re: How to process SFSGame Invitation replies and expired
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);Also you're not setting the game Room as private, which would allow someone to join it while the invitation is running.
Re: How to process SFSGame Invitation replies and expired
Hi Lapo, in first place thanks for your response.
If the inviter doesn't send an invitation to himself, SmartFox throws this error:
What can be the problem?
Thanks in advance.
If the inviter doesn't send an invitation to himself, SmartFox throws this error:
Now I settings the game Room as private, but I still don't receive event notifications. This is my new code:...Invited players (size = 1) are not enough to start the game (min = 2). Additionally no searchable rooms were provided...
Code: Select all
// Prepare the invitation
Sfs2X.Entities.User user1 = smartFox.UserManager.GetUserByName(Inviter);
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.IsPublic = false;
settings.MaxSpectators = 0;
settings.Extension = new RoomExtension(extensionId, extensionClass);
settings.InvitedPlayers.AddRange(invitedUsers);
smartFox.Send(new CreateSFSGameRequest(settings));Thanks in advance.
-
Prajju2000
- Posts: 1
- Joined: 26 May 2023, 16:22
Re: How to process SFSGame Invitation replies and expired
Hii everyone, In the current flow which i'm following the "SFSEvent.INVITATION_REPLY" event is not being tiggered even after sending the new InvitationReplyRequest(invitation, InvitationReply.ACCEPT).
The flow is ,
In the client_1 ,
In the client_2,
but, In Client_1, "SFSEvent.INVITATION_REPLY" event is not being triggred, even though 2 clients were joined the room successfully.
Please, Can anyone give a clarification on this.
Thank you in advance.
The flow is ,
In the client_1 ,
Code: Select all
SFSGameSettings settings = new SFSGameSettings(roomName);
settings.GroupId = "games";
settings.MaxUsers = 2;
settings.MaxSpectators = 10;
settings.MinPlayersToStartGame = 2;
settings.IsPublic = false;
settings.LeaveLastJoinedRoom = true;
settings.NotifyGameStarted = true;
settings.InvitationExpiryTime = 50;
settings.InvitedPlayers = new List<object>();
settings.InvitedPlayers.Add(sfs.BuddyManager.GetBuddyByName(buddyName));
sfs.Send(new CreateSFSGameRequest(settings));Code: Select all
sfs.AddEventListener(SFSEvent.INVITATION, OnInvitation);
private void OnInvitation(BaseEvent ev)
{
Debug.Log("Recieved one invitaion");
Invitation invitation = (SFSInvitation) ev.Params["invitation"];
sfs.Send(new InvitationReplyRequest(invitation, InvitationReply.ACCEPT));
}Please, Can anyone give a clarification on this.
Thank you in advance.
Re: How to process SFSGame Invitation replies and expired
@Prajju2000
Can you clarify what version of SFS2X are you using and what client API? (also which version)
Thanks
Can you clarify what version of SFS2X are you using and what client API? (also which version)
Thanks