Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CB ¶
type CB func([]byte, *Connection)
CB type for callback function for each type of transfered data
type Connection ¶
type Connection struct { AESKey string // AES-128/192/256 key in hex for connecton encryption Types map[uint8]DataTypeCB // map of type->params&callback KeepAlive time.Duration // tcp keep-alive ReadTimeout time.Duration // we need to receive new message at least once per this duration WriteTimeout time.Duration // maximal duration for every write operation ConnectTimeout time.Duration // maximum duration of net.Dial MaxSize uint32 // maximum number of bytes for one record/message Ctx context.Context // context for some values like server id CloseChan chan interface{} // channel for closing incoming messages circle // contains filtered or unexported fields }
Connection informaion both for client or server
func (*Connection) Connect ¶
func (c *Connection) Connect(address string) error
Connect to remote server
func (*Connection) ListenOne ¶
func (c *Connection) ListenOne(address string, onConnect func(*Connection, <-chan interface{}), onError func(err error)) error
ListenOne is one-connection server
type DataTypeCB ¶
type DataTypeCB struct { SizeBytes int8 // -1 for fixed size, 0 for no data (ping?), 1 for 0-255 bytes, 2 for 0-65535 bytes... FixedSize int32 // if some struct has fixed fize no other header needed Callback CB // which function to run after data received }
DataTypeCB describes
Click to show internal directories.
Click to hide internal directories.