net

package
v0.0.0-...-73b4bbd Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	Encoder
	Decoder
}

A Conn is used to send and receive EncodableType values.

func NewGobConn

func NewGobConn(rw io.ReadWriter) Conn

type Decoder

type Decoder interface {
	NextType() (EncodedType, error)
	Decode(EncodableType) error
}

A Decoder is used to receive EncodableType values.

type EncodableType

type EncodableType interface {
	Type() EncodedType
}

An EncodableType is a value that can be represented by a EncodedType and sent/received over a Conn.

type EncodedType

type EncodedType int

A EncodedType is used to mark the following value's type to enable decoding into a concrete go value.

const (
	ET_ERROR EncodedType = iota

	// The Server or the Client can send an ET_PROTOCOL_ERROR if it
	// receives a packet that it wasn't expecting.
	ET_PROTOCOL_ERROR

	// The Server or the Client can send an ET_DISCONNECT message
	// to signal that the connection will be closed.
	ET_DISCONNECT

	// The client sends an ET_CONNECT_ACTOR message immediately
	// after a connection is established.
	ET_CONNECT_ACTOR

	// The Server will respond with an ET_CONNECTED_ACTOR which will
	// contain an implementation specific structure that describes the
	// actor.
	ET_CONNECTED_ACTOR

	// Immediately following an ET_CONNECTED_ACTOR will be an ET_WORLD_STATE
	// that the client can use to render the world around the actor.
	ET_WORLD_STATE

	// As the world changes the server will send ET_WORLD_STATE_DIFF packets
	// enabling the client to update it's view of the world and render this
	// to the user.
	ET_WORLD_STATE_DIFF

	// Used to extend the EncodedType enumeration in other packages.
	// WARNING: Only recommended to extend in one place, else
	// the values taken by the enumeration cases could overlap.
	ET_EXTEND
)

func (EncodedType) String

func (i EncodedType) String() string

type Encoder

type Encoder interface {
	Encode(EncodableType) error
}

An Encoder is used to send EncodableType values.

type ProtocolError

type ProtocolError string

A ProtocolError is used to respond to the client or server that it sent and unexpected packet type.

func (ProtocolError) Error

func (e ProtocolError) Error() string

func (ProtocolError) Type

func (ProtocolError) Type() EncodedType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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