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(in string hostname = "localhost", in ushort port = 4242)

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(in JSONValue initialGameState)

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

sendDoTurnAck
void sendDoTurnAck(in JSONValue gameState, in int winnerPlayerID)

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

sendJson
void sendJson(in JSONValue message)

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

sendLogin
void sendLogin(in string nickname, in string role)

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

sendString
void sendString(in string message)

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

sendTurnAck
void sendTurnAck(in int turnNumber, in JSONValue actions)

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

Meta