face

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DummyFace added in v1.5.0

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

func NewDummyFace added in v1.5.0

func NewDummyFace() *DummyFace

(AI GENERATED DESCRIPTION): Creates a new DummyFace with an unsigned base face and initializes its send packet buffer to an empty slice.

func (*DummyFace) Close added in v1.5.0

func (f *DummyFace) Close() error

(AI GENERATED DESCRIPTION): Stops the DummyFace by atomically setting its running flag to false, returning an error if it was already stopped.

func (*DummyFace) Consume added in v1.5.0

func (f *DummyFace) Consume() (enc.Buffer, error)

Consume consumes a packet from the engine

func (*DummyFace) FeedPacket added in v1.5.0

func (f *DummyFace) FeedPacket(pkt enc.Buffer) error

FeedPacket feeds a packet for the engine to consume

func (*DummyFace) IsLocal added in v1.5.0

func (f *DummyFace) IsLocal() bool

(AI GENERATED DESCRIPTION): Returns true if the face is local, otherwise false.

func (*DummyFace) IsRunning added in v1.5.0

func (f *DummyFace) IsRunning() bool

(AI GENERATED DESCRIPTION): Returns `true` if the `baseFace` is currently running, otherwise `false`.

func (*DummyFace) OnDown added in v1.5.0

func (f *DummyFace) OnDown(onDown func()) (cancel func())

(AI GENERATED DESCRIPTION): Registers a callback to be invoked when the face goes down, returning a function that can be called to unregister that callback.

func (*DummyFace) OnError added in v1.5.0

func (f *DummyFace) OnError(onError func(err error))

(AI GENERATED DESCRIPTION): Sets the callback function that will be invoked whenever the face encounters an error.

func (*DummyFace) OnPacket added in v1.5.0

func (f *DummyFace) OnPacket(onPkt func(frame []byte))

(AI GENERATED DESCRIPTION): Registers a callback function to handle incoming packets by assigning the provided function to the face's `onPkt` handler.

func (*DummyFace) OnUp added in v1.5.0

func (f *DummyFace) OnUp(onUp func()) (cancel func())

(AI GENERATED DESCRIPTION): Registers an “up” event handler for the face, storing the callback under a unique handle and returning a function that, when called, removes the handler.

func (*DummyFace) Open added in v1.5.0

func (f *DummyFace) Open() error

(AI GENERATED DESCRIPTION): Opens the DummyFace by verifying that both error and packet callbacks are set, checking that it is not already running, and marking the face as running.

func (*DummyFace) Send added in v1.5.0

func (f *DummyFace) Send(pkt enc.Wire) error

(AI GENERATED DESCRIPTION): Adds the supplied packet(s) to the DummyFace’s send queue, concatenating multiple buffers into a single buffer when necessary, but only if the face is running; otherwise it returns an error.

func (*DummyFace) String added in v1.5.0

func (f *DummyFace) String() string

(AI GENERATED DESCRIPTION): Returns the static string `"dummy-face"` to represent the DummyFace.

type StreamFace

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

StreamFace is a face that uses a stream connection.

func NewStreamFace

func NewStreamFace(network string, addr string, local bool) *StreamFace

(AI GENERATED DESCRIPTION): Creates a new StreamFace configured with the specified network type and address, marks it as local or remote, and registers a default handler that exits the process with status 106 when the face goes down.

func (*StreamFace) Close

func (f *StreamFace) Close() error

(AI GENERATED DESCRIPTION): Closes the StreamFace by marking its state as closed and shutting down the underlying connection if one exists.

func (*StreamFace) IsLocal

func (f *StreamFace) IsLocal() bool

(AI GENERATED DESCRIPTION): Returns true if the face is local, otherwise false.

func (*StreamFace) IsRunning

func (f *StreamFace) IsRunning() bool

(AI GENERATED DESCRIPTION): Returns `true` if the `baseFace` is currently running, otherwise `false`.

func (*StreamFace) OnDown added in v1.5.0

func (f *StreamFace) OnDown(onDown func()) (cancel func())

(AI GENERATED DESCRIPTION): Registers a callback to be invoked when the face goes down, returning a function that can be called to unregister that callback.

