message

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const HeaderSize = 5

Variables

View Source
var CurrentProtocolVersion = uint8(0)
View Source
var Sessions = &sessionList{}

Functions

This section is empty.

Types

type Asset

type Asset struct {
	ID          uint
	X           uint
	Y           uint
	StateLength uint
	State       interface{}
}

type Envelope

type Envelope struct {
	Conn net.Conn
	Raw  Raw
}

type Handler

type Handler interface {
	HandleConnection(conn net.Conn)
	Send(envelope Envelope)
}
type Header struct {
	ProtocolVersion uint8
	MessageType     Type
	Length          uint16
}

Header starts every message with a simple preamble

func GetHeader

func GetHeader(conn net.Conn) Header

func (Header) Bytes

func (h Header) Bytes() []byte

type Layer

type Layer struct {
	ID    uint8
	Asset Asset
}

type LoginRequest

type LoginRequest struct {
	CharacterName string
}

func (LoginRequest) Envelope

func (l LoginRequest) Envelope(conn net.Conn) Envelope

type LoginResponse

type LoginResponse struct {
	EntityID  uuid.UUID
	SessionID uuid.UUID
}

func (LoginResponse) Envelope

func (l LoginResponse) Envelope(conn net.Conn) Envelope

type NetworkSerializable

type NetworkSerializable interface {
	// NetworkWrite Writes the object for transport over the network
	NetworkWrite(stream *nivio.Writer) error

	// NetworkRead Reads the object from the network
	NetworkRead(stream *nivio.Reader) error
}

NetworkSerializable objects can be wrote to and read from the network

type PlayerActionRequest

type PlayerActionRequest struct {
	SessionID       uuid.UUID
	CommandID       uint32
	ClientCommandID uint8
}

func (*PlayerActionRequest) NetworkRead

func (playerActionRequest *PlayerActionRequest) NetworkRead(stream *nivio.Reader) error

NetworkRead should have inherited the comment from the interface but because there is no way to know which interface it came from, it wants another comment. So here that it. Yay.

func (*PlayerActionRequest) NetworkWrite

func (playerActionRequest *PlayerActionRequest) NetworkWrite(stream *nivio.Writer) error

NetworkWrite should have inherited the comment from the interface but because there is no way to know which interface it came from, it wants another comment. So here that it. Yay.

type PlayerActionResponse

type PlayerActionResponse struct {
	ClientCommandID uint8
	Result          interface{}
}

type Raw

type Raw struct {
	Header       Header
	MessageBytes []byte
}

func (Raw) Bytes

func (r Raw) Bytes() []byte

type Server

type Server interface {
	HandleSessionConnections()
	WaitForInterrupt()
	EnqueueMessage(envelope Envelope)
}

type Session

type Session struct {
	Conn          net.Conn
	Authenticated bool
	SessionID     uuid.UUID
	EntityID      uuid.UUID
	Created       time.Time
}

func SessionFor

func SessionFor(conn net.Conn) Session

type SessionNotFoundError

type SessionNotFoundError struct {
	ID uuid.UUID
}

func (SessionNotFoundError) Error

func (e SessionNotFoundError) Error() string

type Type

type Type uint16
const (
	// Client to Server
	TypeLoginRequest        Type = 0
	TypePlayerActionRequest Type = 1

	// Server to client
	TypeLoginResponse        Type = 1000
	TypePlayerActionResponse      = 1001
	TypeZoneReport                = 1002
)

type ZoneReport

type ZoneReport struct {
	Header
	Layers []Layer
}

Directories

Path Synopsis
npc

Jump to

Keyboard shortcuts

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