ojnet

package module
v0.0.0-...-d062c85 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2020 License: MPL-2.0 Imports: 3 Imported by: 0

README

OJNet-go

A Golang implementation of a Simple and easy to use UDP protocol

Documentation

Index

Constants

View Source
const PROTOCOL_VERSION uint8 = 0

Variables

This section is empty.

Functions

func WriteUInt16

func WriteUInt16(buffer *bytes.Buffer, val uint16)

func WriteUInt32

func WriteUInt32(buffer *bytes.Buffer, val uint32)

func WriteUInt64

func WriteUInt64(buffer *bytes.Buffer, val uint64)

Types

type AcknowledgePacket

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

ID 0x0A - Packet sent whenever a packet with reliable flag was received. Can acknowledge multiple reliable packets

func (*AcknowledgePacket) Decode

func (packet *AcknowledgePacket) Decode(data []byte) error

func (*AcknowledgePacket) Encode

func (packet *AcknowledgePacket) Encode() ([]byte, error)

type ChannelOpPacket

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

ID 0x0B - Packet used to signal different network operations This also is used to close the entire connection, by closing channel 0 (reserved for protocol operations)

func (*ChannelOpPacket) Decode

func (packet *ChannelOpPacket) Decode(data []byte) error

func (*ChannelOpPacket) Encode

func (packet *ChannelOpPacket) Encode() ([]byte, error)

type ChannelOperation

type ChannelOperation uint8
const (
	OPEN_CHANNEL ChannelOperation = iota
	CLOSE_CHANNEL
	RESET_ORDERED_IDS
)

type ConnectionAcceptedPacket

type ConnectionAcceptedPacket struct {
	ServerId uint64
}

ID 0x02 - Response from server to accept and open a connection

func (*ConnectionAcceptedPacket) Decode

func (packet *ConnectionAcceptedPacket) Decode(data []byte) error

func (*ConnectionAcceptedPacket) Encode

func (packet *ConnectionAcceptedPacket) Encode() ([]byte, error)

type ConnectionRejectedPacket

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

ID 0x03 - Response from server to reject a connection request

func (*ConnectionRejectedPacket) Decode

func (packet *ConnectionRejectedPacket) Decode(data []byte) error

func (*ConnectionRejectedPacket) Encode

func (packet *ConnectionRejectedPacket) Encode() ([]byte, error)

type ConnectionRejectedReason

type ConnectionRejectedReason uint8
const (
	INCOMPATIBLE_PROTOCOL_VER ConnectionRejectedReason = iota
	MAX_CONNECTIONS_REACHED
	RATELIMITED
)

type ConnectionRequestPacket

type ConnectionRequestPacket struct {
	ClientId        uint64
	ProtocolVersion uint8
}

ID: 0x01 - Send from client to server to try to open a connection

func (*ConnectionRequestPacket) Decode

func (packet *ConnectionRequestPacket) Decode(data []byte) error

func (*ConnectionRequestPacket) Encode

func (packet *ConnectionRequestPacket) Encode() ([]byte, error)

type ContainerPacket

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

ID 0x0C Container Packet acts as a header for all packets sent over the network

type EncodeDecodeError

type EncodeDecodeError struct {
	Reason string
}

func (EncodeDecodeError) Error

func (err EncodeDecodeError) Error() string

type Packet

type Packet interface {
	Encode() ([]byte, error)
	Decode([]byte) error
}

type PacketID

type PacketID uint8
const (
	ConnectionRequestPid PacketID = iota
	ConnectionAcceptedPid
	ConnectionRejectedPid
	AcknowledgedPid     PacketID = 0x0A
	ChannelOperationPid PacketID = 0x0B
	ContainerPid        PacketID = 0x0C
)

Jump to

Keyboard shortcuts

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