Public message error - unknown senders!!

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

24500
Posts: 3
Joined: 07 Apr 2010, 13:17

Public message error - unknown senders!!

Postby 24500 » 08 Apr 2010, 15:30

this bug has had me scratching my head for some time now.

when i have 2 clients connected at the same time, the first client to send a public message comes up forever on the other client as an "unknown sender" when receiving a public message from it.

the error message is : WARNING! PublicMessage received from unknown sender. Command ignored!!

i am using a custom login method which automatically moves the clients into a room saved in the database - could this be the problem?

any help would be greatly appreciated
thanks in advance.
24500
Posts: 3
Joined: 07 Apr 2010, 13:17

Postby 24500 » 09 Apr 2010, 15:39

never mind - i fixed it myself with a workaround but im not sure how to fix it properly

simply made an extension command send the user list to the client and the client replaced it's with the one sent by the server.

the problem was that the user lists weren't being properly synchronized, i tried to fix it with the API source but couldn't so i settled with the quick fix

Server:
if(cmd=="getuserlist")
{
//send a hashtable of all the users
var response = new Object;
var zone = _server.getCurrentZone()
var Room = zone.getRoom(fromRoom)
var Users=Room.getAllUsers();
response.users = Users;
response.length = Users.length;
response._cmd = "userlist";
_server.sendResponse(response,-1,null,[user]);
}
Client:
SFSObject responseData = (SFSObject)data;
if (responseData.GetString("_cmd") == "userlist")
{
Hashtable users = (Hashtable)responseData.Get("users");
SFS.smartFox.GetActiveRoom().SetUserList(users);
}
tpelham42
Posts: 9
Joined: 27 Jan 2009, 00:01

Postby tpelham42 » 10 Jul 2010, 15:57

This post was quite helpful, but having a bit of an issue on the users return data. I setup an extension and am getting a valid response but Unity keeps giving me errors on...

Hashtable users = (Hashtable)responseData.Get("users");

Keep getting cannot cast from source type to destination type.

I added the length field in the response and it comes back with valid information so I know the extension is working, but I just can't seem to get the users hashtable data and I have it setup the same way in the server side extension.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 17 Jul 2010, 12:47

If you do a custom login, you have to remember to send roomlist (I think - been a while).

This is done automatically by the build in login, but not by a custom login.

User lists should afterwards be automatically updated afaik. But if you didnt get the initial room list, then a lot of stuff will simply not update itself.

This requirement is stated various places but easily missed. In addition you also have other things that you need to handle manually.

Cut'n'paste from here:

http://www.smartfoxserver.com/docs/inde ... _Login.htm

* When using a regular login, the client will handle the login response via the onLogin event handler. Behind the scenes the client API will assign the SmartFoxClient myUserName and myUserId properties.

* When using a custom login the response is sent back to the client via the extension and it is handled in the onExtensionResponse handler. Also the myUserName and myUserId properties ARE NOT populated auto-magically, so you will need to do it manually, if you need them.


Try and report back if that solved it for you
24500
Posts: 3
Joined: 07 Apr 2010, 13:17

Postby 24500 » 19 Jul 2010, 07:58

thanks thomas, these things dont occur to me!
that solution worked like a charm. My work around uses several API mods too (which i cant remember) so my solution is quite useless compared to thomas'

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 17 guests