MCPcopy Create free account
hub / github.com/PlayFab/gsdk / processRequests

Function processRequests

cpp/testapps/cppWindowsRunnerGame/main.cpp:102–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102void processRequests()
103{
104 while (true)
105 {
106 int new_socket;
107 int valread;
108 int addrlen = sizeof(address);
109 char buffer[1024] = { 0 };
110
111 if ((new_socket = accept(server_fd, (sockaddr*)&address, &addrlen)) < 0)
112 {
113 perror("accept");
114 fflush(stdout);
115 exit(EXIT_FAILURE);
116 }
117
118 valread = recv(new_socket, buffer, sizeof(buffer), 0);
119 printf("HTTP:Received %.*s\n", valread, buffer);
120 fflush(stdout);
121
122 // For each request, "add" a connected player
123 players.push_back(Microsoft::Azure::Gaming::ConnectedPlayer("gamer" + std::to_string(requestCount)));
124 requestCount++;
125 Microsoft::Azure::Gaming::GSDK::updateConnectedPlayers(players);
126
127 std::unordered_map<std::string, std::string> config = Microsoft::Azure::Gaming::GSDK::getConfigSettings();
128
129 // First, check if we need to delay shutdown for testing
130 auto it = config.find(Microsoft::Azure::Gaming::GSDK::SESSION_COOKIE_KEY);
131
132 if (it != config.end() && strcmp(it->second.c_str(), "delayshutdown") == 0)
133 {
134 delayShutdown = true;
135 }
136
137 if (isActivated)
138 {
139 std::string playersJoinedAsString = "";
140 for (auto player : Microsoft::Azure::Gaming::GSDK::getInitialPlayers())
141 {
142 playersJoinedAsString += (playersJoinedAsString.empty() ? "" : ",") + player;
143 }
144
145 config["initialPlayers"] = playersJoinedAsString;
146 }
147
148 config["isActivated"] = isActivated ? "true" : "false";
149 config["isShutdown"] = isShutdown ? "true" : "false";
150 config["assetFileText"] = assetFileText;
151 config["installedCertThumbprint"] = installedCertThumbprint;
152 config["cmdArgs"] = cmdArgs;
153
154 if (isMaintenancedScheduled)
155 {
156 char buffer[10];
157 tm tm;
158 localtime_s(&tm, &nextMaintenance);
159 asctime_s(buffer, sizeof(buffer), &tm);

Callers

nothing calls this directly

Calls 7

findMethod · 0.80
endMethod · 0.80
emptyMethod · 0.80
beginMethod · 0.80
sizeMethod · 0.80
escapeFunction · 0.70
ConnectedPlayerClass · 0.50

Tested by

no test coverage detected