Documentation ¶
Index ¶
- Constants
- Variables
- type Client
- func (my *Client) Close() error
- func (my *Client) ConnectTo(addr string, tlsConfig ...*tls.Config) error
- func (my *Client) ConnectToWS(addr string, path string, tlsConfig ...*tls.Config) error
- func (my *Client) GetReceivedChan() chan serde.Packet
- func (my *Client) IsConnected() bool
- func (my *Client) SendByRoute(route string, v interface{}) error
- type ClientOption
- type WsClientConn
- func (my *WsClientConn) Close() error
- func (my *WsClientConn) LocalAddr() net.Addr
- func (my *WsClientConn) Read(b []byte) (int, error)
- func (my *WsClientConn) RemoteAddr() net.Addr
- func (my *WsClientConn) SetDeadline(t time.Time) error
- func (my *WsClientConn) SetReadDeadline(t time.Time) error
- func (my *WsClientConn) SetWriteDeadline(t time.Time) error
- func (my *WsClientConn) Write(b []byte) (int, error)
Constants ¶
const ( StateNone = 0 StateHandshake = 1 StateConnected = 2 )
Variables ¶
var ErrKicked = errors.New("got kick packet from the server! disconnecting~")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(opts ...ClientOption) *Client
func (*Client) ConnectTo ¶
ConnectTo connects to the server at addr, for now the only supported protocol is tcp if tlsConfig is sent, it connects using TLS
func (*Client) ConnectToWS ¶
ConnectToWS connects using web socket protocol
func (*Client) GetReceivedChan ¶
GetReceivedChan return the incoming message channel
func (*Client) IsConnected ¶
IsConnected return the connection status
func (*Client) SendByRoute ¶
type ClientOption ¶
type ClientOption func(*pitayaClientOptions)
func WithReceiverBufferSize ¶
func WithReceiverBufferSize(size int) ClientOption
func WithRequestTimeout ¶
func WithRequestTimeout(timeout time.Duration) ClientOption
type WsClientConn ¶
type WsClientConn struct {
// contains filtered or unexported fields
}
func (*WsClientConn) Close ¶
func (my *WsClientConn) Close() error
func (*WsClientConn) LocalAddr ¶
func (my *WsClientConn) LocalAddr() net.Addr
LocalAddr returns the local address.
func (*WsClientConn) RemoteAddr ¶
func (my *WsClientConn) RemoteAddr() net.Addr
RemoteAddr returns the remote address.
func (*WsClientConn) SetDeadline ¶
func (my *WsClientConn) SetDeadline(t time.Time) error
SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
A deadline is an absolute time after which I/O operations fail with a timeout (see type Error) instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future.
An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.
A zero value for t means I/O operations will not time out.
func (*WsClientConn) SetReadDeadline ¶
func (my *WsClientConn) SetReadDeadline(t time.Time) error
SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out.
func (*WsClientConn) SetWriteDeadline ¶
func (my *WsClientConn) SetWriteDeadline(t time.Time) error
SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Even if write times out, it may return n > 0, indicating that some data was successfully written. A zero value for t means Write will not time out.