WebSocket runtime
Technical reference of Runtime WebSocket.
This API is used in WebSocket.
Symbols
| Symbol | Class | Description |
|---|---|---|
| BindSocketIdentity | func | Install BindSocketIdentity. |
| BindSocketChannelTransport | func | Install BindSocketChannelTransport. |
| EmitSocketChannelEvent | func | Emite EmitSocketChannelEvent. |
| LeaveSocketChannel | func | Withdraw LeaveSocketChannel. |
| SocketGroupBindings | type | SocketGroupBindings defines a public type of API. |
| BindSocketGroups | func | Install BindSocketGroups. |
| BindSocketLocation | func | Install BindSocketLocation. |
| BindSocketSiblings | func | Install BindSocketSiblings. |
| BindSocketSiblingsEmit | func | Install BindSocketSiblingsEmit. |
| BindSocketSiblingsDisconnect | func | Install BindSocketSiblingsDisconnect. |
| BindSocketPacket | func | Install BindSocketPacket. |
| WriteSocketPacket | func | Write WriteSocketPacket. |
| BindSocketDisconnect | func | Install BindSocketDisconnect. |
| BindSocketEmit | func | Install BindSocketEmit. |
| BindSocketRequest | func | Install BindSocketRequest. |
| BindSocketClusterRequest | func | Install BindSocketClusterRequest. |
| RouteSocketClusterRequest | func | Send a socket request to another instance. |
| BindSocketClusterCancel | func | Install BindSocketClusterCancel. |
| CancelSocketClusterRequest | func | Cancel a distributed request pending. |
| SocketRegistryBindings | type | SocketRegistryBindings defines a public type of API. |
| BindSocketRegistry | func | Install BindSocketRegistry. |
| GroupRegistryBindings | type | GroupRegistryBindings defines a public type of API. |
| BindGroups | func | Install BindGroups. |
| NewChannelGenerationCandidate | func | Build NewChannelGenerationCandidate. |
| ValidateChannelGenerationCandidate | func | Valida ValidateChannelGenerationCandidate. |
| CommitChannelGeneration | func | It activates a validated channel generation. |
| AbortChannelGeneration | func | Discard a candidate generation. |
| ChannelRuntimeBindings | type | ChannelRuntimeBindings defines a public type of API. |
| BindChannelRuntime | func | Install BindChannelRuntime. |
| ChannelRegistryBindings | type | ChannelRegistryBindings defines a public type of API. |
| BindChannelRegistry | func | Install BindChannelRegistry. |
BindSocketIdentity
Declaration:
func BindSocketIdentity(s *Socket) func(string) Install BindSocketIdentity.
Parameters
| Parameter | Type | Description |
|---|---|---|
s | *Socket | Type value *Socket required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | func(string) | Type value func(string) produced by the operation. |
BindSocketChannelTransport
Declaration:
func BindSocketChannelTransport(socket *Socket, transport SocketChannelTransport) Install BindSocketChannelTransport.
Parameters
| Parameter | Type | Description |
|---|---|---|
socket | *Socket | Type value *Socket required by the operation. |
transport | SocketChannelTransport | Type value SocketChannelTransport required by the operation. |
EmitSocketChannelEvent
Declaration:
func EmitSocketChannelEvent(socket *Socket, channelID, event string, values []any) error Emite EmitSocketChannelEvent.
Parameters
| Parameter | Type | Description |
|---|---|---|
socket | *Socket | Type value *Socket required by the operation. |
| `` | channelID | Type value channelID required by the operation. |
event | string | Name of the event. |
values | []any | Values provided to the operation. |
Returns
| Return | Type | Description |
|---|---|---|
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
EmitSocketChannelEvent returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
err := gox.EmitSocketChannelEvent(nil, value, "event", value) LeaveSocketChannel
Declaration:
func LeaveSocketChannel(socket *Socket, channelID string, reason ChannelDisconnectReason) error Withdraw LeaveSocketChannel.
Parameters
| Parameter | Type | Description |
|---|---|---|
socket | *Socket | Type value *Socket required by the operation. |
channelID | string | Type value string required by the operation. |
reason | ChannelDisconnectReason | Type value ChannelDisconnectReason required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
LeaveSocketChannel returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
err := gox.LeaveSocketChannel(nil, value, value) SocketGroupBindings
Declaration:
type SocketGroupBindings struct {
Join func(group string) error
Leave func(group string) error
LeaveAll func() error
Groups func() []string
EmitTo func(group string, event string, values []any)
} SocketGroupBindings defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
Join | func(group string) error | Public data associated with Join. |
Leave | func(group string) error | Public data associated with Leave. |
LeaveAll | func() error | Public data associated with LeaveAll. |
Groups | func() []string | Public data associated with Groups. |
EmitTo | func(group string, event string, values []any) | Public data associated with EmitTo. |
BindSocketGroups
Declaration:
func BindSocketGroups(s *Socket, bindings SocketGroupBindings) Install BindSocketGroups.
Parameters
| Parameter | Type | Description |
|---|---|---|
s | *Socket | Type value *Socket required by the operation. |
bindings | SocketGroupBindings | Type value SocketGroupBindings required by the operation. |
BindSocketLocation
Declaration:
func BindSocketLocation(s *Socket, instanceID string, local bool) Install BindSocketLocation.
Parameters
| Parameter | Type | Description |
|---|---|---|
s | *Socket | Type value *Socket required by the operation. |
instanceID | string | Type value string required by the operation. |
local | bool | Type value bool required by the operation. |
BindSocketSiblings
Declaration:
func BindSocketSiblings(socket *Socket, resolve func() []*Socket) Install BindSocketSiblings.
Parameters
| Parameter | Type | Description |
|---|---|---|
socket | *Socket | Type value *Socket required by the operation. |
resolve func() | []*Socket | Type value []*Socket required by the operation. |
BindSocketSiblingsEmit
Declaration:
func BindSocketSiblingsEmit(socket *Socket, resolve func() []*Socket, emit func(event string, values []any)) Install BindSocketSiblingsEmit.
Parameters
| Parameter | Type | Description |
|---|---|---|
socket | *Socket | Type value *Socket required by the operation. |
resolve func() | []*Socket | Type value []*Socket required by the operation. |
emit func(event string | []any) | Type value []any) required by the operation. |
values | []any) | Values provided to the operation. |
BindSocketSiblingsDisconnect
Declaration:
func BindSocketSiblingsDisconnect(socket *Socket, disconnect func(code WSCloseCode)) Install BindSocketSiblingsDisconnect.
Parameters
| Parameter | Type | Description |
|---|---|---|
socket | *Socket | Type value *Socket required by the operation. |
disconnect func(code | WSCloseCode) | Type value WSCloseCode) required by the operation. |
BindSocketPacket
Declaration:
func BindSocketPacket(s *Socket, write func(event string, packet []byte) error) Install BindSocketPacket.
Parameters
| Parameter | Type | Description |
|---|---|---|
s | *Socket | Type value *Socket required by the operation. |
write func(event string | error | Type value error required by the operation. |
packet []byte) | error | Type value error required by the operation. |
WriteSocketPacket
Declaration:
func WriteSocketPacket(s *Socket, event string, packet []byte) error Write WriteSocketPacket.
Parameters
| Parameter | Type | Description |
|---|---|---|
s | *Socket | Type value *Socket required by the operation. |
event | string | Name of the event. |
packet | []byte | Type value []byte required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
WriteSocketPacket returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
BindSocketDisconnect
Declaration:
func BindSocketDisconnect(s *Socket, disconnect func(code WSCloseCode, reason string)) Install BindSocketDisconnect.
Parameters
| Parameter | Type | Description |
|---|---|---|
s | *Socket | Type value *Socket required by the operation. |
disconnect func(code WSCloseCode | string) | Type value string) required by the operation. |
reason | string) | Type value string) required by the operation. |
BindSocketEmit
Declaration:
func BindSocketEmit(s *Socket, emit func(event string, values []any) error) Install BindSocketEmit.
Parameters
| Parameter | Type | Description |
|---|---|---|
s | *Socket | Type value *Socket required by the operation. |
emit func(event string | error | Type value error required by the operation. |
values []any) | error | Type value error required by the operation. |
BindSocketRequest
Declaration:
func BindSocketRequest(s *Socket, request func(event string, values []any, out any) error) Install BindSocketRequest.
Parameters
| Parameter | Type | Description |
|---|---|---|
s | *Socket | Type value *Socket required by the operation. |
request func(event string | error | Type value error required by the operation. |
values []any | error | Type value error required by the operation. |
out any) | error | Type value error required by the operation. |
BindSocketClusterRequest
Declaration:
func BindSocketClusterRequest(s *Socket, request func(originInstanceID string, correlationID []byte, packet []byte) error) Install BindSocketClusterRequest.
Parameters
| Parameter | Type | Description |
|---|---|---|
s | *Socket | Type value *Socket required by the operation. |
request func(originInstanceID string | error | Type value error required by the operation. |
correlationID []byte | error | Type value error required by the operation. |
packet []byte) | error | Type value error required by the operation. |
RouteSocketClusterRequest
Declaration:
func RouteSocketClusterRequest(s *Socket, originInstanceID string, correlationID []byte, packet []byte) error Send a socket request to another instance.
Parameters
| Parameter | Type | Description |
|---|---|---|
s | *Socket | Type value *Socket required by the operation. |
originInstanceID | string | Type value string required by the operation. |
correlationID | []byte | Type value []byte required by the operation. |
packet | []byte | Type value []byte required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
RouteSocketClusterRequest returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
BindSocketClusterCancel
Declaration:
func BindSocketClusterCancel(s *Socket, cancel func(correlationID []byte) bool) Install BindSocketClusterCancel.
Parameters
| Parameter | Type | Description |
|---|---|---|
s | *Socket | Type value *Socket required by the operation. |
cancel func(correlationID []byte) | bool | Type value bool required by the operation. |
CancelSocketClusterRequest
Declaration:
func CancelSocketClusterRequest(s *Socket, correlationID []byte) bool Cancel a distributed request pending.
Parameters
| Parameter | Type | Description |
|---|---|---|
s | *Socket | Type value *Socket required by the operation. |
correlationID | []byte | Type value []byte required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | bool | It indicates the result of the check. |
SocketRegistryBindings
Declaration:
type SocketRegistryBindings struct {
All func() []*Socket
Count func() int
FindByID func(id string) (*Socket, bool)
FindBySessionID func(sessionID string) []*Socket
Emit func(event string, values []any)
EmitSession func(sessionID string, event string, values []any)
Disconnect func(code WSCloseCode)
DisconnectSession func(sessionID string, code WSCloseCode)
} SocketRegistryBindings defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
All | func() []*Socket | Public data associated with All. |
Count | func() int | Quantity recorded. |
FindByID | func(id string) (*Socket, bool) | Associated identifier. |
FindBySessionID | func(sessionID string) []*Socket | Associated identifier. |
Emit | func(event string, values []any) | Public data associated with Emit. |
EmitSession | func(sessionID string, event string, values []any) | Public data associated with EmitSession. |
Disconnect | func(code WSCloseCode) | Public data associated with Disconnect. |
DisconnectSession | func(sessionID string, code WSCloseCode) | Public data associated with DisconnectSession. |
BindSocketRegistry
Declaration:
func BindSocketRegistry(bindings SocketRegistryBindings) func() Install BindSocketRegistry.
Parameters
| Parameter | Type | Description |
|---|---|---|
bindings | SocketRegistryBindings | Type value SocketRegistryBindings required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | func() | Type value func() produced by the operation. |
GroupRegistryBindings
Declaration:
type GroupRegistryBindings struct {
List func() []string
Members func(group string) []*Socket
Count func() int
CountMembers func(group string) int
EmitTo func(group string, event string, values []any)
} GroupRegistryBindings defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
List | func() []string | Public data associated with List. |
Members | func(group string) []*Socket | Public data associated with Members. |
Count | func() int | Quantity recorded. |
CountMembers | func(group string) int | Quantity recorded. |
EmitTo | func(group string, event string, values []any) | Public data associated with EmitTo. |
BindGroups
Declaration:
func BindGroups(bindings GroupRegistryBindings) func() Install BindGroups.
Parameters
| Parameter | Type | Description |
|---|---|---|
bindings | GroupRegistryBindings | Type value GroupRegistryBindings required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | func() | Type value func() produced by the operation. |
NewChannelGenerationCandidate
Declaration:
func NewChannelGenerationCandidate(channel *Channel, version string) *Channel Build NewChannelGenerationCandidate.
Parameters
| Parameter | Type | Description |
|---|---|---|
channel | *Channel | Type value *Channel required by the operation. |
version | string | Type value string required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | *Channel | Type value *Channel produced by the operation. |
Usage syntax
value := gox.NewChannelGenerationCandidate(nil, value) ValidateChannelGenerationCandidate
Declaration:
func ValidateChannelGenerationCandidate(channel, candidate *Channel) error Valida ValidateChannelGenerationCandidate.
Parameters
| Parameter | Type | Description |
|---|---|---|
| `` | channel | Type value channel required by the operation. |
candidate | *Channel | Type value *Channel required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
ValidateChannelGenerationCandidate returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
err := gox.ValidateChannelGenerationCandidate(value, nil) CommitChannelGeneration
Declaration:
func CommitChannelGeneration(channel, candidate *Channel) error It activates a validated channel generation.
Parameters
| Parameter | Type | Description |
|---|---|---|
| `` | channel | Type value channel required by the operation. |
candidate | *Channel | Type value *Channel required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
err | error | nil if the operation ends correctly; otherwise, the error produced. |
Behavior
The operation returns an error when it cannot complete the above contract.
Errors
CommitChannelGeneration returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.
Usage syntax
err := gox.CommitChannelGeneration(value, nil) AbortChannelGeneration
Declaration:
func AbortChannelGeneration(candidate *Channel) Discard a candidate generation.
Parameters
| Parameter | Type | Description |
|---|---|---|
candidate | *Channel | Type value *Channel required by the operation. |
Usage syntax
gox.AbortChannelGeneration(nil) ChannelRuntimeBindings
Declaration:
type ChannelRuntimeBindings struct {
Members func() []*Socket
Emit func(event string, values []any) error
Leave func(socket *Socket) error
Close func() error
IsClosed func() bool
} ChannelRuntimeBindings defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
Members | func() []*Socket | Public data associated with Members. |
Emit | func(event string, values []any) error | Public data associated with Emit. |
Leave | func(socket *Socket) error | Public data associated with Leave. |
Close | func() error | Public data associated with Close. |
IsClosed | func() bool | Public data associated with IsClosed. |
BindChannelRuntime
Declaration:
func BindChannelRuntime(channel *Channel, bindings ChannelRuntimeBindings) Install BindChannelRuntime.
Parameters
| Parameter | Type | Description |
|---|---|---|
channel | *Channel | Type value *Channel required by the operation. |
bindings | ChannelRuntimeBindings | Type value ChannelRuntimeBindings required by the operation. |
ChannelRegistryBindings
Declaration:
type ChannelRegistryBindings struct {
Get func(id string) (*Channel, bool)
List func() []*Channel
Count func() int
} ChannelRegistryBindings defines a public type of API.
Fields
| Field | Type | Description |
|---|---|---|
Get | func(id string) (*Channel, bool) | Query callback. |
List | func() []*Channel | Public data associated with List. |
Count | func() int | Quantity recorded. |
BindChannelRegistry
Declaration:
func BindChannelRegistry(bindings ChannelRegistryBindings) func() Install BindChannelRegistry.
Parameters
| Parameter | Type | Description |
|---|---|---|
bindings | ChannelRegistryBindings | Type value ChannelRegistryBindings required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | func() | Type value func() produced by the operation. |