Documentation ¶
Index ¶
- func DecodeOptions(opts *PacketOptions) *socket.BroadcastOptions
- func RandomId() (string, error)
- func SliceMap[I any, O any](i []I, converter func(I) O) (o []O)
- func Tap[T any](value T, callback func(T)) T
- func Uid2(length int) (string, error)
- type Adapter
- type AdapterBuilder
- type BroadcastAck
- type BroadcastClientCount
- type BroadcastMessage
- type ClusterAckRequest
- type ClusterAdapter
- type ClusterAdapterBuilder
- type ClusterAdapterOptions
- func (s *ClusterAdapterOptions) Assign(data ClusterAdapterOptionsInterface) (ClusterAdapterOptionsInterface, error)
- func (s *ClusterAdapterOptions) GetRawHeartbeatInterval() *time.Duration
- func (s *ClusterAdapterOptions) GetRawHeartbeatTimeout() *int64
- func (s *ClusterAdapterOptions) HeartbeatInterval() time.Duration
- func (s *ClusterAdapterOptions) HeartbeatTimeout() int64
- func (s *ClusterAdapterOptions) SetHeartbeatInterval(heartbeatInterval time.Duration)
- func (s *ClusterAdapterOptions) SetHeartbeatTimeout(heartbeatTimeout int64)
- type ClusterAdapterOptionsInterface
- type ClusterAdapterWithHeartbeat
- type ClusterAdapterWithHeartbeatBuilder
- type ClusterMessage
- type ClusterRequest
- type ClusterResponse
- type CustomClusterRequest
- type DisconnectSocketsMessage
- type FetchSocketsMessage
- type FetchSocketsResponse
- type MessageType
- type Offset
- type PacketOptions
- type RemoteSocket
- type ServerId
- type ServerSideEmitMessage
- type ServerSideEmitResponse
- type SessionAwareAdapter
- type SessionAwareAdapterBuilder
- type SocketResponse
- type SocketsJoinLeaveMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeOptions ¶
func DecodeOptions(opts *PacketOptions) *socket.BroadcastOptions
Decode PacketOptions back into BroadcastOptions
Types ¶
type AdapterBuilder ¶
type AdapterBuilder struct { }
type BroadcastAck ¶
type BroadcastClientCount ¶
type BroadcastMessage ¶
type BroadcastMessage struct { Opts *PacketOptions `json:"opts,omitempty" msgpack:"opts,omitempty"` Packet *parser.Packet `json:"packet,omitempty" msgpack:"packet,omitempty"` RequestId *string `json:"requestId,omitempty" msgpack:"requestId,omitempty"` }
Message for BROADCAST
type ClusterAckRequest ¶
type ClusterAdapter ¶
type ClusterAdapter interface { Adapter Uid() ServerId OnMessage(*ClusterMessage, Offset) OnResponse(*ClusterResponse) Publish(*ClusterMessage) PublishAndReturnOffset(*ClusterMessage) (Offset, error) DoPublish(*ClusterMessage) (Offset, error) PublishResponse(ServerId, *ClusterResponse) DoPublishResponse(ServerId, *ClusterResponse) error }
A cluster-ready adapter. Any extending interface must:
- implement [ClusterAdapter.DoPublish] and [ClusterAdapter.DoPublishResponse]
- call [ClusterAdapter.OnMessage] and [ClusterAdapter.OnResponse]
func MakeClusterAdapter ¶
func MakeClusterAdapter() ClusterAdapter
func NewClusterAdapter ¶
func NewClusterAdapter(nsp socket.Namespace) ClusterAdapter
type ClusterAdapterBuilder ¶
type ClusterAdapterBuilder struct { }
A cluster-ready adapter. Any extending interface must:
- implement [ClusterAdapter.DoPublish] and [ClusterAdapter.DoPublishResponse]
- call [ClusterAdapter.OnMessage] and [ClusterAdapter.OnResponse]
type ClusterAdapterOptions ¶
type ClusterAdapterOptions struct {
// contains filtered or unexported fields
}
func DefaultClusterAdapterOptions ¶
func DefaultClusterAdapterOptions() *ClusterAdapterOptions
func (*ClusterAdapterOptions) Assign ¶
func (s *ClusterAdapterOptions) Assign(data ClusterAdapterOptionsInterface) (ClusterAdapterOptionsInterface, error)
func (*ClusterAdapterOptions) GetRawHeartbeatInterval ¶
func (s *ClusterAdapterOptions) GetRawHeartbeatInterval() *time.Duration
func (*ClusterAdapterOptions) GetRawHeartbeatTimeout ¶
func (s *ClusterAdapterOptions) GetRawHeartbeatTimeout() *int64
func (*ClusterAdapterOptions) HeartbeatInterval ¶
func (s *ClusterAdapterOptions) HeartbeatInterval() time.Duration
func (*ClusterAdapterOptions) HeartbeatTimeout ¶
func (s *ClusterAdapterOptions) HeartbeatTimeout() int64
func (*ClusterAdapterOptions) SetHeartbeatInterval ¶
func (s *ClusterAdapterOptions) SetHeartbeatInterval(heartbeatInterval time.Duration)
func (*ClusterAdapterOptions) SetHeartbeatTimeout ¶
func (s *ClusterAdapterOptions) SetHeartbeatTimeout(heartbeatTimeout int64)
type ClusterAdapterWithHeartbeat ¶
type ClusterAdapterWithHeartbeat interface { ClusterAdapter SetOpts(any) }
func MakeClusterAdapterWithHeartbeat ¶
func MakeClusterAdapterWithHeartbeat() ClusterAdapterWithHeartbeat
func NewClusterAdapterWithHeartbeat ¶
func NewClusterAdapterWithHeartbeat(nsp socket.Namespace, opts any) ClusterAdapterWithHeartbeat
type ClusterAdapterWithHeartbeatBuilder ¶
type ClusterAdapterWithHeartbeatBuilder struct {
Opts ClusterAdapterOptionsInterface
}
type ClusterMessage ¶
type ClusterMessage struct { Uid ServerId `json:"uid,omitempty" msgpack:"uid,omitempty"` Nsp string `json:"nsp,omitempty" msgpack:"nsp,omitempty"` Type MessageType `json:"type,omitempty" msgpack:"type,omitempty"` Data any `json:"data,omitempty" msgpack:"data,omitempty"` // Data will hold the specific message data for different types }
Common fields for all messages
type ClusterRequest ¶
type ClusterRequest struct { Type MessageType Resolve func(*types.Slice[any]) Timeout *atomic.Pointer[utils.Timer] Expected int64 Current *atomic.Int64 Responses *types.Slice[any] }
ClusterRequest equivalent
type ClusterResponse ¶
type ClusterResponse = ClusterMessage
type CustomClusterRequest ¶
type DisconnectSocketsMessage ¶
type DisconnectSocketsMessage struct { Opts *PacketOptions `json:"opts,omitempty" msgpack:"opts,omitempty"` Close bool `json:"close,omitempty" msgpack:"close,omitempty"` }
Message for DISCONNECT_SOCKETS
type FetchSocketsMessage ¶
type FetchSocketsMessage struct { Opts *PacketOptions `json:"opts,omitempty" msgpack:"opts,omitempty"` RequestId string `json:"requestId,omitempty" msgpack:"requestId,omitempty"` }
Message for FETCH_SOCKETS
type FetchSocketsResponse ¶
type FetchSocketsResponse struct { RequestId string `json:"requestId,omitempty" msgpack:"requestId,omitempty"` Sockets []*SocketResponse `json:"sockets,omitempty" msgpack:"sockets,omitempty"` }
type MessageType ¶
type MessageType int
const ( INITIAL_HEARTBEAT MessageType = iota + 1 HEARTBEAT BROADCAST SOCKETS_JOIN SOCKETS_LEAVE DISCONNECT_SOCKETS FETCH_SOCKETS FETCH_SOCKETS_RESPONSE SERVER_SIDE_EMIT SERVER_SIDE_EMIT_RESPONSE BROADCAST_CLIENT_COUNT BROADCAST_ACK ADAPTER_CLOSE )
type Offset ¶
type Offset string
The unique ID of a message (for the connection state recovery feature)
type PacketOptions ¶
type PacketOptions struct { Rooms []socket.Room `json:"rooms,omitempty" msgpack:"rooms,omitempty"` Except []socket.Room `json:"except,omitempty" msgpack:"except,omitempty"` Flags *socket.BroadcastFlags `json:"flags,omitempty" msgpack:"flags,omitempty"` }
PacketOptions represents the options for broadcasting messages.
func EncodeOptions ¶
func EncodeOptions(opts *socket.BroadcastOptions) *PacketOptions
Encode BroadcastOptions into PacketOptions
type RemoteSocket ¶
type RemoteSocket struct {
// contains filtered or unexported fields
}
Expose of subset of the attributes and methods of the Socket struct
func MakeRemoteSocket ¶
func MakeRemoteSocket() *RemoteSocket
func NewRemoteSocket ¶
func NewRemoteSocket(details *SocketResponse) *RemoteSocket
func (*RemoteSocket) Construct ¶
func (r *RemoteSocket) Construct(details *SocketResponse)
func (*RemoteSocket) Data ¶
func (r *RemoteSocket) Data() any
func (*RemoteSocket) Handshake ¶
func (r *RemoteSocket) Handshake() *socket.Handshake
func (*RemoteSocket) Id ¶
func (r *RemoteSocket) Id() socket.SocketId
type ServerId ¶
type ServerId string
The unique ID of a server
const ( EMITTER_UID ServerId = "emitter" DEFAULT_TIMEOUT time.Duration = 5_000 * time.Millisecond )
type ServerSideEmitMessage ¶
type ServerSideEmitMessage struct { RequestId *string `json:"requestId,omitempty" msgpack:"requestId,omitempty"` Packet []any `json:"packet,omitempty" msgpack:"packet,omitempty"` }
Message for SERVER_SIDE_EMIT
type ServerSideEmitResponse ¶
type SessionAwareAdapter ¶
type SessionAwareAdapter = socket.SessionAwareAdapter
func MakeSessionAwareAdapter ¶
func MakeSessionAwareAdapter() SessionAwareAdapter
func NewSessionAwareAdapter ¶
func NewSessionAwareAdapter(nsp socket.Namespace) SessionAwareAdapter
type SessionAwareAdapterBuilder ¶
type SessionAwareAdapterBuilder struct { }
type SocketResponse ¶
type SocketResponse struct { Id socket.SocketId `json:"id,omitempty" msgpack:"id,omitempty"` Handshake *socket.Handshake `json:"handshake,omitempty" msgpack:"handshake,omitempty"` Rooms []socket.Room `json:"rooms,omitempty" msgpack:"rooms,omitempty"` Data any `json:"data,omitempty" msgpack:"data,omitempty"` }
type SocketsJoinLeaveMessage ¶
type SocketsJoinLeaveMessage struct { Opts *PacketOptions `json:"opts,omitempty" msgpack:"opts,omitempty"` Rooms []socket.Room `json:"rooms,omitempty" msgpack:"rooms,omitempty"` }
Message for SOCKETS_JOIN, SOCKETS_LEAVE