Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a chat client
func (*Client) Disconnect ¶
func (c *Client) Disconnect()
Disconnect closes the connection to the server
func (*Client) IsConnected ¶
IsConnected returns whether the client is connected
func (*Client) SendMessage ¶
SendMessage sends a text message to the server
type ClientConnection ¶
type ClientConnection interface {
// Write sends data to the server
Write(data []byte) (int, error)
// Read receives data from the server
Read(buf []byte) (int, error)
// Close closes the connection
Close() error
// RemoteAddr returns the server address
RemoteAddr() net.Addr
}
ClientConnection represents a connection to the server
type Option ¶
type Option func(*Client)
Option configures optional Client behavior.
func WithRootCAs ¶
WithRootCAs sets the certificate pool used to verify the server's TLS certificate for the WebTransport protocol. A nil pool falls back to the system trust store, so this is only needed for servers presenting a certificate signed by a CA not present there (for example a local dev CA).
type TCPClientConnection ¶
type TCPClientConnection struct {
// contains filtered or unexported fields
}
TCPClientConnection wraps net.Conn for TCP connections
func NewTCPClientConnection ¶
func NewTCPClientConnection(conn net.Conn) *TCPClientConnection
NewTCPClientConnection creates a new TCP connection wrapper
func (*TCPClientConnection) Close ¶
func (tc *TCPClientConnection) Close() error
func (*TCPClientConnection) RemoteAddr ¶
func (tc *TCPClientConnection) RemoteAddr() net.Addr
type WebSocketClientConnection ¶
type WebSocketClientConnection struct {
// contains filtered or unexported fields
}
WebSocketClientConnection wraps net.Conn for WebSocket connections using gobwas/ws
func NewWebSocketClientConnection ¶
func NewWebSocketClientConnection(conn net.Conn) *WebSocketClientConnection
NewWebSocketClientConnection creates a new WebSocket connection wrapper
func (*WebSocketClientConnection) Close ¶
func (wc *WebSocketClientConnection) Close() error
func (*WebSocketClientConnection) Read ¶
func (wc *WebSocketClientConnection) Read(buf []byte) (int, error)
func (*WebSocketClientConnection) RemoteAddr ¶
func (wc *WebSocketClientConnection) RemoteAddr() net.Addr
type WebTransportClientConnection ¶
type WebTransportClientConnection struct {
// contains filtered or unexported fields
}
WebTransportClientConnection wraps a WebTransport session and its single bidirectional stream. The chat protocol is treated as an unframed byte stream over that stream, matching the framing assumption used for TCP.
func NewWebTransportClientConnection ¶
func NewWebTransportClientConnection( session *webtransport.Session, stream *webtransport.Stream, ) *WebTransportClientConnection
NewWebTransportClientConnection creates a new WebTransport connection wrapper over an established session and its bidirectional stream.
func (*WebTransportClientConnection) Close ¶
func (wtc *WebTransportClientConnection) Close() error
func (*WebTransportClientConnection) Read ¶
func (wtc *WebTransportClientConnection) Read(buf []byte) (int, error)
func (*WebTransportClientConnection) RemoteAddr ¶
func (wtc *WebTransportClientConnection) RemoteAddr() net.Addr