Placing Text into a SmartFoxbits ChatBox

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

Moderators: Lapo, Bax

Wavemannova
Posts: 2
Joined: 24 Jan 2014, 00:08

Placing Text into a SmartFoxbits ChatBox

Postby Wavemannova » 24 Jan 2014, 14:30

I'd like to post some information in a chatBox from a button event in flash.

For example my game will have 4 players, when the first player chooses (lets call him Dave) their seat I want a message in the chat box saying "Dave is now Player 1".

When I use the PublicMessageRequest function it preludes the user name in the chat that comes into the chatBox:
Example:

Dave says: Dave is now Player 1

Is there a method I am missing that will allow me to send chat into a SmartFoxbits chatBox other than PublicMessageRequest?
User avatar
Bax
Site Admin
Posts: 4332
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Placing Text into a SmartFoxbits ChatBox

Postby Bax » 25 Jan 2014, 15:18

You could send a request to a server side Extension and from there send a moderator message to all the users in the Room.
The ChatBox component is capable of displaying moderator messages.
Paolo Bax
The SmartFoxServer Team
Wavemannova
Posts: 2
Joined: 24 Jan 2014, 00:08

Re: Placing Text into a SmartFoxbits ChatBox

Postby Wavemannova » 27 Jan 2014, 02:36

Thanks for the quick response Bax. When I try to implement the ModeratorMessageRequest function I get a compiler error in Flash 1180: Call to a possibly undefined method ModeratorMessageRequest.

I do have the appropriate import calls to
import com.smartfoxserver.v2.SmartFox;
import com.smartfoxserver.v2.requests.*;
import com.smartfoxserver.v2.core.SFSEvent;

in my code

Code: Select all

private function modMethod():void {
         sfs.addEventListener(SFSEvent.MODERATOR_MESSAGE, onModMsg);
         var recipMode:MessageRecipientMode = new MessageRecipientMode(MessageRecipientMode.TO_ROOM, sfs.lastJoinedRoom);
         sfs.send(new ModeratorMessageRequest("Dave is now Player 1", recipMode));
      }
      
private function onModMsg(evt:SFSEvent):void {
        trace ("received mod response");
      }
User avatar
Bax
Site Admin
Posts: 4332
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Placing Text into a SmartFoxbits ChatBox

Postby Bax » 27 Jan 2014, 08:44

I'm not sure why Flash can't find those classes, but anyway that's not the right approach: if you send a moderator request from the client, that user must have moderation privileges. You should handle this on the server side using a custom Extension: the client sends a message to the Extension and the server sends a moderator message.

If you don't want to use an Extension for that purpose only (maybe your game doesn't need it for other purposes), then you could use for example an ObjectMessageRequest: send a message to all the clients in the Room, and make all the clients write a string in the ChatBox by accessing the internal text area directly (you have a public property on the ChatBox class).
Paolo Bax
The SmartFoxServer Team

Return to “SmartFoxBits for SFS 2X”

Who is online

Users browsing this forum: No registered users and 2 guests