client

package
v0.0.0-...-2f4e5ef Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Zlib Imports: 13 Imported by: 0

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 New

func New(address, username, proto string, opts ...Option) *Client

New creates a new Client instance

func (*Client) Connect

func (c *Client) Connect() error

Connect establishes a connection to the server

func (*Client) Disconnect

func (c *Client) Disconnect()

Disconnect closes the connection to the server

func (*Client) IsConnected

func (c *Client) IsConnected() bool

IsConnected returns whether the client is connected

func (*Client) Join

func (c *Client) Join() error

Join sends a join message to the server

func (*Client) Leave

func (c *Client) Leave() error

Leave sends a leave message to the server

func (*Client) Messages

func (c *Client) Messages() <-chan protocol.Message

Messages returns the channel for receiving messages

func (*Client) SendMessage

func (c *Client) SendMessage(content string) error

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

func WithRootCAs(pool *x509.CertPool) Option

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) Read

func (tc *TCPClientConnection) Read(buf []byte) (int, error)

func (*TCPClientConnection) RemoteAddr

func (tc *TCPClientConnection) RemoteAddr() net.Addr

func (*TCPClientConnection) Write

func (tc *TCPClientConnection) Write(data []byte) (int, error)

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

func (*WebSocketClientConnection) Write

func (wc *WebSocketClientConnection) Write(data []byte) (int, error)

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

func (*WebTransportClientConnection) Write

func (wtc *WebTransportClientConnection) Write(data []byte) (int, error)

Jump to

Keyboard shortcuts

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