we have recently received different reports from Linux users stating that the examples coming with SFS Lite/Basic didn't work in the broswer.
There seems to be an issue with both Flash player 6 and 7 under Linux but it's not a real bug. The problem is related with the slowness of such version of the player which leads to a misbehaviour in the code.
At this address >> www.gotoandplay.it/test/sfs_linux/advancedChat.zip
you can download a fixed version of the AdvancedChat example and below you will find an quick explanation of what was changed in the code and why.
The critical point is located in this code section under the "connect" label:
Code: Select all
//----------------------------------------------------------
// Handle login response from server
//----------------------------------------------------------
smartfox.onLogin = function(resObj:Object)
{
if (resObj.success)
{
// Login Successfull
_global.myName = resObj.name
gotoAndStop("chat")
}
else
{
// Login Failed
_global.isBusy = true
// Show an error window
var win = showWindow("errorWindow")
win.errorMsg.text = resObj.error
}
}
Once the onLogin() event is fired we use a gotoAndStop("chat") to move the playhead to the next frame and almost simultaneously the SFS API send a request to the server in order to receive the room List.
The onRoomListUpdate() event handler is located in the "chat" frame, and this is what causes the problem with the Linux Flash Player.
The player for Linux is so slow in performing the gotoAndStop() action that the response from the server still arrives in the previous frame and the event is lost.
The solution is to handle the same event in the "connect" event as well, holding the server response in a queue. When the flash player has finally moved to the next frame we'll check the queue and handle the event.
The new code looks like this:
Code: Select all
var evtQueue:Array = []
//----------------------------------------------------------
// Handle login response from server
//----------------------------------------------------------
smartfox.onLogin = function(resObj:Object)
{
if (resObj.success)
{
// Login Successfull
_global.myName = resObj.name
}
else
{
// Login Failed
_gloabl.isBusy = true
// Show an error window
var win = showWindow("errorWindow")
win.errorMsg.text = resObj.error
}
}
smartfox.onRoomListUpdate = function(o:Object)
{
evtQueue.push(o)
gotoAndStop("chat")
}
The gotoAndStop() was moved in the onRoomListUpdate(), the evtQueue list will hold that event and we will handle it in the next frame with this code:
Code: Select all
smartfox.onRoomListUpdate = function(roomList:Object)
{
roomList_lb.removeAll()
for (var i:String in roomList)
{
var room:Room = roomList[i]
roomList_lb.addItem(room.getName() + " (" + room.getUserCount() + ")", room.getId())
}
roomList_lb.sortItemsBy("label", "ASC")
// Join the default room
this.autoJoin()
}
if (evtQueue.length > 0)
{
smartfox.onRoomListUpdate(evtQueue[0])
delete evtQueue
}
As you can see the last three lines check if the queue contains a message and if so the message is sent to the onRoomListUpdate() handler.
We'll update all the other examples in the next releases!