InviteUsersRequest example is wrong or outdated

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

alexanderM
Posts: 1
Joined: 04 Feb 2021, 02:42

InviteUsersRequest example is wrong or outdated

Postby alexanderM » 04 Feb 2021, 03:00

I've tried following the example in this page:
http://docs2x.smartfoxserver.com/api-do ... 221f98.htm

It seems to have a couple of issues:
• First One is that it's using two names for the same variables: "friend1" and "user1", the same happens for friend2 and user2.
• When sending the invitedUsers list smartfox server logs throws this error:

Code: Select all

| 20:49:25,580 | WARN  | SFSWorker:Sys:2 | controllers.v290.SystemReqController |     | java.lang.IllegalArgumentException: Invited Users Array expected to contain at least 1 element!, Sender: ( User Name: Kermit, Id: 2, Priv: 0, Sess: 127.0.0.1:60189 ) com.smartfoxserver.v2.controllers.system.game.InviteUser.execute(InviteUser.java:58)


Could someone explain me how are we supposing to pass the invitedUsers list from the client side to make it find the array elemnts?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: InviteUsersRequest example is wrong or outdated

Postby Lapo » 04 Feb 2021, 08:07

Hi,
thanks for pointing this out. There seem to be a mismatch in the variable names. We'll fix it asap.
I have not tested this (yet) but it looks like you just have to use friend1 and friend2 as the variables to add to the List.

In other words:

Code: Select all

// Choose the invitation recipients
User friend1 = sfs.UserManager.GetUserByName("Piggy");
User friend2 = sfs.UserManager.GetUserByName("Gonzo");

List<object> invitedUsers = new List<object>();
invitedUsers.Add(friend1);
invitedUsers.Add(friend2);


When sending the invitedUsers list smartfox server logs throws this error:

From the error log it looks like the list you sent was empty.
Keep in mind that the Example you have mentioned assumes that those two Users exists in the Zone, i.e. they are real, logged-in Users. If not the friendX variable will be null and you're adding a bunch of null references to a List, which is then passed to the API.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 24 guests