Page 1 of 1

Send object to all users

Posted: 26 Jan 2014, 12:28
by Goddes
So i am new to SmartFoxServer and i am developing Multiplayer Game using avatarChat as many people do.
So my question is how to send object to everyone. I know only how to send to user, but i want the object ot be sended to everyone in the room!

Here's the code is use:

Code: Select all

function sendEventMessage(toUser, myMsg, cmd) {
if (toUser != _global.myName) { 
var obj:Object = {}; 
obj.toUser = toUser;
obj.myMsg = myMsg;
obj.cmd = cmd;
obj.Owner = _global.myName;
obj.Guild = _root.LoadedGuild;
if (cmd == "kick") {
Moderator("" + toUser + " has been kicked.");
}

_root.smartfox.sendObject(obj); 
}
}
and then

Code: Select all

smartfox.onObjectReceived = function(obj, sender) {
if (_global.myName == obj.toUser) {
	if(obj.cmd == "kick") {
		closeConnection()
	} else if(obj.cmd == "gi") {
		_root.InvGuild = obj.Guild;
		gi.guild.text = "" + obj.Owner + " has invited you to join \"" + obj.Guild + "\" Guild, do you want to join?"
		gi._visible = true;
	}
}
}

So, simply the code doesn't matter much. I wan't to know how to send the object to everyone in the room.
Thanks in advance!

Re: Send object to all users

Posted: 27 Jan 2014, 08:50
by Bax
The SmartFoxClient.sendObject() method is supposed to send the passed object to all the users in the same Room of the sense.
What is not working for you?

Re: Send object to all users

Posted: 27 Jan 2014, 12:46
by Goddes
Well i have button like

Code: Select all

on(release) {
    _root.sendEventMessage("Username", "", "kick");
}
that will send Kick command only to the user specified .. "Username"

Re: Send object to all users

Posted: 27 Jan 2014, 14:28
by Bax
Sorry I don't understand: how is your last answer related to the previous posts?

Re: Send object to all users

Posted: 27 Jan 2014, 15:44
by Goddes
Ah never mind about the object i do new method using onUserVariables Update and that way i send what i want to everyone in the room. Another question, is it possible that i can send it to all rooms?

Re: Send object to all users

Posted: 27 Jan 2014, 15:47
by Bax
Not from the client side. A client can communicate with other clients in the same Room only.

Re: Send object to all users

Posted: 28 Jan 2014, 10:23
by Goddes
Thank you Bax ^^