Documentation
¶
Index ¶
- func BasicAuth(user, password string) string
- func OAuth2(token string) string
- type SocketClient
- func (w *SocketClient) Close() (err error)
- func (w *SocketClient) Connect(url string, options ...api.SocketOption) (err error)
- func (w *SocketClient) GetLocalAddr() (addr string)
- func (w *SocketClient) GetRemoteAddr() (addr string)
- func (w *SocketClient) IsClosed() bool
- func (w *SocketClient) Listen(url string) (err error)
- func (w *SocketClient) Recv(length int) (msg *api.SockMessage, err error)
- func (w *SocketClient) Send(data []byte, to ...string) (n int, err error)
- func (w *SocketClient) SendJson(v interface{}, to ...string) (n int, err error)
- type SocketHandler
- type SocketServer
- func (w *SocketServer) Close()
- func (w *SocketServer) CloseClient(client *SocketClient) (err error)
- func (w *SocketServer) GetClientAll() (clients []*SocketClient)
- func (w *SocketServer) GetClientCount() int
- func (w *SocketServer) Listen(handler SocketHandler) (err error)
- func (w *SocketServer) Send(client *SocketClient, data []byte, to ...string) (n int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SocketClient ¶
type SocketClient struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient() *SocketClient
func (*SocketClient) Close ¶
func (w *SocketClient) Close() (err error)
func (*SocketClient) Connect ¶
func (w *SocketClient) Connect(url string, options ...api.SocketOption) (err error)
IPv4 => tcp://127.0.0.1:6666 [tcp4://127.0.0.1:6666] WebSocket => ws://127.0.0.1:6668 [wss://127.0.0.1:6668]
func (*SocketClient) GetLocalAddr ¶
func (w *SocketClient) GetLocalAddr() (addr string)
func (*SocketClient) GetRemoteAddr ¶
func (w *SocketClient) GetRemoteAddr() (addr string)
func (*SocketClient) IsClosed ¶
func (w *SocketClient) IsClosed() bool
func (*SocketClient) Recv ¶
func (w *SocketClient) Recv(length int) (msg *api.SockMessage, err error)
type SocketHandler ¶
type SocketHandler interface {
OnAccept(c *SocketClient)
OnReceive(c *SocketClient, msg *api.SockMessage)
OnClose(c *SocketClient)
}
type SocketServer ¶
type SocketServer struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(url string, options ...api.SocketOption) *SocketServer
func (*SocketServer) Close ¶
func (w *SocketServer) Close()
func (*SocketServer) CloseClient ¶
func (w *SocketServer) CloseClient(client *SocketClient) (err error)
func (*SocketServer) GetClientAll ¶
func (w *SocketServer) GetClientAll() (clients []*SocketClient)
func (*SocketServer) GetClientCount ¶
func (w *SocketServer) GetClientCount() int
func (*SocketServer) Listen ¶
func (w *SocketServer) Listen(handler SocketHandler) (err error)
TCP => tcp://127.0.0.1:6666 UDP => udp://127.0.0.1:6667 WebSocket => ws://127.0.0.1:6668/ wss://127.0.0.1:6668/websocket?cert=cert.pem&key=key.pem
func (*SocketServer) Send ¶
func (w *SocketServer) Send(client *SocketClient, data []byte, to ...string) (n int, err error)
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
tcp/client
command
|
|
|
tcp/server
command
|
|
|
udp/client
command
|
|
|
udp/server
command
|
|
|
unix/client
command
|
|
|
unix/server
command
|
|
|
websock/client
command
|
|
|
websock/server
command
|
|
Click to show internal directories.
Click to hide internal directories.