...

Package tcp

import "github.com/Diarkis/diarkis/client/go/tcp"
Overview
Index

Overview ▾

func LogLevel

func LogLevel(lvl int)

LogLevel sets log level

type Client

Client TCP Client

type Client struct {
    ID               string
    IDBytes          []byte
    ServerEndPoint   string
    ClientKey        string
    SID              []byte
    SIDString        string
    EncryptionKey    []byte
    EncryptionIV     []byte
    EncryptionMacKey []byte
    // contains filtered or unexported fields
}

func New

func New(rcvMaxSize int, interval int64, hbInterval int64) *Client

New Creates a new TCP Client

func (*Client) CatchOnReconnect

func (cli *Client) CatchOnReconnect(ver uint8, cmd uint16, callback func())

CatchOnReconnect registers a callback on reconnect or response w/ ver and cmd of your choice ONCE

func (*Client) Connect

func (cli *Client) Connect(addr string)

Connect Starts TCP Client

func (*Client) Disconnect

func (cli *Client) Disconnect()

Disconnect Stops TCP Client

func (*Client) OnConnect

func (cli *Client) OnConnect(callback func())

OnConnect registers a callback on connect

func (*Client) OnDisconnect

func (cli *Client) OnDisconnect(callback func())

OnDisconnect registers a callback on disconnect

func (*Client) OnPush

func (cli *Client) OnPush(callback func(uint8, uint16, []byte))

OnPush Registers a callback on response reveive

func (*Client) OnReconnect

func (cli *Client) OnReconnect(callback func())

OnReconnect registers a callback on reconnect

func (*Client) OnResponse

func (cli *Client) OnResponse(callback func(uint8, uint16, uint8, []byte))

OnResponse Registers a callback on response reveive

func (*Client) PauseHeartbeat

func (cli *Client) PauseHeartbeat()

PauseHeartbeat Stops sending heartbeat command to the server

func (*Client) Reconnect

func (cli *Client) Reconnect(addr string)

Reconnect restarts TCP Client

func (*Client) RemoveAll

func (cli *Client) RemoveAll()

RemoveAll Removes all callbacks on OnResponse and OnPush

func (*Client) RemoveAllOnPush

func (cli *Client) RemoveAllOnPush()

RemoveAllOnPush Removes all callbacks on OnPush

func (*Client) RemoveAllOnResponse

func (cli *Client) RemoveAllOnResponse()

RemoveAllOnResponse Removes all callbacks on OnResponse

func (*Client) RemoveOnReconnect

func (cli *Client) RemoveOnReconnect(callbackToRemove func())

RemoveOnReconnect removes a callback function on reconnect event

func (*Client) RemoveOnResponse

func (cli *Client) RemoveOnResponse(callbackToRemove func(uint8, uint16, uint8, []byte))

RemoveOnResponse removes a callback function on response event

func (*Client) ResumeHeartbeat

func (cli *Client) ResumeHeartbeat()

ResumeHeartbeat Resumes sending heartbeat command to the server

func (*Client) Send

func (cli *Client) Send(ver uint8, cmd uint16, payload []byte)

Send Sends a TCP packet to server

func (*Client) SetClientKey

func (cli *Client) SetClientKey(clientKey string)

SetClientKey sets up client key

func (*Client) SetEncryptionKeys

func (cli *Client) SetEncryptionKeys(sid []byte, key []byte, iv []byte, macKey []byte)

SetEncryptionKeys Sets up encryption keys

func (*Client) SetID

func (cli *Client) SetID(id string)

SetID sets ID