Page 1 of 1
Three questions :)
Posted: 17 Apr 2011, 08:42
by GolceaVlad
Hi Guys,
I'd like to send a special variable from one user to another.
1) Is there a direct way to do this, or just going through the server ?
2) On the server side, si there a simpler way to get the user than sending the username in the parameters, then running a for :
[code]for(var i = 0 ; i < peopleInTheRoom ; i++)
{
var userIs = peopleInTheRoom[i]
if(userIs.getName() == params.targetUser)
{ etc } ...
[/code]
3) Can I create a place where two users can play individually and sepparate from the rest without creating a new room ?
?
Posted: 17 Apr 2011, 11:57
by rjgtav
Hi.
GolceaVlad wrote:I'd like to send a special variable from one user to another.
1) Is there a direct way to do this, or just going through the server ?
You can use the sendObjectToGroup() method, by using it like: sendObjectToGroup(object, [the name of the user you want to send the object]).
For more information you can check the AS2 API:
http://www.smartfoxserver.com/docs/docP ... ectToGroup
GolceaVlad wrote:2) On the server side, si there a simpler way to get the user than sending the username in the parameters, then running a for :
Code: Select all
for(var i = 0 ; i < peopleInTheRoom ; i++)
{
var userIs = peopleInTheRoom[i]
if(userIs.getName() == params.targetUser)
{ etc } ...
Yes, there is. You can get an user by its Id, by using _server.getUserById(Id), so you would only need to send the id of the user in the params.
For more information you coud check the Serverside AS API:
http://www.smartfoxserver.com/docs/docP ... erById.htm
GolceaVlad wrote:3) Can I create a place where two users can play individually and sepparate from the rest without creating a new room ?
?
Well, in my opinion, its better if you create a dynamic game room, where the players can play.
Posted: 17 Apr 2011, 15:02
by GolceaVlad
regarding 3 :
I am using a chatroom -= database =- and also I need to create a gameroom. When the user wants to join a room, how do I display the game rooms sepparately from the chatrooms and vice versa ?
Posted: 17 Apr 2011, 15:07
by rjgtav
Hum... For example you could call all the game rooms by starting its names by "Game-", for example: "Game-TicTacToe", "Game-Snake",.... Then in the client-side you could analyse the roomnames and then put the games in one section and the other ones in the other section.