The SFS2X Invitation Manager is very simple to use. All you need to provide is:
inviter: the User starting the invitation (null == Server)
invitee: the User to invite
expiryTime: the amount of time (in seconds) that the invitee has to accept/refuse the invitation. (default is 15 sec)
params: any custom params to send with the invitation (e.g. a message, game name etc...)
The Invitation system will then fire events back to a CallBack handler that you will provide in the form of a Class extending InvitationCallback.
If you pass null as the inviter, either to the SFSInvitation object, or to the API's sendInvitation method, you are given the following exception:
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: │
│Exception: java.lang.IllegalArgumentException │
│Message: Both Inviter and Invitee must be non-null User objects. │
│Description: Error while handling client request in extension: { Ext: __lib__, Type: JAVA, Lev: ROOM, { Zone: REDACTED }, [ MMORoom: REDACTED, Id: 0, Group: default, AOI: (100.0, 100.0, 1.0) ] } │
│Extension Cmd: REDACTED │
│+--- --- ---+ │
│Stack Trace: │
│+--- --- ---+ │
│com.smartfoxserver.v2.entities.invitation.SFSInvitationManager.prepareStartInvitation(SFSInvitationManager.java:178) │
│com.smartfoxserver.v2.entities.invitation.SFSInvitationManager.startInvitation(SFSInvitationManager.java:138) │
│com.smartfoxserver.v2.api.SFSGameApi.sendInvitation(SFSGameApi.java:213)
Just wanted to report.
SFS2X Version 2.18.3
Thanks.
Edit: I wanted to add that you can ignore the fact that this error occurs during a client request. I am building the SFSInvitation object manually on the server in response to a player command action that picks two users at random and then allocates them to a game room. I had also tried using the API command directly e.g.:
Code: Select all
User sender = null; // Server
List<User> userList = new CustomList<User>(userA, userB); // class CustomList<T> extends ArrayList<T> and has CustomList(T... things) { super(Arrays.asList(things)); } etc.
int expiry = 60;
Room gameRoom = exampleGeneratedRoom();
int invitedPlayers = userList.size();
boolean leaveLastRoom = false;
SFSGameInvitationCallback callbackHandler = new CustomCallbackHandler(gameRoom, invitedPlayers, leaveLastRoom);
getExtension().getGameApi().sendInvitation(sender, userList, expiry, callbackHandler, SFSObject.newInstance());
The reason I wasn't setting one of them as the "inviter" is
A) That doesn't make logical sense, if the option to have no inviter exists I'd have rather used it
B) The inviter doesn't seem to reliably trigger the server's OnRoomJoin event, which causes problems because I need to perform certain actions when a user joins the room