Three questions :)

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

Moderators: Lapo, Bax

Post Reply
GolceaVlad
Posts: 36
Joined: 23 Aug 2010, 17:55

Three questions :)

Post 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 ?
?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post 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.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
GolceaVlad
Posts: 36
Joined: 23 Aug 2010, 17:55

Post 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 ?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post 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.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Post Reply