am i using scheduler right way?

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

ilcygnet
Posts: 8
Joined: 09 Sep 2009, 06:40
Location: Seoul, Korea

am i using scheduler right way?

Postby ilcygnet » 09 Sep 2009, 07:04

hi i'm developing some realtime server-client game
and it needs something time-relative logics in server side.
so i think that scheduler is needed 'cause i don't need
timer millisecond-accurate.

and now question,

example code says:
"create a new instance of the scheduler per application"
is "per application" mean "per zone" ?
if it is, making more than one scheduler will make no sense or would be inefficient.
so i'm trying to reference scheduler instance created in zone-extension
from every room-extension. am i doing right? i hope so.
but i don't know how to reference instance as written above.
should i use internal-request just for reference single instance?
it makes me crazy. plz help me!
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 10 Sep 2009, 10:57

"create a new instance of the scheduler per application"
is "per application" mean "per zone" ?

Yes, correct

if it is, making more than one scheduler will make no sense or would be inefficient.
so i'm trying to reference scheduler instance created in zone-extension
from every room-extension. am i doing right? i hope so.

Yes, you should create one Scheduler in the Zone by defining it in a Zone Level extension. Then you can get a reference from other Room Extensions to use always the same object

but i don't know how to reference instance as written above.
should i use internal-request just for reference single instance?
it makes me crazy. plz help me!

Yes, that's correct.
In the init() method of your Room extension you take a reference to the Zone Extension and use internalRequest to get the reference to the Scheduler. This way you just do it once.

All details are exposed here:
http://www.smartfoxserver.com/docs/docP ... bility.htm

NOTE:
A simpler way would require using a Singleton but every extension uses a different ClassLoader so it's not easy to do, so we recommend touse the interoperability function.
Lapo
--
gotoAndPlay()
...addicted to flash games
ilcygnet
Posts: 8
Joined: 09 Sep 2009, 06:40
Location: Seoul, Korea

Postby ilcygnet » 11 Sep 2009, 05:27

thanks! it's really helpful :D
and please excuse me one more question:

i tested the scheduler task to be called every 1 second
to trace simple text, but those texts seem not displayed
every 1 second as i planned. it seems like:

1 sec : displayed
2 sec : displayed
3 sec : displayed
4 sec : rest (not-displayed)
5 sec : displayed
6 sec : displayed
7 sec : displayed
8 sec : rest (not-displayed)
.
.

and so on.

i know scheduler is not such a exact timer, but i cannot use it
with irregular function call. the server i tested was completely light
weighted and only single connection was established.
could u explain me why this problem occurs? thank u :)
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 15 Sep 2009, 15:17

If you prefer you can use the Java 5 own scheduling class which is also more flexible than the SFS scheduler.
You should look into the ScheduledThreadPoolExecutor: http://www.j2ee.me/j2se/1.5.0/docs/api/ ... cutor.html
Lapo

--

gotoAndPlay()

...addicted to flash games
ilcygnet
Posts: 8
Joined: 09 Sep 2009, 06:40
Location: Seoul, Korea

Postby ilcygnet » 17 Sep 2009, 04:02

i'll do that. thx lapo! :)
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 17 Sep 2009, 15:06

Take a look at our Java Cookbook we have just added a new example on that topic: http://www.smartfoxserver.com/docs/docP ... okBook.htm

(see second last menu entry)
Lapo

--

gotoAndPlay()

...addicted to flash games
satishbhawra37
Posts: 2
Joined: 25 Sep 2009, 20:47
Contact:

Postby satishbhawra37 » 25 Sep 2009, 21:01

create a new instance of the scheduler per application"
is "per application" mean "per zone" ?
if it is, making more than one sche
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 26 Sep 2009, 09:23

Per application means "per Zone" as well
Lapo

--

gotoAndPlay()

...addicted to flash games
aMUSiC
Posts: 48
Joined: 15 Dec 2007, 17:15

Postby aMUSiC » 29 Mar 2010, 03:28

Lapo wrote:Yes, that's correct.
In the init() method of your Room extension you take a reference to the Zone Extension and use internalRequest to get the reference to the Scheduler. This way you just do it once.


Could you provide some AS code example for this? Should tasks be added in the room extension but on the reference of the zone level scheduler?
User avatar
RipX
Posts: 22
Joined: 15 Mar 2010, 22:49

Postby RipX » 29 Mar 2010, 17:19

This might be related, I wondered if this would be the same if I was creating a timer that needed to send messages to everyone in the zone. Lets take a game like CoD Modern Warfare. The server has a timing system that needs to track the game state.
This may be;
  • interval,
  • count down to playing
  • playing, countdown to end of game and back to interval


If, at a zone level, this was going to send a synchronize message to all clients would this be done upon joining the game, then the client store and run a timer internally, or would a message be sent to all clients upon entering any one of those states.? If the later, would this create a huge amount of server load?

Also, would players be able to create game rooms on the server that lasted for a given period of time if the scheduler was running at zone level? I guess not?

Regards

RipX

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 25 guests