Send object to all users

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Post Reply
Goddes
Posts: 15
Joined: 25 Jan 2014, 21:08

Send object to all users

Post 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!
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Send object to all users

Post 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?
Paolo Bax
The SmartFoxServer Team
Goddes
Posts: 15
Joined: 25 Jan 2014, 21:08

Re: Send object to all users

Post 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"
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Send object to all users

Post by Bax »

Sorry I don't understand: how is your last answer related to the previous posts?
Paolo Bax
The SmartFoxServer Team
Goddes
Posts: 15
Joined: 25 Jan 2014, 21:08

Re: Send object to all users

Post 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?
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Send object to all users

Post by Bax »

Not from the client side. A client can communicate with other clients in the same Room only.
Paolo Bax
The SmartFoxServer Team
Goddes
Posts: 15
Joined: 25 Jan 2014, 21:08

Re: Send object to all users

Post by Goddes »

Thank you Bax ^^
Post Reply