Documentation
¶
Index ¶
- type SocketClient
- func (sc *SocketClient) Await() ([]interface{}, error)
- func (sc *SocketClient) BroadcastToGroup(groupID string, data interface{}) error
- func (sc *SocketClient) Close()
- func (sc *SocketClient) Connect() error
- func (sc *SocketClient) GetGroups() []string
- func (sc *SocketClient) JoinGroup(groupID string) error
- func (sc *SocketClient) LeaveGroup(groupID string) error
- func (sc *SocketClient) Send(data []interface{}) error
- type SocketGroup
- type SocketMessage
- type SocketServer
- func (ss *SocketServer) Bind() string
- func (ss *SocketServer) Broadcast(groupId string, data []interface{})
- func (ss *SocketServer) Close(ProcessID string)
- func (ss *SocketServer) Listen(clientId string) ([]interface{}, error)
- func (ss *SocketServer) Response(ProcessID string, data []interface{}) error
- func (ss *SocketServer) Start() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SocketClient ¶
type SocketClient struct { ServerAddr string UseTLS bool // contains filtered or unexported fields }
SocketClient represents a client connection to the server.
func (*SocketClient) Await ¶
func (sc *SocketClient) Await() ([]interface{}, error)
Await waits for data from the server.
func (*SocketClient) BroadcastToGroup ¶
func (sc *SocketClient) BroadcastToGroup(groupID string, data interface{}) error
BroadcastToGroup sends a message to all clients in the specified group.
func (*SocketClient) Connect ¶
func (sc *SocketClient) Connect() error
Connect establishes a connection to the server.
func (*SocketClient) GetGroups ¶
func (sc *SocketClient) GetGroups() []string
GetGroups returns the list of groups the client has joined.
func (*SocketClient) JoinGroup ¶
func (sc *SocketClient) JoinGroup(groupID string) error
JoinGroup subscribes the client to a group.
func (*SocketClient) LeaveGroup ¶
func (sc *SocketClient) LeaveGroup(groupID string) error
LeaveGroup unsubscribes the client from a group.
func (*SocketClient) Send ¶
func (sc *SocketClient) Send(data []interface{}) error
Send sends data to the server.
type SocketGroup ¶
type SocketGroup struct { Id string // Id to map specific group. Clients map[string]*socketProcess // Stores all the clients listening to the group. Sync sync.RWMutex // Sync read and write to support multithreading. }
SocketGroup represents a communication channel with its clients and synchronization mechanism.
type SocketMessage ¶
type SocketMessage struct { Flag enums.SocketFlag `json:"flag"` // Flag indicates the type of message. Payload interface{} `json:"payload"` // Payload contains the actual data. Group string `json:"group"` // Channel sends payload across clients subscribed to it. }
SocketMessage represents the structure of the JSON message used for communication.
type SocketServer ¶
type SocketServer struct { Name string Port uint16 EnableTLS bool CertPath string KeyPath string // contains filtered or unexported fields }
func (*SocketServer) Bind ¶
func (ss *SocketServer) Bind() string
Bind listen to new connections and if succeed return the client id.
func (*SocketServer) Broadcast ¶
func (ss *SocketServer) Broadcast(groupId string, data []interface{})
func (*SocketServer) Close ¶
func (ss *SocketServer) Close(ProcessID string)
func (*SocketServer) Listen ¶
func (ss *SocketServer) Listen(clientId string) ([]interface{}, error)
Listen returns data from a specific client.
func (*SocketServer) Response ¶
func (ss *SocketServer) Response(ProcessID string, data []interface{}) error