Client

Netorcai metaprotocol client class (D version)

Constructors

this
this()

Constructor. Initializes a TCP socket (AF_INET, STREAM)

Destructor

~this
~this()

Destructor. Closes the socket if needed.

Members

Functions

close
void close()

Close the socket.

connect
void connect(string hostname, ushort port)

Connect to a remote endpoint. Throw Exception on error.

readDoInit
DoInitMessage readDoInit()

Reads a DO_INIT message on the client socket. Throw Exception on error.

readDoTurn
DoTurnMessage readDoTurn()

Reads a DO_TURN message on the client socket. Throw Exception on error.

readGameEnds
GameEndsMessage readGameEnds()

Reads a GAME_ENDS message on the client socket. Throw Exception on error.

readGameStarts
GameStartsMessage readGameStarts()

Reads a GAME_STARTS message on the client socket. Throw Exception on error.

readLoginAck
LoginAckMessage readLoginAck()

Reads a LOGIN_ACK message on the client socket. Throw Exception on error.

readTurn
TurnMessage readTurn()

Reads a TURN message on the client socket. Throw Exception on error.

recvJson
JSONValue recvJson()

Reads a JSON message on the client socket. Throw Exception on error.

recvString
string recvString()

Reads a string message on the client socket. Throw Exception on error.

sendDoInitAck
void sendDoInitAck(JSONValue initialGameState)

Send a DO_INIT_ACK message on the client socket. Throw Exception on error.

sendDoTurnAck
void sendDoTurnAck(JSONValue gameState, int winnerPlayerID)

Send a DO_TURN_ACK message on the client socket. Throw Exception on error.

sendJson
void sendJson(JSONValue message)

Send a JSON message on the client socket. Throw Exception on error.

sendLogin
void sendLogin(string nickname, string role)

Send a LOGIN message on the client socket. Throw Exception on error.

sendString
void sendString(string message)

Send a string message on the client socket. Throw Exception on error.

sendTurnAck
void sendTurnAck(int turnNumber, JSONValue actions)

Send a TURN_ACK message on the client socket. Throw Exception on error.

Meta