Class SocketEvent

java.lang.Object
org.omnifaces.cdi.push.SocketEvent
All Implemented Interfaces:
Serializable

public final class SocketEvent extends Object implements Serializable

This web socket event will be fired by SocketSessionManager when a socket has been @SocketEvent.Opened, @SocketEvent.Switched or @SocketEvent.Closed. An application scoped CDI bean can @Observes them.

For detailed usage instructions, see Socket javadoc.

Since:
2.3
Author:
Bauke Scholtz
See Also:
  • Method Details

    • getChannel

      public String getChannel()
      Returns the <o:socket channel>.
      Returns:
      The web socket channel name.
    • getUser

      public <S extends Serializable> S getUser()
      Returns the current <o:socket user>, if any.
      Type Parameters:
      S - The generic type of the user identifier.
      Returns:
      The current web socket user identifier, if any.
      Throws:
      ClassCastException - When S is of wrong type.
    • getPreviousUser

      public <S extends Serializable> S getPreviousUser()
      Returns the previous <o:socket user>, if any.
      Type Parameters:
      S - The generic type of the user identifier.
      Returns:
      The previous web socket user identifier, if any.
      Throws:
      ClassCastException - When S is of wrong type.
      Since:
      3.2
    • getCloseCode

      public CloseReason.CloseCode getCloseCode()
      Returns the close code. If this returns null, then it was SocketEvent.Opened. If this returns non-null, then it was SocketEvent.Closed.
      Returns:
      The close code.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object