What's New in Director 8.5 > Multiuser Server-Side Scripting > Adding server-side scripts > Sending messages from server-side scripts

 

Sending messages from server-side scripts

Your server scripts can send messages to their movies by using the sendMessage() command. The following server script sends a message back to the movie that calls the handler testHandler:

on incomingMessage (me, movie, group, user, fullMsg)
	-- if the #subject of the incoming message is "testHandler"
	-- call that handler and pass it the fullMsg as an argument
	case fullMsg.subject of 
		"testHandler":
			me.testHandler(user, fullMsg)
	end case
end
	
on testHandler me, user, fullMsg
	-- send a message back to the user saying that the incoming 
	-- message was received
	user.sendMessage(fullMsg.senderID, "Server response", \
	"Your message was received")
end

By specifying user.sendMessage you tell the server to send the message to the user object passed in with the original incoming message.