connect

package
v0.0.0-...-3e66800 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const EVENT_GET byte = 5
View Source
const EVENT_LOG byte = 8
View Source
const EVENT_MOUSE_CLICK byte = 2
View Source
const EVENT_PAUSE byte = 1
View Source
const EVENT_SET_BORDERS byte = 6
View Source
const EVENT_UPDATE byte = 7
View Source
const EVENT_UPDATE_RATE_DECREASE byte = 4
View Source
const EVENT_UPDATE_RATE_INCREASE byte = 3
View Source
const MAX_PACKET_LEN = 65535
View Source
const MAX_RETRIES = 1000
View Source
const MAX_TIMEOUT = 1 * 1000 * 1000 * 1000
View Source
const MESSAGE_CLOSE byte = 9
View Source
const MESSAGE_ERROR byte = 2
View Source
const MESSAGE_EVENT byte = 3
View Source
const MESSAGE_PING byte = 1

Variables

This section is empty.

Functions

func BaseHandler

func BaseHandler(connection net.Conn, eventHandler func(connection net.Conn, event byte, buffer []byte) bool) bool

func BytesToInts

func BytesToInts(buffer []byte) []int

func CreatePacket

func CreatePacket(messageType byte, event byte, data []byte) []byte

func CreateResponsePacket

func CreateResponsePacket(data []int) []byte

func DeserializeBorders

func DeserializeBorders(data []byte) (*utilsgo.Vector, *utilsgo.Vector, *utilsgo.Vector, *utilsgo.Vector)

func DeserializeMatrix

func DeserializeMatrix(packet []byte) *utilsgo.Matrix

func DeserializeVector

func DeserializeVector(packet []byte) *utilsgo.Vector

func IntsToBytes

func IntsToBytes(buffer []int) []byte

func ReadPacket

func ReadPacket(conn net.Conn) (byte, byte, []byte)

func ReadRaw

func ReadRaw(connection net.Conn, size int) []byte

func ReadResponsePacket

func ReadResponsePacket(conn net.Conn) ([]byte, int)

func SendBadResponse

func SendBadResponse(connection net.Conn)

func SendOkResponse

func SendOkResponse(connection net.Conn)

func SerializeBorders

func SerializeBorders(top, bottom, left, right *utilsgo.Vector) []byte

func SerializeMatrix

func SerializeMatrix(matrix *utilsgo.Matrix) []int

func SerializeVector

func SerializeVector(vector *utilsgo.Vector) []byte

func WriteRaw

func WriteRaw(connection net.Conn, buffer []byte)

Types

type Client

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

func NewClient

func NewClient(host string, port int, protocol string) *Client

func (*Client) Close

func (client *Client) Close()

func (*Client) Dial

func (client *Client) Dial() net.Conn

func (*Client) Send

func (client *Client) Send(messageType byte, event byte, data []byte) ([]byte, int)

type Server

type Server struct {
	ShouldStop bool
	// contains filtered or unexported fields
}

func NewServer

func NewServer(host string, port int, protocol string) *Server

func (*Server) Close

func (server *Server) Close()

func (*Server) Listen

func (server *Server) Listen()

func (*Server) Serve

func (server *Server) Serve(eventHandler func(connection net.Conn, event byte, buffer []byte) bool)

Jump to

Keyboard shortcuts

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