unique name for dinamically created room ?

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

Moderators: Lapo, Bax

Post Reply
kotbegemot
Posts: 82
Joined: 21 Nov 2010, 05:05
Location: Saint-Petersburg

unique name for dinamically created room ?

Post by kotbegemot »

How i can set unique room name for dinamically created rooms, by name+random ? But random may be not unique...
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post by rjgtav »

Hi. You can try the Date.getTime() or the getTimer() methods to get an unique name :-)
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.
kotbegemot
Posts: 82
Joined: 21 Nov 2010, 05:05
Location: Saint-Petersburg

Post by kotbegemot »

Thanks i try.

But random based on getTime....
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post by rjgtav »

If you use the getTime method, i dont think you need the random. You can also try the Date method which returns the time has passed since a default date (sorry cant remember the name :-P)
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.
User avatar
Evil-Dog
Posts: 86
Joined: 08 Mar 2011, 17:59
Contact:

Re: unique name for dinamically created room ?

Post by Evil-Dog »

Just for reference, you can use this
(new Date()).getTimer()
I think there's a better way to convert the number to string but this works just fine

What I ended up doing just to be 100% sure is this
settings.setName((new Date()).getTime() + "_" + rooms.size());

Worst case where 2 rooms are added in the same millisecond, it will append the number of rooms present in the zone so that number will be different for the second room created.
Post Reply