Is it safe to edit SysHandler?

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Post Reply
TreeTree
Posts: 12
Joined: 28 May 2010, 00:22

Is it safe to edit SysHandler?

Post 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?
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post 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]
Smartfox's forum is my daily newspaper.
TreeTree
Posts: 12
Joined: 28 May 2010, 00:22

Post by TreeTree »

Oh yeah I could do that... talk about overcomplicating. Well just for future knowledge is it safe to edit SysHandler?
Post Reply