Skip to content
This repository has been archived by the owner on Jun 7, 2019. It is now read-only.

Network Library Documentation

Codex04 edited this page Nov 12, 2017 · 1 revision

Network

Client InfosClient
Locker LockManager
Server

Client

Client class for the Network library. This class allow the user to start a transmission in order to receive and send requests to a single Server.

CallBackFct

Static callback method for the server request

ClientRequest(header, connection, data)

Trigered function when the server want to communicate with the client

Name Description
header NetworkCommsDotNet.PacketHeader
connection NetworkCommsDotNet.Connections.Connection
data System.String
Data send by the server

Finalize

Destructor of the Client. When called, it'll shutdown all the transmissions

Instance

Getter for the singleton instance of a Client

MsgCallbackFct

Static callback method for the chat server request

MsgRequest(header, connection, msg)

Get a msg for the chat from the server

Name Description
header NetworkCommsDotNet.PacketHeader
connection NetworkCommsDotNet.Connections.Connection
msg System.String

SendDataToServer(data)

Send an object to the server (you will minimum need "public string name" in your object

Name Description
data System.Object

SendMsgChat(msg)

Send a msg for the chat to the server

Name Description
msg System.String

Start(callBackFct, msgCallbackFct, serverIP, serverPort)

Launch the ClientNetwork

Name Description
callBackFct System.Func{System.Object,System.Int32}
Function called when the client receive a message from the server
msgCallbackFct System.Func{System.String,System.Int32}
Function called when the client received a chat message from the server
serverIP System.String
Ip of the server you want to connect to
serverPort System.Int32
Port of the server you want to connect to

InfosClient

A class which contains the network information for a client.

_ip

A System.String for the IP of the client

_port

An System.Int32 for the port of the client

Locker

Class designed to lock and unlock asynchronous event. Usually managed by a LockManager.

Constructor(key_, username_, duration_)

Second constructor of the Locker, allowing the user to customize the timeout duration.

Name Description
key_ System.UInt32
The unique key code of the Locker
username_ System.String
The username of the Locker's owner
duration_ System.Int32
The duration of the lock period timeout.

Constructor(key_, username_)

Main constructor of the Locker

Name Description
key_ System.UInt32
The unique key code of the Locker
username_ System.String
The username of the Locker's owner

Duration

Getter and Setter for the timeout duration of the Locker

Key

Getter and Setter for the Locker key

State

Getter and Setter for the current State of the Locker

Username

Getter and Setter for the Username of the owner of the Locker

LockManager

Class used to store, delete, lock and unlock Locker

Add(username)

Add a new Locker in the manager

Name Description
username System.String
The owner of the Locker

Returns

This method return the generated key of the Locker

Delete(key)

Delete the locker associated to the key given in parameter

Name Description
key System.UInt32
The key of the Locker

Returns

True if the Locker has been successfully deleted, false otherwise.

Lock(key)

Lock the Locker linked to the key given in parameter and wait for a call to LockManager.Unlock(System.UInt32)

Name Description
key System.UInt32
The key of the Locker

Returns

False if no Locker has been found with this key, true otherwise

Locks

Getter and Setter for the Dictionnary of Lockers, which assign an System.UInt32 key to its Locker

Unlock(key)

Unlock the Locker linked to the key given in parameter.

Name Description
key System.UInt32
The key of the Locker

Returns

False if the manager does not contain a Locker with this key, true otherwise

Server

Server class for the Network library. This class allow the user to start a transmission in order to receive and send requests to multiples Client.

_currentId

Current client ID

CallBackFct

Callback method which will be called when the server receive client request

Clients

A getter and a setter to a dictionnary which link for each client's name their network informations (InfosClient)

DeleteClient(name)

Delete a client to the server

Name Description
name System.String

Returns

Finalize

Destructor for the Server class. It will shutdwon the connection.

GetIpAddr

Get ip of the pc

Returns

Instance

A getter and a setter for the server singleton instance

Lock_m

A getter and a setter for the stored LockerManager wich will manager all the synchronous network operations

MsgRequest(header, connection, msg)

Get a Msg from a client for the chat

Name Description
header NetworkCommsDotNet.PacketHeader
connection NetworkCommsDotNet.Connections.Connection
msg System.String

SendDataToClient(name, data)

Send an object to a client

Name Description
name System.String
Name of the client you want to send something
data CardGameResources.Net.Packet

Returns

SendMsgChat(msg)

Send a msg to all the clients for the chat

Name Description
msg System.String

Returns

ServerRequest(header, connection, data)

Function trigered by the server when the client send a request

Name Description
header NetworkCommsDotNet.PacketHeader
connection NetworkCommsDotNet.Connections.Connection
data System.String
Data sent by the client

Start(callBackFct)

Name Description
callBackFct System.Func{System.Object,System.Int32}
Function called when the client receive a request from the client

Returns

Stop

Stop the server by closing all packet handlers and stop the request listening. It also delete all the client's infos