client

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Connected bool

	IncomingMsgChan chan *message.Message
	// contains filtered or unexported fields
}

Client struct

func New

func New(logLevel logrus.Level, requestTimeout ...time.Duration) *Client

New returns a new client

func (*Client) ConnectTo

func (c *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 (c *Client) ConnectToWS(addr string, path string, tlsConfig ...*tls.Config) error

ConnectToWS connects using webshocket protocol

func (*Client) ConnectedStatus

func (c *Client) ConnectedStatus() bool

ConnectedStatus return the connection status

func (*Client) Disconnect

func (c *Client) Disconnect()

Disconnect disconnects the client

func (*Client) MsgChannel

func (c *Client) MsgChannel() chan *message.Message

MsgChannel return the incoming message channel

func (*Client) SendNotify

func (c *Client) SendNotify(route string, data []byte) error

SendNotify sends a notify to the server

func (*Client) SendRequest

func (c *Client) SendRequest(route string, data []byte) (uint, error)

SendRequest sends a request to the server

func (*Client) SetClientHandshakeData

func (c *Client) SetClientHandshakeData(data *session.HandshakeData)

SetClientHandshakeData sets the data to send inside handshake

type Command

type Command struct {
	// contains filtered or unexported fields
}

Command struct. Save the input and output type and proto descriptor for each one.

type HandshakeData

type HandshakeData struct {
	Code int          `json:"code"`
	Sys  HandshakeSys `json:"sys"`
}

HandshakeData struct

type HandshakeSys

type HandshakeSys struct {
	Dict       map[string]uint16 `json:"dict"`
	Heartbeat  int               `json:"heartbeat"`
	Serializer string            `json:"serializer"`
}

HandshakeSys struct

type PitayaClient

type PitayaClient interface {
	ConnectTo(addr string, tlsConfig ...*tls.Config) error
	ConnectToWS(addr string, path string, tlsConfig ...*tls.Config) error
	ConnectedStatus() bool
	Disconnect()
	MsgChannel() chan *message.Message
	SendNotify(route string, data []byte) error
	SendRequest(route string, data []byte) (uint, error)
	SetClientHandshakeData(data *session.HandshakeData)
}

PitayaClient iface

type ProtoBufferInfo

type ProtoBufferInfo struct {
	Commands map[string]*Command
}

ProtoBufferInfo save all commands from a server.

type ProtoClient

type ProtoClient struct {
	Client

	IncomingMsgChan chan *message.Message
	// contains filtered or unexported fields
}

ProtoClient struct

func NewProto

func NewProto(docsRoute string, docslogLevel logrus.Level, requestTimeout ...time.Duration) *ProtoClient

NewProto returns a new protoclient with the auto documentation route.

func NewWithDescriptor

func NewWithDescriptor(descriptorsRoute string, docsRoute string, docslogLevel logrus.Level, requestTimeout ...time.Duration) *ProtoClient

NewWithDescriptor returns a new protoclient with the descriptors route and auto documentation route.

func (*ProtoClient) AddPushResponse

func (pc *ProtoClient) AddPushResponse(route string, protoName string)

AddPushResponse add a push response. Must be ladded before LoadInfo.

func (*ProtoClient) ConnectTo

func (pc *ProtoClient) ConnectTo(addr string, tlsConfig ...*tls.Config) error

ConnectTo connects to the server at addr, for now the only supported protocol is tcp this methods blocks as it also handles the messages from the server

func (*ProtoClient) Disconnect

func (pc *ProtoClient) Disconnect()

Disconnect the client

func (*ProtoClient) ExportInformation

func (pc *ProtoClient) ExportInformation() *ProtoBufferInfo

ExportInformation export supported server commands information

func (*ProtoClient) LoadInfo

func (pc *ProtoClient) LoadInfo(info *ProtoBufferInfo) error

LoadInfo load commands information form ProtoBufferInfo

func (*ProtoClient) LoadServerInfo

func (pc *ProtoClient) LoadServerInfo(addr string) error

LoadServerInfo load commands information from the server. Addr is the server address.

func (*ProtoClient) MsgChannel

func (pc *ProtoClient) MsgChannel() chan *message.Message

MsgChannel return the incoming message channel

func (*ProtoClient) SendNotify

func (pc *ProtoClient) SendNotify(route string, data []byte) error

SendNotify sends a notify to the server

func (*ProtoClient) SendRequest

func (pc *ProtoClient) SendRequest(route string, data []byte) (uint, error)

SendRequest sends a request to the server

Jump to

Keyboard shortcuts

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