Page 1 of 1

Is it safe to edit SysHandler?

Posted: 14 Jul 2010, 18:38
by TreeTree
I need to get a user variable from the player who just disconnected from a room. But the user gets disconnected before the onUserLeaveRoom event is fired so I can't get the user object. So will it mess up anything if I did this to the SysHandler code?

Code: Select all

public function handleUserLeaveRoom(o:Object):void
{
var userId:int = int(o.body.user.@id)
var roomId:int = int(o.body.@r)
			
// Get room
var theRoom:Room = sfs.getRoom(roomId)
			
// Get user name
var uName:String = theRoom.getUser(userId).getName()
// My custom code
var place:Number = theRoom.getUser (userId).getVariable ("place");
// Remove user
theRoom.removeUser(userId)
			
// Fire event!
var params:Object = {}
params.roomId = roomId
params.userId = userId
params.userName = uName 
params.place = place;//My custom code

var evt:SFSEvent = new SFSEvent(SFSEvent.onUserLeaveRoom, params)
sfs.dispatchEvent(evt)
			 
}
I added 2 lines to include the variable I need in the params of the event. Is this safe to do?

Posted: 15 Jul 2010, 05:40
by BigFIsh
You should store all user's SFS object locally, so you can access them with userId if needed to.

i.e. users[userId]

Posted: 15 Jul 2010, 15:31
by TreeTree
Oh yeah I could do that... talk about overcomplicating. Well just for future knowledge is it safe to edit SysHandler?