Removing and adding ChatBox creates issues...

Everything about the SmartFoxBits UI Components for SmartFoxServer 1.x. Post your questions, suggestions and bug reports.

Moderators: Lapo, Bax

Biff_Cornwall
Posts: 29
Joined: 07 Aug 2009, 17:54

Removing and adding ChatBox creates issues...

Postby Biff_Cornwall » 06 Nov 2009, 16:28

Hey All,

When the chatbox is instantiated for the first time, everything works exactly as it should. When the chatbox is set for garbage collection (all listeners/timers/enter frame events/etc... are removed) and then a new instance of the chatbox is created, everything works, except displaying any previous messages between the users, either by using the setPrivateChatId method or the setMessagesQueue method. Tracing out the text inside the ta_chat textarea component like such:

Code: Select all

trace("ta_chat.htmlText = " + ta_chat.htmlText);

traces out the text that should be displayed, but it does not actually display the text on the screen. Everything else works fine, i.e. chatting and scrolling and all that. I've been chasing this down for two days now and can't come up with a reason as to why this isn't working. Any help would be greatly appreciated.

Thanks!
Biff
User avatar
cksachdev
Posts: 55
Joined: 28 Aug 2007, 10:13
Location: Bangalore, India
Contact:

Postby cksachdev » 06 Nov 2009, 18:21

@Biff:
I have a doubt. When you have removed, ta_chat, then how you are able to get previous text messages, in my opinion, your new ta_chat(textarea) should not have any value in htmlText.

Code: Select all

trace("ta_chat.htmlText = " + ta_chat.htmlText);

If you want me to look at your source, do send out a mail to cksachdev [at] gmail [dot] com
--
Chetan Sachdev
Site: http://www.chetansachdev.com
Biff_Cornwall
Posts: 29
Joined: 07 Aug 2009, 17:54

Postby Biff_Cornwall » 10 Nov 2009, 20:44

Hey cksachdev,

Thanks for the response!

We log the chat messages between users (via a ChatLog class that I've written) as long as they stay in the same room. The chat window is accessed by clicking on the user (which displays a user information panel) and clicking on a chat button in the panel. That in turns opens up the chat window, where the chatbox is created. If they have chatted previously (and neither have left the room), we want to display their previous chat messages out of convenience. This way, when they aren't chatting they can close the user information panel, but still keep up with their chat when they go back to it.

I actually spent two full days debugging this issue and chased the bug all the way down into the source code (thank goodness we purchased it!).

It turns out both the setPrivateChatUserId() method and the setMessagesQueue() method were being executed before the draw() method. Because of this, the text in the ta_chat box was not being rendered on the screen, even though it was technically there (which was why it was showing up in my trace statements, but not on screen).

Also, it really had nothing to do with removing the chatbox and then instantiating it again. I thought that was the issue at first, but it turns out that any time you create an instance of the chat box and you try to pre-populate the ta_chat text area, this bug will occur. The only reason I thought it was due to removing and instantiating again was because of the user click-through flow, where there wouldn't be any chat history the first time it was instantiated, so there would be no pre-population of the ta_chat text area.

I've submitted my findings to the SmartFox team and came up with a simple (albeit a bit shoddy) patch to ensure the setPrivateChatUserId() method doesn't execute until the draw() method is complete, and it works perfectly now.

Thanks!
Biff

Return to “SmartFoxBits for SFS 1.x”

Who is online

Users browsing this forum: No registered users and 4 guests