Documentation
¶
Index ¶
- type DummyFace
- func (f *DummyFace) Close() error
- func (f *DummyFace) Consume() (enc.Buffer, error)
- func (f *DummyFace) FeedPacket(pkt enc.Buffer) error
- func (f *DummyFace) IsLocal() bool
- func (f *DummyFace) IsRunning() bool
- func (f *DummyFace) OnDown(onDown func()) (cancel func())
- func (f *DummyFace) OnError(onError func(err error))
- func (f *DummyFace) OnPacket(onPkt func(frame []byte))
- func (f *DummyFace) OnUp(onUp func()) (cancel func())
- func (f *DummyFace) Open() error
- func (f *DummyFace) Send(pkt enc.Wire) error
- func (f *DummyFace) String() string
- type StreamFace
- func (f *StreamFace) Close() error
- func (f *StreamFace) IsLocal() bool
- func (f *StreamFace) IsRunning() bool
- func (f *StreamFace) OnDown(onDown func()) (cancel func())
- func (f *StreamFace) OnError(onError func(err error))
- func (f *StreamFace) OnPacket(onPkt func(frame []byte))
- func (f *StreamFace) OnUp(onUp func()) (cancel func())
- func (f *StreamFace) Open() error
- func (f *StreamFace) Send(pkt enc.Wire) error
- func (f *StreamFace) String() string
- type WebSocketFace
- func (f *WebSocketFace) Close() error
- func (f *WebSocketFace) IsLocal() bool
- func (f *WebSocketFace) IsRunning() bool
- func (f *WebSocketFace) OnDown(onDown func()) (cancel func())
- func (f *WebSocketFace) OnError(onError func(err error))
- func (f *WebSocketFace) OnPacket(onPkt func(frame []byte))
- func (f *WebSocketFace) OnUp(onUp func()) (cancel func())
- func (f *WebSocketFace) Open() error
- func (f *WebSocketFace) Send(pkt enc.Wire) error
- func (f *WebSocketFace) String() string
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
(AI GENERATED DESCRIPTION): Stops the DummyFace by atomically setting its running flag to false, returning an error if it was already stopped.
func (*DummyFace) FeedPacket ¶ added in v1.5.0
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
(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.
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)”.