func (*StreamFace) OnError added in v1.5.0

func (f *StreamFace) OnError(onError func(err error))

(AI GENERATED DESCRIPTION): Sets the callback function that will be invoked whenever the face encounters an error.

func (*StreamFace) OnPacket added in v1.5.0

func (f *StreamFace) OnPacket(onPkt func(frame []byte))

(AI GENERATED DESCRIPTION): Registers a callback function to handle incoming packets by assigning the provided function to the face's `onPkt` handler.

func (*StreamFace) OnUp added in v1.5.0

func (f *StreamFace) OnUp(onUp func()) (cancel func())

(AI GENERATED DESCRIPTION): Registers an “up” event handler for the face, storing the callback under a unique handle and returning a function that, when called, removes the handler.

func (*StreamFace) Open

func (f *StreamFace) Open() error

(AI GENERATED DESCRIPTION): Opens a stream-based Face by establishing a network connection, initializing its state, and launching a goroutine to receive packets.

func (*StreamFace) Send

func (f *StreamFace) Send(pkt enc.Wire) error

(AI GENERATED DESCRIPTION): Sends the provided packet over the StreamFace’s underlying connection, returning an error if the face is not running or if the write fails.

func (*StreamFace) String added in v1.5.0

func (f *StreamFace) String() string

(AI GENERATED DESCRIPTION): Returns a string describing the stream face, formatted as “stream‑face (network://addr)”.

type WebSocketFace

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

func NewWebSocketFace

func NewWebSocketFace(url string, local bool) *WebSocketFace

(AI GENERATED DESCRIPTION): Creates a new WebSocketFace, initializing its base face with the supplied local flag and assigning the given WebSocket URL.

func (*WebSocketFace) Close

func (f *WebSocketFace) Close() error

(AI GENERATED DESCRIPTION): Closes the WebSocket face by marking it as closed and terminating the underlying connection if it hasn't already been closed.

func (*WebSocketFace) IsLocal

func (f *WebSocketFace) IsLocal() bool

(AI GENERATED DESCRIPTION): Returns true if the face is local, otherwise false.

func (*WebSocketFace) IsRunning

func (f *WebSocketFace) IsRunning() bool

(AI GENERATED DESCRIPTION): Returns `true` if the `baseFace` is currently running, otherwise `false`.

func (*WebSocketFace) OnDown added in v1.5.0

func (f *WebSocketFace) OnDown(onDown func()) (cancel func())

(AI GENERATED DESCRIPTION): Registers a callback to be invoked when the face goes down, returning a function that can be called to unregister that callback.

func (*WebSocketFace) OnError added in v1.5.0

func (f *WebSocketFace) OnError(onError func(err error))

(AI GENERATED DESCRIPTION): Sets the callback function that will be invoked whenever the face encounters an error.

func (*WebSocketFace) OnPacket added in v1.5.0

func (f *WebSocketFace) OnPacket(onPkt func(frame []byte))

(AI GENERATED DESCRIPTION): Registers a callback function to handle incoming packets by assigning the provided function to the face's `onPkt` handler.

func (*WebSocketFace) OnUp added in v1.5.0

func (f *WebSocketFace) OnUp(onUp func()) (cancel func())

(AI GENERATED DESCRIPTION): Registers an “up” event handler for the face, storing the callback under a unique handle and returning a function that, when called, removes the handler.

func (*WebSocketFace) Open

func (f *WebSocketFace) Open() error

(AI GENERATED DESCRIPTION): Opens a WebSocket connection for the face, initializes the connection, sets the face state to up, and starts a goroutine to receive packets.

func (*WebSocketFace) Send

func (f *WebSocketFace) Send(pkt enc.Wire) error

(AI GENERATED DESCRIPTION): Sends the given packet over the WebSocket connection if the face is running, otherwise returns an error.

func (*WebSocketFace) String added in v1.5.0

func (f *WebSocketFace) String() string

(AI GENERATED DESCRIPTION): Returns a human‑readable string describing the WebSocketFace, formatted as “websocket‑face (URL)”.

Jump to

Keyboard shortcuts

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