Documentation
¶
Overview ¶
Package transport abstracts the WebSocket layer so the dispatcher never touches a concrete websocket library.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrFakeClosed = errors.New("transport: fake ws closed")
ErrFakeClosed is returned by a closed FakeWS.
Functions ¶
This section is empty.
Types ¶
type FakeWS ¶
type FakeWS struct {
// contains filtered or unexported fields
}
FakeWS is an in-memory WS for tests. Inbound messages are injected via Inject; outbound writes are observable via Sent.
func (*FakeWS) Subprotocol ¶
type StatusCode ¶
type StatusCode int
StatusCode mirrors RFC 6455 close codes (subset used by OCPP).
const ( StatusNormalClosure StatusCode = 1000 StatusGoingAway StatusCode = 1001 StatusProtocolError StatusCode = 1002 StatusInternalError StatusCode = 1011 )
type WS ¶
type WS interface {
// Read blocks until one full text message arrives or ctx is cancelled.
Read(ctx context.Context) ([]byte, error)
// Write sends one text message, respecting ctx for cancellation.
Write(ctx context.Context, data []byte) error
// Close sends a close frame with the given status code and reason.
Close(code StatusCode, reason string) error
// Subprotocol returns the negotiated subprotocol (e.g. "ocpp1.6").
Subprotocol() string
}
WS is a context-native WebSocket connection. All blocking operations accept a context so the dispatcher can cancel reads/writes during connection teardown.
func NewCoderWS ¶
NewCoderWS wraps a coder/websocket connection as a WS.
Click to show internal directories.
Click to hide internal directories.