package tcp
import "github.com/Diarkis/diarkis/client/go/tcp"
Index
- func LogLevel(lvl int)
-
type Client
- func New(rcvMaxSize int, interval int64, hbInterval int64) *Client
- func (cli *Client) CatchOnReconnect(ver uint8, cmd uint16, callback func(bool))
- func (cli *Client) Connect(addr string)
- func (cli *Client) Die()
- func (cli *Client) Disconnect()
- func (cli *Client) EnablePuffer(isPufferEnabled bool)
- func (cli *Client) IsOffline() bool
- func (cli *Client) Migrate()
- func (cli *Client) OnConnect(callback func())
- func (cli *Client) OnDisconnect(callback func())
- func (cli *Client) OnHeartbeat(callback func())
- func (cli *Client) OnOffline(callback func())
- func (cli *Client) OnPush(callback func(uint8, uint16, []byte))
- func (cli *Client) OnReconnect(callback func())
- func (cli *Client) OnResponse(callback func(uint8, uint16, uint8, []byte))
- func (cli *Client) PauseHeartbeat()
- func (cli *Client) Reconnect(addr string)
- func (cli *Client) RemoveAll()
- func (cli *Client) RemoveAllOnPush()
- func (cli *Client) RemoveAllOnResponse()
- func (cli *Client) RemoveOnPush(callbackToRemove func(uint8, uint16, []byte))
- func (cli *Client) RemoveOnReconnect(callbackToRemove func())
- func (cli *Client) RemoveOnResponse(callbackToRemove func(uint8, uint16, uint8, []byte))
- func (cli *Client) ResumeHeartbeat()
- func (cli *Client) Send(ver uint8, cmd uint16, payload []byte)
- func (cli *Client) SetClientKey(clientKey string)
- func (cli *Client) SetEncryptionKeys(sid []byte, key []byte, iv []byte, macKey []byte)
- func (cli *Client) SetID(id string)
Functions
func LogLevel
func LogLevel(lvl int)
LogLevel sets log level
Types
type Client
type Client struct { ID string IDBytes []byte ServerEndPoint string ClientKey string SID []byte SIDString string EncryptionKey []byte EncryptionIV []byte EncryptionMacKey []byte // IsPufferEnabled is a boolean flag that enables packing/unpacking with Puffer IsPufferEnabled bool }
Client TCP Client
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(bool))
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) Die
func (cli *Client) Die()
Die stops server communication ungracefully
func (*Client) Disconnect
func (cli *Client) Disconnect()
Disconnect Stops TCP Client
func (*Client) EnablePuffer
func (cli *Client) EnablePuffer(isPufferEnabled bool)
EnablePuffer enables or disables Puffer
func (*Client) IsOffline
func (cli *Client) IsOffline() bool
IsOffline returns if the connected server is offline state
func (*Client) Migrate
func (cli *Client) Migrate()
Migrate lets TCP client reconnect to the other server
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) OnHeartbeat
func (cli *Client) OnHeartbeat(callback func())
OnHeartbeat registers a callback on heartbeat
func (*Client) OnOffline
func (cli *Client) OnOffline(callback func())
OnOffline registers a callback called when server gets Offline state
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) RemoveOnPush
func (cli *Client) RemoveOnPush(callbackToRemove func(uint8, uint16, []byte))
RemoveOnPush removes a callback function on push event
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