Socket collections
Technical reference of Colecciones de sockets.
Symbols
| Symbol | Class | Description |
|---|---|---|
| SocketRegistry | type | SocketRegistry defines a public type of API. |
| Sockets | var | Sockets it exposes a shared value of the package. |
| SocketRegistry.All | func | Returns all available elements. |
| SocketRegistry.Count | func | Returns the number of keys or elements available. |
| SocketRegistry.Emit | func | It emits an event. |
| SocketRegistry.Disconnect | func | Close the connection to the indicated code. |
| SocketRegistry.GetByID | func | Get it. GetByID. |
| SocketRegistry.FindBySessionID | func | Look. FindBySessionID. |
| SocketCollection | type | SocketCollection defines a public type of API. |
| SocketCollection.All | func | Returns all available elements. |
| SocketCollection.Count | func | Returns the number of keys or elements available. |
| SocketCollection.Emit | func | It emits an event. |
| SocketCollection.Disconnect | func | Close the connection to the indicated code. |
SocketRegistry
Declaration:
type SocketRegistry struct {
// contiene campos internos
} SocketRegistry defines a public type of API.
Sockets
Declaration:
var Sockets = newSocketRegistry() Sockets it exposes a shared value of the package.
SocketRegistry.All
Declaration:
func (s *SocketRegistry) All() []*Socket Returns all available elements.
Returns
| Return | Type | Description |
|---|---|---|
value | []*Socket | Result collection; can be nil when there are no values. |
Usage syntax
value := socketRegistry.All() SocketRegistry.Count
Declaration:
func (s *SocketRegistry) 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 := socketRegistry.Count() SocketRegistry.Emit
Declaration:
func (s *SocketRegistry) Emit(event string, values ...any) It emits an event.
Parameters
| Parameter | Type | Description |
|---|---|---|
event | string | Name of the event. |
values | ...any | Values provided to the operation. |
Usage syntax
socketRegistry.Emit("event", value) SocketRegistry.Disconnect
Declaration:
func (s *SocketRegistry) Disconnect(code WSCloseCode) Close the connection to the indicated code.
Parameters
| Parameter | Type | Description |
|---|---|---|
code | WSCloseCode | Code of closure. |
Behavior
Use the default ratio associated with the closing code.
Usage syntax
socketRegistry.Disconnect(gox.WSCloseNormal) SocketRegistry.GetByID
Declaration:
func (s *SocketRegistry) GetByID(id string) (*Socket, bool) Get it. GetByID.
Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Type value string required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | *Socket | Type value *Socket produced by the operation. |
ok | bool | It indicates the result of the check. |
Usage syntax
value, ok := socketRegistry.GetByID("id") SocketRegistry.FindBySessionID
Declaration:
func (s *SocketRegistry) FindBySessionID(sessionID string) SocketCollection Look. FindBySessionID.
Parameters
| Parameter | Type | Description |
|---|---|---|
sessionID | string | Type value string required by the operation. |
Returns
| Return | Type | Description |
|---|---|---|
value | SocketCollection | Type value SocketCollection produced by the operation. |
Usage syntax
value := socketRegistry.FindBySessionID(value) SocketCollection
Declaration:
type SocketCollection struct {
// contiene campos internos
} SocketCollection defines a public type of API.
SocketCollection.All
Declaration:
func (collection SocketCollection) All() []*Socket Returns all available elements.
Returns
| Return | Type | Description |
|---|---|---|
value | []*Socket | Result collection; can be nil when there are no values. |
Usage syntax
value := gox.Sockets.All().All() SocketCollection.Count
Declaration:
func (collection SocketCollection) 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 := gox.Sockets.All().Count() SocketCollection.Emit
Declaration:
func (collection SocketCollection) Emit(event string, values ...any) It emits an event.
Parameters
| Parameter | Type | Description |
|---|---|---|
event | string | Name of the event. |
values | ...any | Values provided to the operation. |
Usage syntax
gox.Sockets.All().Emit("event", value) SocketCollection.Disconnect
Declaration:
func (collection SocketCollection) Disconnect(code WSCloseCode) Close the connection to the indicated code.
Parameters
| Parameter | Type | Description |
|---|---|---|
code | WSCloseCode | Code of closure. |
Behavior
Use the default ratio associated with the closing code.
Usage syntax
gox.Sockets.All().Disconnect(gox.WSCloseNormal)