Documentation ¶
Overview ¶
Package udpc provides functionality to create a UDP Client
Index ¶
- type CanConnect
- type CanReconnect
- type Client
- func (c *Client) Close(code int, reason string)
- func (c *Client) CloseAllStreams()
- func (c *Client) CloseStream(id string)
- func (c *Client) Connect() (err error)
- func (c *Client) GetStream(id string) (stream *udp.Stream, err error)
- func (c *Client) ID() string
- func (c *Client) OpenStream(metadata map[string]string, data map[string]string) (cstream *udp.Stream, err error)
- func (c *Client) RegisterHandler(mtype network.MessageType, handler MessageHandler) (err error)
- func (c *Client) SearchClients(params *model.ClientSearch) (clients []string, err error)
- func (c *Client) Send(msg *network.Message) (rmsg *network.Message, err error)
- func (c *Client) SetCanConnectHandler(handler CanConnect)
- func (c *Client) SetCanReconnectHandler(handler CanReconnect)
- func (c *Client) SetClosedHandler(handler ClosedHandler)
- func (c *Client) SetConnectedHandler(handler ConnectedHandler)
- func (c *Client) SetDisconnectedHandler(handler DisconnectedHandler)
- func (c *Client) SetStreamHandler(handler udp.StreamHandler)
- func (c *Client) String() string
- type ClosedHandler
- type Config
- type ConnectedHandler
- type DisconnectedHandler
- type MessageHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CanConnect ¶
Called to determine whether to connect to a Server
type CanReconnect ¶
Called to determine whether to reconnect to a Server
type Client ¶
type Client struct { // Config Cfg Config // Listen Address Addr *net.UDPAddr // UDP Connection // It's exposed as it's needed in the p2pc package UDPConn *net.UDPConn // ID Id string // Metadata Data *model.ClientData // Connected Status Connected bool // Exit Channel Exit chan bool // Closed Status Closed bool // contains filtered or unexported fields }
Client
func NewWithConnection ¶
func NewWithConnection(log *logrus.Logger, cfg Config, addr *net.UDPAddr, udpConn *net.UDPConn) (c *Client, err error)
Creates a new Client using an existing net.UDPConn connection
func (*Client) CloseAllStreams ¶
func (c *Client) CloseAllStreams()
Close all Streams Used when closing the Client
func (*Client) CloseStream ¶
Close the Stream associated with the ID
func (*Client) OpenStream ¶
func (c *Client) OpenStream(metadata map[string]string, data map[string]string) (cstream *udp.Stream, err error)
Open a new Stream to the Server
func (*Client) RegisterHandler ¶
func (c *Client) RegisterHandler(mtype network.MessageType, handler MessageHandler) (err error)
Register a MessageType Handler
func (*Client) SearchClients ¶
func (c *Client) SearchClients(params *model.ClientSearch) (clients []string, err error)
Search for Clients based on certain parameters
func (*Client) SetCanConnectHandler ¶
func (c *Client) SetCanConnectHandler(handler CanConnect)
Set CanConnect Handler
func (*Client) SetCanReconnectHandler ¶
func (c *Client) SetCanReconnectHandler(handler CanReconnect)
Set CanReconnect Handler
func (*Client) SetClosedHandler ¶
func (c *Client) SetClosedHandler(handler ClosedHandler)
Set Closed Handler
func (*Client) SetConnectedHandler ¶
func (c *Client) SetConnectedHandler(handler ConnectedHandler)
Set Connected Handler
func (*Client) SetDisconnectedHandler ¶
func (c *Client) SetDisconnectedHandler(handler DisconnectedHandler)
Set Disconnected Handler
func (*Client) SetStreamHandler ¶
func (c *Client) SetStreamHandler(handler udp.StreamHandler)
Set New Stream Handler
type Config ¶
type Config struct { // Log Tag Tag string // Server Address ServerAddr *net.UDPAddr // No. of times to try to connect ConnectTries int // No. of times to try to reconnect ReconnectTries int // Use QUID Datagram Datagrams bool Unmarshaler network.ChannelUnmarshaler // Server Token Token string // Metadata Data map[string]string // TLS Config TLS *tls.Config // QUIC Config Quic *quic.Config // contains filtered or unexported fields }
UDP Client Config
func (*Config) MaxStreams ¶
Maximum number of streams per connection
func (*Config) Unmarshalers ¶
func (c *Config) Unmarshalers() (unmarshalers []network.ChannelUnmarshaler)
Protobuf Unmarshalers
func (*Config) UseDatagram ¶
Whether to use Datagram mode for QUIC
type ConnectedHandler ¶
type ConnectedHandler func(reconnect bool)
Called on connection to the server
type MessageHandler ¶
Called when a Server sends a message