server

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: GPL-2.0 Imports: 5 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
	// Cookies
	Cookies map[string][]string

	// Data is used for storing extra data about the client server side.
	Data any
	// contains filtered or unexported fields
}

Server-side client.

func (*Client) AddCookie added in v1.5.1

func (c *Client) AddCookie(key string, value string)

func (*Client) DeleteCookie added in v1.5.1

func (c *Client) DeleteCookie(key string)

func (*Client) GetCookie added in v1.5.1

func (c *Client) GetCookie(key string) []string

func (*Client) SetCookies added in v1.5.1

func (c *Client) SetCookies(key string, values []string)

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 any, 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(typ ...string) (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