multiplayer

package
v0.0.0-...-fa75330 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStopped = fmt.Errorf("stopped")
	ErrPaused  = fmt.Errorf("paused")
)

Functions

func RegisterIntent

func RegisterIntent[I loki.EphemeralType]()

func RegisterIntentImpl

func RegisterIntentImpl[I, M loki.EphemeralType]()

Types

type ED25519Key

type ED25519Key struct {
	Key []byte
	// contains filtered or unexported fields
}

func NewED25519Key

func NewED25519Key() (*ED25519Key, error)

func (*ED25519Key) ID

func (k *ED25519Key) ID() ID

func (*ED25519Key) Public

func (k *ED25519Key) Public() Signer

func (*ED25519Key) Sign

func (k *ED25519Key) Sign(rand io.Reader, digest []byte) (signature []byte, err error)

func (*ED25519Key) Verify

func (k *ED25519Key) Verify(rand io.Reader, message, sig []byte) error

type Engine

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

func Start

func Start(key Signer) *Engine

Start the engine.

func (*Engine) Accept

func (e *Engine) Accept(conn io.ReadWriteCloser) (err error)

func (*Engine) AcceptPeer

func (e *Engine) AcceptPeer(peer Signer)

Accept votes to accept the peer. All other (active) peers must vote to accept before the peer is accepted.

func (*Engine) Dial

func (e *Engine) Dial(conn io.ReadWriteCloser) (err error)

func (*Engine) Next

func (e *Engine) Next(ctx context.Context, intents []loki.EphemeralType) ([]Event, error)

func (*Engine) Pause

func (e *Engine) Pause() bool

Pause ticking.

func (*Engine) RejectPeer

func (e *Engine) RejectPeer(peer Signer)

Reject votes to reject the peer. All other (active) peers other than the one being rejected must vote to accept before the peer is accepted.

func (*Engine) Resume

func (e *Engine) Resume()

Resume ticking.

func (*Engine) Stop

func (e *Engine) Stop()

Stop the engine.

type Event

type Event interface {
	// contains filtered or unexported methods
}

type ID

type ID [sha256.Size]byte

type PeerAccepted

type PeerAccepted struct{ Peer Signer }

type PeerConnected

type PeerConnected struct{ Peer Signer }

type PeerRejected

type PeerRejected struct{ Peer Signer }

type Signer

type Signer interface {
	ID() ID
	Public() Signer
	Sign(rand io.Reader, message []byte) (signature []byte, err error)
	Verify(rand io.Reader, message, sig []byte) error
}

type Tick

type Tick struct {
	Intents map[ID][]loki.EphemeralType
}

type UDP

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

func ListenUDP

func ListenUDP(key Signer, addr *net.UDPAddr) (*UDP, error)

func (*UDP) Connect

func (m *UDP) Connect(addr *net.UDPAddr)

Jump to

Keyboard shortcuts

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