Groups
Technical reference of Grupos.
This API is used in WebSocket Groups.
Symbols
| Symbol | Class | Description |
|---|---|---|
| MaxGroupNameBytes | const | MaxGroupNameBytes defines a constant value of the API. |
| ValidateGroupName | func | Valida ValidateGroupName. |
| GroupRegistry | type | GroupRegistry defines a public type of API. |
| Groups | var | Returns the socket groups. |
| GroupRegistry.List | func | Returns List. |
| GroupRegistry.Has | func | It indicates whether the collection contains the key. |
| GroupRegistry.Count | func | Returns the number of keys or elements available. |
| GroupRegistry.Members | func | Give back the member sockets. |
| GroupRegistry.CountMembers | func | Returns the amount of CountMembers. |
| GroupRegistry.EmitTo | func | Emite EmitTo. |
MaxGroupNameBytes
Declaration:
const MaxGroupNameBytes = 128 MaxGroupNameBytes defines a constant value of the API.
ValidateGroupName
Declaration:
func ValidateGroupName(name string) error Valida ValidateGroupName.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Name assigned. |
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
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
err := gox.ValidateGroupName("name") GroupRegistry
Declaration:
type GroupRegistry struct{ state *groupRegistryState } GroupRegistry defines a public type of API.
Groups
Declaration:
var Groups = GroupRegistry{state: &groupRegistryState{}} Returns the socket groups.
GroupRegistry.List
Declaration:
func (groups *GroupRegistry) List() []string Returns List.
Returns
| Return | Type | Description |
|---|---|---|
value | []string | Result collection; can be nil when there are no values. |
Usage syntax
value := groupRegistry.List() GroupRegistry.Has
Declaration:
func (groups *GroupRegistry) Has(group string) bool It indicates whether the collection contains the key.
Parameters
| Parameter | Type | Description |
|---|---|---|
group | string | Group name. |
Returns
| Return | Type | Description |
|---|---|---|
value | bool | It indicates the result of the check. |
Usage syntax
value := groupRegistry.Has("group") GroupRegistry.Count
Declaration:
func (groups *GroupRegistry) Count() int Returns the number of keys or elements available.
Returns
| Return | Type | Description |
|---|---|---|
value | int | Type value int produced by the operation. |
Usage syntax
value := groupRegistry.Count() GroupRegistry.Members
Declaration:
func (groups *GroupRegistry) Members(group string) SocketCollection Give back the member sockets.
Parameters
| Parameter | Type | Description |
|---|---|---|
group | string | Group name. |
Returns
| Return | Type | Description |
|---|---|---|
value | SocketCollection | Type value SocketCollection produced by the operation. |
Usage syntax
value := groupRegistry.Members("group") GroupRegistry.CountMembers
Declaration:
func (groups *GroupRegistry) CountMembers(group string) int Returns the amount of CountMembers.
Parameters
| Parameter | Type | Description |
|---|---|---|
group | string | Group name. |
Returns
| Return | Type | Description |
|---|---|---|
value | int | Type value int produced by the operation. |
Usage syntax
value := groupRegistry.CountMembers("group") GroupRegistry.EmitTo
Declaration:
func (groups *GroupRegistry) EmitTo(group string, event string, values ...any) Emite EmitTo.
Parameters
| Parameter | Type | Description |
|---|---|---|
group | string | Group name. |
event | string | Name of the event. |
values | ...any | Values provided to the operation. |
Usage syntax
groupRegistry.EmitTo("group", "event", value)