client

package
v0.0.0-...-3d0ed7e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateNone      = 0
	StateHandshake = 1
	StateConnected = 2
)

Variables

View Source
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) Close

func (my *Client) Close() error

func (*Client) ConnectTo

func (my *Client) ConnectTo(addr string, tlsConfig ...*tls.Config) error

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

func (my *Client) ConnectToWS(addr string, path string, tlsConfig ...*tls.Config) error

ConnectToWS connects using web socket protocol

func (*Client) GetReceivedChan

func (my *Client) GetReceivedChan() chan serde.Packet

GetReceivedChan return the incoming message channel

func (*Client) IsConnected

func (my *Client) IsConnected() bool

IsConnected return the connection status

func (*Client) SendByRoute

func (my *Client) SendByRoute(route string, v interface{}) error

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) Read

func (my *WsClientConn) Read(b []byte) (int, error)

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.

func (*WsClientConn) Write

func (my *WsClientConn) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL