Interface SocketIOSocket

  • All Superinterfaces:
    SocketIOEmitter

    @ProviderType
    public interface SocketIOSocket
    extends SocketIOEmitter
    A Socket is the fundamental class for interacting with browser clients. A Socket belongs to a certain Namespace (by default /) and uses an underlying Client to communicate.
    • Method Detail

      • getId

        @Nonnull
        String getId()
        A unique identifier for the socket session, that comes from the underlying Client.
        Returns:
        the id
      • getRooms

        @Nonnull
        Set<String> getRooms()
        A list of strings identifying the rooms this socket is in.
        Returns:
        set of rooms
      • disconnect

        @Nonnull
        SocketIOSocket disconnect​(boolean close)
        Disconnects this socket.
        Parameters:
        close - true to also close the underlying connection
        Returns:
        this
      • join

        @Nonnull
        SocketIOSocket join​(@Nonnull
                            String name)
        Adds the socket to the room, and fires optionally a callback fn with err signature (if any). The socket is automatically a member of a room identified with its session id (see Socket#id). The mechanics of joining rooms are handled by the Adapter that has been configured (see Server#adapter above), defaulting to socket.io-adapter.
        Parameters:
        name - room name
        Returns:
        this
      • leave

        @Nonnull
        SocketIOSocket leave​(@Nonnull
                             String name)
        Removes the socket from room, and fires optionally a callback fn with err signature (if any). Rooms are left automatically upon disconnection. The mechanics of leaving rooms are handled by the Adapter that has been configured (see Server#adapter above), defaulting to socket.io-adapter.
        Parameters:
        name - room name
        Returns:
        this
      • broadcast

        @Nonnull
        SocketIOEmitter broadcast()
        Sets a modifier for a subsequent event emission that the event will sent to all sockets except to itself.
        Returns:
        an emitter
      • getUserPrincipal

        Principal getUserPrincipal()
        Returns:
        the Principal of the current authenticated user.