Server Event Handling

From Multiverse

Jump to: navigation, search

The Multiverse proxy server maps incoming events from the Multiverse Client to server-based messages. A server event is represented by a Java class that extends multiverse.server.engine.Event and thus must implement the method:

abstract protected void parseBytes(MVByteBuffer buf);

Using this method, Event objects can parse Client message data in the form of a MVByteBuffer into an Event object.

The server defines event objects in two packages:

The script multiverse/config/common/events.py defines the mapping between Client messages and server events. This script maps message IDs to the corresponding event class. For example, the line:

 evtSvr.registerEventId(2, "multiverse.server.events.DirLocEvent")

specifies to call the DirLocEvent object when the proxy server receives a message with ID of 2. This message would be created by the client, for example, when a player moves. The proxy server then dispatches this message to other plugins.

NOTE: Do not modify events.py since the client uses the message ID numbers it defines.

In a future release, you will be able to customize event handling.

In the meantime, send a Multiverse.Network.CommandMessage to the server and write a command handler in the proxy to translate this message to a server message. For more information on command handlers, see Defining Command Handlers.

Personal tools