how do I get the room from a "userLost" InternalEv

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

Moderators: Lapo, Bax

martin
Posts: 2
Joined: 30 Nov 2006, 12:40

how do I get the room from a "userLost" InternalEv

Postby martin » 31 Mar 2008, 11:35

In a Java extension I want to track the room of a user that disconnects from the server (e.g. by closing his browser window). My extension receives an InternalEventObject of type "userLost". The SFS docs say that this event has a parameter called "roomIds" of type int[].

But all get from this parameter is an array of 2 objects. There is no way I can cast this into an int or Integer. I wonder what kind of information this object holds? (If I print out the contents of an object[] which holds ints for testing in another file I get int values, which I can cast as ints. Not in this case, all I see is something like "[I"

Here's what I have:

Code: Select all

public void handleInternalEvent(InternalEventObject ieo)
{
      //how can I retrieve the room information form the following expression?
      ieo.getTypedObject("roomIds")[0];


Any idea how I can retrieve th room of the lost user? Thanks.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 01 Apr 2008, 05:29

I would use a different code:

Code: Select all

public void handleInternalEvent(InternalEventObject ieo)
{
   int[] roomIds = ieo.getObject("roomIds");
   int userRoomId = roomIds[0];
   
   // more code here...
}

hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
Zak
Posts: 13
Joined: 04 Mar 2008, 07:41
Location: Las Vegas
Contact:

Postby Zak » 09 Apr 2008, 21:52

I had a similar problem, and ended up solving it the long way by setting a "currentRoomId" user variable when a user enters a game room, which I then read when the userLost event goes. I'm sure this is a waste of resources though, and I will have to clean it up later.
User avatar
rgfernan
Posts: 11
Joined: 20 Mar 2010, 00:25
Location: Buenos Aires, Argentina
Contact:

roomIds[] content

Postby rgfernan » 14 Jul 2010, 13:34

What would be the content of the roomIds[] array? Is the roomIds[0] the last room the user joined?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Hello.

Postby Lapo » 15 Jul 2010, 17:00

Well,
there's no specific intention to keep a chronology or order of joining but I guess that this is implicit.
Since a List is being used in the User object, the returned array maps exactly that list and so the last element would also correspond to the last joined Room.

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 21 guests