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 ¶
type DummyFace struct {
// contains filtered or unexported fields
}
func NewDummyFace ¶
func NewDummyFace() *DummyFace
Constructs a new DummyFace initialized with a base face (configured for dummy mode) and an empty packet buffer, used to simulate network interactions and capture outgoing packets during testing.
func (*DummyFace) Close ¶
Closes the face, returning an error if the face was not previously running.
func (*DummyFace) FeedPacket ¶
FeedPacket feeds a packet for the engine to consume
func (*DummyFace) IsLocal ¶
func (f *DummyFace) IsLocal() bool
Returns true if the face is local (e.g., connected to a local NDN daemon).
func (*DummyFace) IsRunning ¶
func (f *DummyFace) IsRunning() bool
Returns true if the face is currently running.
func (*DummyFace) OnDown ¶
func (f *DummyFace) OnDown(onDown func()) (cancel func())
Registers a callback to be invoked when the face becomes unreachable and returns a function to cancel the callback registration.
func (*DummyFace) OnError ¶
func (f *DummyFace) OnError(onError func(err error))
Sets the error handler function to be called when an error occurs on this face, passing the error as an argument.
func (*DummyFace) OnPacket ¶
func (f *DummyFace) OnPacket(onPkt func(frame []byte))
Sets the callback function to be invoked when a packet is received on this face, passing the raw packet data as a byte slice.
func (*DummyFace) OnUp ¶
func (f *DummyFace) OnUp(onUp func()) (cancel func())
Registers a callback to be invoked when the face becomes active and returns a function to cancel the registration.
func (*DummyFace) Open ¶
Opens the DummyFace, returning an error if required callbacks are not set or the face is already running; marks the face as running upon successful opening.
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
Constructs a new StreamFace configured with the specified network, address, and local setting, defaulting to exit the application with code 106 when the face becomes unavailable.
func (*StreamFace) Close ¶
func (f *StreamFace) Close() error
Closes the StreamFace by transitioning its state to closed and closing the underlying connection if it exists, returning any error encountered during the connection close.
func (*StreamFace) IsLocal ¶
func (f *StreamFace) IsLocal() bool
Returns true if the face is local (e.g., connected to a local NDN daemon).
func (*StreamFace) IsRunning ¶
func (f *StreamFace) IsRunning() bool
Returns true if the face is currently running.
func (*StreamFace) OnDown ¶
func (f *StreamFace) OnDown(onDown func()) (cancel func())
Registers a callback to be invoked when the face becomes unreachable and returns a function to cancel the callback registration.
func (*StreamFace) OnError ¶
func (f *StreamFace) OnError(onError func(err error))
Sets the error handler function to be called when an error occurs on this face, passing the error as an argument.
func (*StreamFace) OnPacket ¶
func (f *StreamFace) OnPacket(onPkt func(frame []byte))
Sets the callback function to be invoked when a packet is received on this face, passing the raw packet data as a byte slice.
func (*StreamFace) OnUp ¶
func (f *StreamFace) OnUp(onUp func()) (cancel func())
Registers a callback to be invoked when the face becomes active and returns a function to cancel the registration.
func (*StreamFace) Open ¶
func (f *StreamFace) Open() error
Opens a network connection for the StreamFace, verifies required callbacks are set, and initiates packet reception in a goroutine.
func (*StreamFace) Send ¶
func (f *StreamFace) Send(pkt enc.Wire) error
Sends a wire-encoded packet through the StreamFace if it is active, using a mutex to ensure thread-safe transmission and returning an error if the send fails or the face is not running.
func (*StreamFace) String ¶
func (f *StreamFace) String() string
Returns a string representation of the StreamFace in the format "stream-face (network://address)", combining the underlying network type and address.
type WebSocketFace ¶
type WebSocketFace struct {
// contains filtered or unexported fields
}
func NewWebSocketFace ¶
func NewWebSocketFace(url string, local bool) *WebSocketFace
Constructs a WebSocketFace with the given URL and local boolean indicating whether it is a local face.
func (*WebSocketFace) Close ¶
func (f *WebSocketFace) Close() error
Closes the WebSocket connection if the face state is successfully transitioned to closed.
func (*WebSocketFace) IsLocal ¶
func (f *WebSocketFace) IsLocal() bool
Returns true if the face is local (e.g., connected to a local NDN daemon).
func (*WebSocketFace) IsRunning ¶
func (f *WebSocketFace) IsRunning() bool
Returns true if the face is currently running.
func (*WebSocketFace) OnDown ¶
func (f *WebSocketFace) OnDown(onDown func()) (cancel func())
Registers a callback to be invoked when the face becomes unreachable and returns a function to cancel the callback registration.
func (*WebSocketFace) OnError ¶
func (f *WebSocketFace) OnError(onError func(err error))
Sets the error handler function to be called when an error occurs on this face, passing the error as an argument.
func (*WebSocketFace) OnPacket ¶
func (f *WebSocketFace) OnPacket(onPkt func(frame []byte))
Sets the callback function to be invoked when a packet is received on this face, passing the raw packet data as a byte slice.
func (*WebSocketFace) OnUp ¶
func (f *WebSocketFace) OnUp(onUp func()) (cancel func())
Registers a callback to be invoked when the face becomes active and returns a function to cancel the registration.
func (*WebSocketFace) Open ¶
func (f *WebSocketFace) Open() error
Opens a WebSocket connection to the specified URL, verifies required callbacks are set, and initializes the face for communication by starting a goroutine to receive packets.
func (*WebSocketFace) Send ¶
func (f *WebSocketFace) Send(pkt enc.Wire) error
Sends a wire-encoded packet over the WebSocket connection if the face is running, returning an error if the face is not active.
func (*WebSocketFace) String ¶
func (f *WebSocketFace) String() string
Returns a string representation of the WebSocketFace, including its associated URL, for formatting or logging purposes.