Internal Event :: privMsg
Availability:
SmartFoxServer PRO 1.5.5
Event name:
privMsg
Description:
This event is fired each time a private message is sent.
By default the server does not create an event on every private message sent. If you want to listen for these type of event you will have to turn them on on your current Zone. Check the examples below for more details. The event handler can be useful to log or analyze the private messages sent by clients in the current Zone.
The private message transaction is split into two phases:
1 - the "privMsg" event is notified by the server to the listening extensions
2 - the extension processes the data and dispatches the message to the recipient by calling _server.dispatchPrivateMessage()
Properties:
name | description | type | |
msg | The message | java.lang.String(*) | |
room | The Room object | object | |
sender | The private message sender | object | |
recipient | The private message recipient | java.lang.String(*) |
(*) A note on data types: the parameters passed by the server events to the running extensions are all Java types.
You can use them transparently in Actionscript or cast them to AS native data types.
» javadoc for -> java.lang.String
Example:
/** * Extension intialization * This example can be used as Zone level extension */ function init() { /* enable "privMsg" internal events notification by default this event is turned off */ var zone = _server.getCurrentZone() zone.setPrivMsgInternalEvent(true) } /** * Handle internal events * * @param e the event object */ function handleInternalEvent(e) { evtName = e.name if (evtName == "privMsg") { sourceRoom = e.room // the room object sender = e.sender // the sender recipient = e.recipient // the recipient message = e.msg // the public message // ... do something cool here ... // dispatch the message to the recipient _server.dispatchPublicMessage(message, sourceRoom, sender, recipient) } }
See also:
_server.dispatchPrivateMessage()