Socket collections

Technical reference of Colecciones de sockets.


Symbols

SymbolClassDescription
SocketRegistrytypeSocketRegistry defines a public type of API.
SocketsvarSockets it exposes a shared value of the package.
SocketRegistry.AllfuncReturns all available elements.
SocketRegistry.CountfuncReturns the number of keys or elements available.
SocketRegistry.EmitfuncIt emits an event.
SocketRegistry.DisconnectfuncClose the connection to the indicated code.
SocketRegistry.GetByIDfuncGet it. GetByID.
SocketRegistry.FindBySessionIDfuncLook. FindBySessionID.
SocketCollectiontypeSocketCollection defines a public type of API.
SocketCollection.AllfuncReturns all available elements.
SocketCollection.CountfuncReturns the number of keys or elements available.
SocketCollection.EmitfuncIt emits an event.
SocketCollection.DisconnectfuncClose the connection to the indicated code.

SocketRegistry

Declaration:

gox
type SocketRegistry struct {
	// contiene campos internos
}

SocketRegistry defines a public type of API.


Sockets

Declaration:

gox
var Sockets = newSocketRegistry()

Sockets it exposes a shared value of the package.


SocketRegistry.All

Declaration:

gox
func (s *SocketRegistry) All() []*Socket

Returns all available elements.

Returns

ReturnTypeDescription
value[]*SocketResult collection; can be nil when there are no values.

Usage syntax

gox
value := socketRegistry.All()

SocketRegistry.Count

Declaration:

gox
func (s *SocketRegistry) Count() int

Returns the number of keys or elements available.

Returns

ReturnTypeDescription
valueintType value int produced by the operation.

Usage syntax

gox
value := socketRegistry.Count()

SocketRegistry.Emit

Declaration:

gox
func (s *SocketRegistry) Emit(event string, values ...any)

It emits an event.

Parameters

ParameterTypeDescription
eventstringName of the event.
values...anyValues provided to the operation.

Usage syntax

gox
socketRegistry.Emit("event", value)

SocketRegistry.Disconnect

Declaration:

gox
func (s *SocketRegistry) Disconnect(code WSCloseCode)

Close the connection to the indicated code.

Parameters

ParameterTypeDescription
codeWSCloseCodeCode of closure.

Behavior

Use the default ratio associated with the closing code.

Usage syntax

gox
socketRegistry.Disconnect(gox.WSCloseNormal)

SocketRegistry.GetByID

Declaration:

gox
func (s *SocketRegistry) GetByID(id string) (*Socket, bool)

Get it. GetByID.

Parameters

ParameterTypeDescription
idstringType value string required by the operation.

Returns

ReturnTypeDescription
value*SocketType value *Socket produced by the operation.
okboolIt indicates the result of the check.

Usage syntax

gox
value, ok := socketRegistry.GetByID("id")

SocketRegistry.FindBySessionID

Declaration:

gox
func (s *SocketRegistry) FindBySessionID(sessionID string) SocketCollection

Look. FindBySessionID.

Parameters

ParameterTypeDescription
sessionIDstringType value string required by the operation.

Returns

ReturnTypeDescription
valueSocketCollectionType value SocketCollection produced by the operation.

Usage syntax

gox
value := socketRegistry.FindBySessionID(value)

SocketCollection

Declaration:

gox
type SocketCollection struct {
	// contiene campos internos
}

SocketCollection defines a public type of API.


SocketCollection.All

Declaration:

gox
func (collection SocketCollection) All() []*Socket

Returns all available elements.

Returns

ReturnTypeDescription
value[]*SocketResult collection; can be nil when there are no values.

Usage syntax

gox
value := gox.Sockets.All().All()

SocketCollection.Count

Declaration:

gox
func (collection SocketCollection) Count() int

Returns the number of keys or elements available.

Returns

ReturnTypeDescription
valueintType value int produced by the operation.

Usage syntax

gox
value := gox.Sockets.All().Count()

SocketCollection.Emit

Declaration:

gox
func (collection SocketCollection) Emit(event string, values ...any)

It emits an event.

Parameters

ParameterTypeDescription
eventstringName of the event.
values...anyValues provided to the operation.

Usage syntax

gox
gox.Sockets.All().Emit("event", value)

SocketCollection.Disconnect

Declaration:

gox
func (collection SocketCollection) Disconnect(code WSCloseCode)

Close the connection to the indicated code.

Parameters

ParameterTypeDescription
codeWSCloseCodeCode of closure.

Behavior

Use the default ratio associated with the closing code.

Usage syntax

gox
gox.Sockets.All().Disconnect(gox.WSCloseNormal)

Next step

Continue with Group registration.

Groups