Documentation
¶
Index ¶
- Constants
- func Marshal(val any) []byte
- func NewJSONCodec() jsonCodec
- type AdapterReceiver
- type AdapterSender
- type DataCodec
- type Engine
- func (e *Engine) AddClient(conn net.Conn) *Socket
- func (e *Engine) Broadcast(_ context.Context, event string, data any) error
- func (e *Engine) EmitForUser(_ context.Context, userID, event string, data any) error
- func (e *Engine) GetCodec() DataCodec
- func (e *Engine) NewSocket(cl *engineio.Socket) *Socket
- func (e *Engine) On(event string, handler SocketEventHandler)
- func (e *Engine) ReceivedNew(ctx context.Context, userID, event string, data json.RawMessage)
- func (e *Engine) RemoveSocket(socket *Socket) *Socket
- func (e *Engine) RemoveSocketUnsafe(socket *Socket) *Socket
- type ErrorData
- type Packet
- type PacketType
- type PushData
- type RedisAdapter
- type Socket
- type SocketEventHandler
Constants ¶
View Source
const ( // CatchAllEvent is special event, that will be selected // if no handlers are registered for received event type. CatchAllEvent = "*" DefaultNamespace = "/" )
View Source
const Version = 5
Variables ¶
This section is empty.
Functions ¶
func NewJSONCodec ¶
func NewJSONCodec() jsonCodec
Types ¶
type AdapterReceiver ¶
type AdapterReceiver interface { // ReceivedNew will be called when new event is received. // // userID may be empty if this is a broadcast event. // // Currently all notifications will be processed here, // without difference between user or broadcast notifications or // if user in received event is present on this server. ReceivedNew(ctx context.Context, userID, event string, data json.RawMessage) }
type AdapterSender ¶
type AdapterSender interface { Broadcast(ctx context.Context, event string, data any) error EmitForUser(ctx context.Context, userID, event string, data any) error }
func NewRedisAdapter ¶
func NewRedisAdapter(r redis.UniversalClient, recvr AdapterReceiver, codec DataCodec, eventsChannel string) AdapterSender
type Engine ¶
type Engine struct { OnConnect SocketEventHandler OnDisconnect SocketEventHandler // contains filtered or unexported fields }
func (*Engine) AddClient ¶
AddClient creates and stores Socket.
TODO: Better init handshake. Wait for client to send connect & auth before moving forward.
func (*Engine) EmitForUser ¶
EmitForUser emits provided event to all sockets for this user connected to this engine.
It is only useful if `UserID` field is set on socket.
func (*Engine) On ¶
func (e *Engine) On(event string, handler SocketEventHandler)
On adds event listener to specified event.
To add catch-all listener use `On(socketio.CatchAllEvent, ...)`.
func (*Engine) ReceivedNew ¶
ReceivedNew is used for adapter only.
This method should not be used anywhere in the code apart from adapter implementation.
func (*Engine) RemoveSocket ¶
func (*Engine) RemoveSocketUnsafe ¶
type Packet ¶
type Packet struct { Type PacketType Namespace string AckID *int Data json.RawMessage }
func UnmarshalPacket ¶
func (Packet) MarshalBinary ¶
func (*Packet) UnmarshalBinary ¶
type PacketType ¶
type PacketType string
const ( PacketTypeConnect PacketType = "0" PacketTypeDisconnect PacketType = "1" PacketTypeEvent PacketType = "2" PacketTypeAck PacketType = "3" PacketTypeConnectError PacketType = "4" PacketTypeBinaryEvent PacketType = "5" PacketTypeBinaryAck PacketType = "6" )
type RedisAdapter ¶
type RedisAdapter struct {
// contains filtered or unexported fields
}
func (RedisAdapter) EmitForUser ¶
Click to show internal directories.
Click to hide internal directories.