server

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Threshold : Limit of simultanous message between client from channel
	BUFFER_CLIENT_NB_MESSAGE_THRESHOLD = 200
	// Threshold : Limit the buffer size for sockets
	BUFFER_SIZE = 1024
)

Variables

This section is empty.

Functions

func ClientHandler

func ClientHandler(connection net.Conn, messageChannel chan string, clients *list.List)

*

  • Manage I/O client from server socket *
  • @param connection - Socket between client and server
  • @param messageChannel - The shared bus message between all clients
  • @param clients - The list of all clients connected

func ClientReceiver

func ClientReceiver(client *Client)

*

  • Manage client input from server-side socket *
  • @param client - Client object

func ClientSender

func ClientSender(client *Client)

*

  • Manage output from server-side socket *
  • @param client - Client object

func IOHandler

func IOHandler(Incoming <-chan string, clients *list.List)

*

  • Manage asynchronously IO from all connected clients *
  • @param Incoming - A pipe between each client to relay message
  • @param clients - A list of connected client

Types

type Client

type Client struct {
	Incoming   chan string // Message Channel : Input
	Outgoing   chan string // Message Channel : Output
	Connection net.Conn    // Socket between client and server
	Quit       chan bool   // Message Channel which contains the state of connection
	Clients    *list.List  // List of clients connected from server
}

* Client structure

func (Client) Close

func (c Client) Close()

*

  • Manage client logout

func (Client) GetId

func (c Client) GetId() string

*

  • Getting uniq identifier of a client

func (Client) Read

func (c Client) Read(buffer []byte) bool

*

  • Read data from client socket
  • @param buffer

func (Client) RemoveMe

func (c Client) RemoveMe()

*

  • Remove client from the list of connected users

func (Client) Send

func (c Client) Send(buffer []byte) int

*

  • Send data from client socket
  • @param buffer - []byte
  • @return int - nb bytes sent

func (Client) SendMessage

func (c Client) SendMessage(message string)

*

  • Send string message from client socket
  • @param message - string

type Server

type Server struct {
	socket.SocketContext
	Clients *list.List
}

* ServerProvider structure

func Create

func Create(target *socket.Target, useDebugMode bool) Server

* Init server instance

func (Server) Start

func (s Server) Start()

Jump to

Keyboard shortcuts

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