Method | Description | |
---|---|---|
NetworkClient ( string matchID = "4fg7-38g3-d922-f75g-48g6", string username = "Jeff" ) : 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.
|
Method | Description | |
---|---|---|
ReceiveInstruction ( Instruction instruction ) : void |
When a command is received from the server. It specifies what to do with the different type of instruction received. TODO: A 'leave' command, 'joined' command and 'command' command just print for now. Need to add function.
|
|
Start ( ) : void |
Starts the new thread that will call the client to start.
|
|
StartClient ( ) : void |
Starts the client. Asks the server for permission to join. Then runs in a loop, constantly looking for new instructions, such as Leave, Joined, and Command. It deserializes the instruction and passes it on to ReceiveInstruction method.
|
public NetworkClient ( string matchID = "4fg7-38g3-d922-f75g-48g6", string username = "Jeff" ) : 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. |
return | System |
public SendInstruction ( Instruction command, string arg1 = "", string arg2 = "", string arg3 = "", string arg4 = "" ) : void | ||
command | 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 |