Groups

Technical reference of Grupos.

This API is used in WebSocket Groups.


Symbols

SymbolClassDescription
MaxGroupNameBytesconstMaxGroupNameBytes defines a constant value of the API.
ValidateGroupNamefuncValida ValidateGroupName.
GroupRegistrytypeGroupRegistry defines a public type of API.
GroupsvarReturns the socket groups.
GroupRegistry.ListfuncReturns List.
GroupRegistry.HasfuncIt indicates whether the collection contains the key.
GroupRegistry.CountfuncReturns the number of keys or elements available.
GroupRegistry.MembersfuncGive back the member sockets.
GroupRegistry.CountMembersfuncReturns the amount of CountMembers.
GroupRegistry.EmitTofuncEmite EmitTo.

MaxGroupNameBytes

Declaration:

gox
const MaxGroupNameBytes = 128

MaxGroupNameBytes defines a constant value of the API.


ValidateGroupName

Declaration:

gox
func ValidateGroupName(name string) error

Valida ValidateGroupName.

Parameters

ParameterTypeDescription
namestringName assigned.

Returns

ReturnTypeDescription
errerrornil if the operation ends correctly; otherwise, the error produced.

Behavior

The operation returns an error when it cannot complete the above contract.

Errors

ValidateGroupName returns an error when the arguments, the status of the receiver or the underlying operation make it impossible to complete the call.

Usage syntax

gox
err := gox.ValidateGroupName("name")

GroupRegistry

Declaration:

gox
type GroupRegistry struct{ state *groupRegistryState }

GroupRegistry defines a public type of API.


Groups

Declaration:

gox
var Groups = GroupRegistry{state: &groupRegistryState{}}

Returns the socket groups.


GroupRegistry.List

Declaration:

gox
func (groups *GroupRegistry) List() []string

Returns List.

Returns

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

Usage syntax

gox
value := groupRegistry.List()

GroupRegistry.Has

Declaration:

gox
func (groups *GroupRegistry) Has(group string) bool

It indicates whether the collection contains the key.

Parameters

ParameterTypeDescription
groupstringGroup name.

Returns

ReturnTypeDescription
valueboolIt indicates the result of the check.

Usage syntax

gox
value := groupRegistry.Has("group")

GroupRegistry.Count

Declaration:

gox
func (groups *GroupRegistry) Count() int

Returns the number of keys or elements available.

Returns

ReturnTypeDescription
valueintType value int produced by the operation.

Usage syntax

gox
value := groupRegistry.Count()

GroupRegistry.Members

Declaration:

gox
func (groups *GroupRegistry) Members(group string) SocketCollection

Give back the member sockets.

Parameters

ParameterTypeDescription
groupstringGroup name.

Returns

ReturnTypeDescription
valueSocketCollectionType value SocketCollection produced by the operation.

Usage syntax

gox
value := groupRegistry.Members("group")

GroupRegistry.CountMembers

Declaration:

gox
func (groups *GroupRegistry) CountMembers(group string) int

Returns the amount of CountMembers.

Parameters

ParameterTypeDescription
groupstringGroup name.

Returns

ReturnTypeDescription
valueintType value int produced by the operation.

Usage syntax

gox
value := groupRegistry.CountMembers("group")

GroupRegistry.EmitTo

Declaration:

gox
func (groups *GroupRegistry) EmitTo(group string, event string, values ...any)

Emite EmitTo.

Parameters

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

Usage syntax

gox
groupRegistry.EmitTo("group", "event", value)

See also

Next step

Continue with Channel API.

Channel