You can use custom events to meet scenes like IM, barrage, and likes.
Both Room and Player (2.0.0-beta15) support custom events. Player cannot send custom events, but supports adding monitors and removing monitors.
public void addMagixEventListener(String eventName, EventListener eventListener);
public void removeMagixEventListener(String eventName);
addMagixEventListener
and removeMagixEventListener
are used to register and remove custom event listeners, eventName is the name of the message type. EventListener
is the processing when a custom event is received.
public void dispatchMagixEvent(AkkoEvent eventEntry);
dispatchMagixEvent
is used to send AkkoEvent, the structure of AkkoEvent is as follows:
payload
is any object that can be serialized by JSONeventName
is the name of the message type, everyone in the same room will receive the same message type message in the roompublic class AkkoEvent {
private String eventName;
private Object payload;
public AkkoEvent(String eventName, Object payload) {
this.eventName = eventName;
this.payload = payload;
}
}