server

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v1.3.1

type Client struct {
	Conn net.Conn
	Key  *[32]byte
	Data any
}

Server-side client.

type Server

type Server struct {
	// Address of the server.
	IP   string
	PORT any
	// Listener for connections.
	Listener net.Listener
	// General configuration.
	CONFIG  *quickproto.Config
	Clients map[string]*Client
}

Server struct.

func New added in v1.1.6

func New(ip string, port int, conf *quickproto.Config) *Server

Initialize a new server.

func (*Server) Accept

func (s *Server) Accept() (net.Conn, *Client, error)

Accept a new client connection. If the server is using crypto, the first message received from the client will be the AES key. If the server is provided with a private key, it will use it to decrypt the AES key. The server will then use the AES key to decrypt and encrypt all future messages.

func (*Server) Addr

func (s *Server) Addr() string

Get the address of the server.

func (*Server) Broadcast added in v1.3.1

func (s *Server) Broadcast(msg *quickproto.Message) error

Broadcast a message to all clients.

func (*Server) Listen

func (s *Server) Listen() (net.Listener, error)

Listen for connections

func (*Server) Read

func (s *Server) Read(client *Client) (*quickproto.Message, error)

Read a message from a client.

func (*Server) RemoveClient added in v1.3.1

func (s *Server) RemoveClient(conn net.Conn) error

Close a client connection.

func (*Server) Terminate

func (s *Server) Terminate() error

Close the server

func (*Server) Write

func (s *Server) Write(client *Client, msg *quickproto.Message) error

Write a message to a client.

Jump to

Keyboard shortcuts

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