Class SFSEvent

java.lang.Object
com.smartfoxserver.core.SFSEvent
All Implemented Interfaces:
ISFSEvent

public class SFSEvent extends Object implements ISFSEvent
Events are notified to Server Extensions via listeners. Each event object provides a number of parameters that are documented in SFSEventType

Here's an example of how events can be handled in an Extension:


 public void init()
 {
 	addEventHandler(SFSEventType.USER_JOIN_ZONE, this::userJoinZone);
 }

 private void userJoinZone(ISFSEvent evt)
 {
	User user = evt.getParameter(SFSEventParam.USER);
	Zone zone = evt.getParameter(SFSEventParam.ZONE);
 	
	trace("User:", user.getName(), "joined:", zone.getName());
 }
 
See Also:
  • Constructor Details

    • SFSEvent

      public SFSEvent(com.smartfoxserver.core.EventType type)
      Internal
    • SFSEvent

      public SFSEvent(com.smartfoxserver.core.EventType type, Map<ISFSEventParam,Object> params)
      Internal
  • Method Details

    • getType

      public com.smartfoxserver.core.EventType getType()
      Get the type of the event
      Specified by:
      getType in interface ISFSEvent
      Returns:
      the type of the event
      See Also:
      • EventType
    • getParameter

      public Object getParameter(ISFSEventParam id)
      Get the value for a specific parameter, or null if no such parameter exists.
      Specified by:
      getParameter in interface ISFSEvent
      Parameters:
      id - the name of the parameter
      Returns:
      the parameter value, null if no such parameter exists for the provided name
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object