C# Class UnitTests.NetworkClient

Datei anzeigen Open project: Good4m/WindowsDefender Class Usage Examples

Public Properties

Property Type Description
SERVER_IP string
matchID string
socket System.Net.Sockets.UdpClient
username string

Public Methods

Method Description
NetworkClient ( string matchID, string username, string ip ) : System

The component that the game logic uses to creates the instance of our class.

OnApplicationQuit ( ) : void

Quits the client and closes the socket and stops the threads. Must have this otherwise Unity will freeze after running the application more than once.

SendInstruction ( Instruction command, string arg1 = "", string arg2 = "", string arg3 = "", string arg4 = "" ) : void

Sends an instruction to the server. It's in a lock (using monitor lock) to prevent multiple sending instructions at the same time.

Start ( ) : void

Starts the new thread that will call the client to start.

Method Details

NetworkClient() public method

The component that the game logic uses to creates the instance of our class.
public NetworkClient ( string matchID, string username, string ip ) : System
matchID string The MatchID of the client. It is 20 characters separated with a dash every 4 characters.
username string The username of the client.
ip string
return System

OnApplicationQuit() public method

Quits the client and closes the socket and stops the threads. Must have this otherwise Unity will freeze after running the application more than once.
public OnApplicationQuit ( ) : void
return void

SendInstruction() public method

Sends an instruction to the server. It's in a lock (using monitor lock) to prevent multiple sending instructions at the same time.
public SendInstruction ( Instruction command, string arg1 = "", string arg2 = "", string arg3 = "", string arg4 = "" ) : void
command WDClient.Instruction The type of instruction to send.
arg1 string An argument to pass along with the instruction.
arg2 string An argument to pass along with the instruction.
arg3 string An argument to pass along with the instruction.
arg4 string An argument to pass along with the instruction.
return void

Start() public method

Starts the new thread that will call the client to start.
public Start ( ) : void
return void

Property Details

SERVER_IP public_oe property

The IP of the server. TODO: Change it eventually. (Should not be hardcoded to local).
public string SERVER_IP
return string

matchID public_oe property

The client's MatchID for the game. It is created in the web component of the application. TODO: Change it eventually. (Should not be hardcoded).
public string matchID
return string

socket public_oe property

The socket for UDP.
public UdpClient,System.Net.Sockets socket
return System.Net.Sockets.UdpClient

username public_oe property

The client's username for the game. It is created in the web component of the application. TODO: Change it eventually. (Should not be hardcoded).
public string username
return string