-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessages.cpp
38 lines (31 loc) · 974 Bytes
/
Messages.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "Messages.h"
using namespace rapidjson;
#include <rapidjson/writer.h>
#include <rapidjson/stringbuffer.h>
#include "Game.h"
#include "GameSettings.h"
void handle_message(const std::string& /*json*/, net::WebSocket* /*ws*/, Game* /*game*/) {
// Handle incoming messages
// TBD...
// Read JSON using rapidjson example:
// doc.Parse(json.c_str());
// assert(doc["type"].IsString());
// assert(doc["move"].IsInt());
// printf("Handling 'submit move' Event!\n");
// int submitted_move = doc["move"].GetInt();
// Write JSON using rapidjson example:
// StringBuffer sb;
// Writer<StringBuffer> writer(sb);
// writer.StartObject();
// writer.Key("type");
// writer.String("initial state");
// writer.Key("board");
// writer.StartArray();
// for (auto&& field : game->board) {
// writer.Int(field);
// }
// writer.EndArray();
// writer.EndObject();
// Sending to client example:
// ws->write(sb.GetString());
}