interception message

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
regulxenao
Posts: 34
Joined: 03 Mar 2011, 20:29

interception message

Postby regulxenao » 10 Mar 2011, 11:15

How can I intercepte public messages - modif or remove it? And can I filter outgoing public messages from server to user (for example, that would be some sort of message block something which users?).
stix
Posts: 9
Joined: 01 May 2010, 15:51

Postby stix » 10 Mar 2011, 15:29

You can listen for the event in an extension. Something like this:

this.addEventHandler(SFSEventType.PUBLIC_MESSAGE, onPubMsg.class);

then in your onPubMsg.class you can handle filtering etc.
User avatar
regulxenao
Posts: 34
Joined: 03 Mar 2011, 20:29

Postby regulxenao » 10 Mar 2011, 16:46

Yes :-) But how I can stop event dispatching? I can listen public message, but can't break message event.
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 11 Mar 2011, 10:45

You can use Extension Filters. Check the bottom of this document.
Paolo Bax
The SmartFoxServer Team
User avatar
regulxenao
Posts: 34
Joined: 03 Mar 2011, 20:29

Postby regulxenao » 11 Mar 2011, 13:15

bax wrote:You can use Extension Filters. Check the bottom of this document.


Hi, bax! Thanks for answer.

Yes, I did as written at this document. But I understood, that filter make enable or disable of execution of the Extension, not filtering message sending. If I do return "CONTINUE" in Filter - the Extenstion work well and user recive public message. But if I return HALT - my extenstion doesn't work, but user still recive public message message! I need filter outgoing messeges.
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 15 Mar 2011, 13:13

Then you can't use the default PublicMessageRequest. You have to use a custom extension request, apply your own filtering logic inside the request handler in your Extension and then send the message to all users using SFSAPI.sendPublicMessage().
Paolo Bax
The SmartFoxServer Team
styx
Posts: 68
Joined: 13 May 2010, 19:41
Location: Poland

Postby styx » 17 Mar 2011, 10:19

If I use a custom extension request, will I still be able to use the FloodFilter and WordsFilter?

I would like to avoid writing publicmessages in rooms where the number of users is over 200 If the room will keep less than 200 users, again, allow them to write.

What is the best solution?
tpenn
Posts: 95
Joined: 03 Aug 2010, 18:48

Postby tpenn » 17 Mar 2011, 15:12

I know you can apply the word filter in a custom extension, as I do it myself. Something like:

Code: Select all

getParentExtension().getParentZone().getWordFilter().apply(message, user);

I'm not as familiar with the flood filter, but I would imagine it can be used similarly.
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 18 Mar 2011, 17:19

The flood filter works at a lower level, so don't worry about it.
Paolo Bax
The SmartFoxServer Team

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 43 guests