How can I send admin messages

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Post Reply
cenicol
Posts: 14
Joined: 19 Apr 2008, 15:38
Contact:

How can I send admin messages

Post by cenicol »

I have been searching through the docs and I cannot find how to send admin messages from a server side java extension. There does not seem to be a method on ExtensionHelper to send admin events.

I found reference to sending messages to an administrator extension in section 5.13 Custom Login Integration, but nothing on where the extension or sample code can be found or documentation for what commands it accepts.

There is not a "$dmn" named extension in config.xml either. Is this extension possibly built-in?

Mostly, I want to be able to send events to the client that will be caught by the onAdminMessage handler.

I think I must have missed something very basic since it seems no one else here has asked about this problem.

Thanks.. Carl
cenicol
Posts: 14
Joined: 19 Apr 2008, 15:38
Contact:

Sending admin messages from a java extension

Post by cenicol »

I did more reading and figured out how to send a text admin message. This method uses room to get the target room ID and user to get the socket channel of the user and user ID for the room. It could be generalized further to accept a linked list of socket connection IDs as is used by most send data commands.

Code: Select all

	/**
	 * Send an admin message to \a user in room \a room.
	 * @param room Room the user is in.
	 * @param user User to send the message to.
	 * @param message Contents of the message being sent. 
	 */
	public void SendAdminMessage(Room room, User user, String message) {
		String reply = "<msg t='sys'>"
			+ "<body action='dmnMsg' r='"+ room.getId() + "'>"
			+ "<user id='" + user.getPlayerIndex(room) + "'/>"
			+ "<txt>"

			+ "<![CDATA[" 
			+ message
			+ "]]>"
			
			+ "</txt>"
			+ "</body>" 
			+ "</msg>";
		
		LinkedList channelList = new LinkedList();
		channelList.add(user.getChannel());
		helper.sendGenericMessage(reply, null, channelList);			}
Boing
Posts: 59
Joined: 11 Apr 2008, 14:57

Post by Boing »

thanks for sharing.

Maybe an "Extensionhelper.sendAdminMessage(...)" method should go to the feature request list.

btw: Happy New Year everyone!
thomers1
Posts: 125
Joined: 13 Aug 2008, 07:36
Contact:

Post by thomers1 »

lapo, any outlook whether/when this will be added to the API?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Actually the Admin message is meant to be coming from the Admin Tool only so it was not thought as part of the API.

Instead you can simply create your own custom command and send it to all clients, or a selection of them, and call it what you prefer "Admin message" , "Root message", "Master message" ... you get the idea.

Cenicol:
There is not a "$dmn" named extension in config.xml either. Is this extension possibly built-in?
Yes, that's correct.
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply