...

Package udp

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

Overview ▾

func LogLevel

func LogLevel(lvl int)

LogLevel sets log level

type Client

Client UDP 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) *Client

New Creates a new UDP 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 connects UDP Client

func (*Client) Disconnect

func (cli *Client) Disconnect()

Disconnect disconnects the UDP 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 push receive

func (*Client) OnReconnect

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

OnReconnect registers a callack on Reconnect

func (*Client) OnResponse

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

OnResponse Registers a callback on response receive

func (*Client) Ping

func (cli *Client) Ping()

Ping sends a ping packet over UDP

func (*Client) RSend

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

RSend Sends a Reliable UDP packet to server

func (*Client) Reconnect

func (cli *Client) Reconnect(addr string)

Reconnect restarts UDP Client

func (*Client) RemoveAll

func (cli *Client) RemoveAll()

RemoveAll Removes all callbacks

func (*Client) RemoveAllOnPush

func (cli *Client) RemoveAllOnPush()

RemoveAllOnPush Removes all callbacks of OnPush

func (*Client) RemoveAllOnResponse

func (cli *Client) RemoveAllOnResponse()

RemoveAllOnResponse Removes all callbacks of 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) Send

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

Send Sends a UDP 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