Send message at a FixedRate

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

peter890
Posts: 12
Joined: 31 May 2011, 04:01

Send message at a FixedRate

Postby peter890 » 28 Jun 2011, 04:02

I have a senario like this - will be sending position update message to each user in a perticular room, this is like every sec. I need to control the network traffic to the client, is there a way i can setup some time fixed and post these messages, any examples on this will be gr8 help.

Thanks,
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 28 Jun 2011, 05:37

hi. To achive that you can try using the Scheduler, which is used to schedule a task to occur in a specific interval
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.
peter890
Posts: 12
Joined: 31 May 2011, 04:01

Postby peter890 » 30 Jun 2011, 06:39

rjgtav wrote:hi. To achive that you can try using the Scheduler, which is used to schedule a task to occur in a specific interval



Thank you.
so i want to send user variables/Room variable update to client at a perticular time in the form of packet. so the client side will unpack and use the variables. how do i achive this.

Thanks in advance
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 30 Jun 2011, 09:25

Hi. For a tutorial about using the Scheduler, you can check here:

http://docs2x.smartfoxserver.com/Gettin ... wtos#item7
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.
peter890
Posts: 12
Joined: 31 May 2011, 04:01

Postby peter890 » 04 Jul 2011, 12:22

rjgtav wrote:Hi. For a tutorial about using the Scheduler, you can check here:

http://docs2x.smartfoxserver.com/Gettin ... wtos#item7


i am scheduling at every 3 sec once the user variable update will be sent to all room users. to reduce the network traffic on server side.

but when i collect all the incoming user variable update and packet it. while sednging them in a perticular interval facing one problem, the user who is sending should not receive user variable update. how do i do this.

here is the code iam using on server side

result= new SFSArray();
result = map.get(currentRoom.getId());
result.addSFSObject(object);
map.put(currentRoom.getId(), result);

map is a hash map.

in the looping task will read through the Map and send the packet per room,

Set<Integer> set = map.keySet();
for(Integer ks:set){
object.putSFSArray("arr", response);
send(CMD_SET_USER_VARIABLES, object,userList);

//userlist getting it using the roomId.
but all user's of that room will be receiving these updates, how to avoid not to receive user who sent the update req.

Thanks in advance.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 04 Jul 2011, 20:22

Hi. To achieve that you need to create a new List, where you put all the users except the sender.
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.
peter890
Posts: 12
Joined: 31 May 2011, 04:01

Postby peter890 » 13 Jul 2011, 12:42

rjgtav wrote:Hi. To achieve that you need to create a new List, where you put all the users except the sender.



Hi,

i am using the schedular to send message packet at a fixed rate. i read the document and using the same way.
we have TaskRunner implements Runnable in this class their is a call taskHandle.cancel().

we have to pass value to this method either true/false
what actully this cancel will do.what value we should put true/false.

Thanks in advance.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 141 guests