Skip to content

Instantly share code, notes, and snippets.

@ToeJamson
Last active December 21, 2015 02:18
Show Gist options
  • Select an option

  • Save ToeJamson/6233756 to your computer and use it in GitHub Desktop.

Select an option

Save ToeJamson/6233756 to your computer and use it in GitHub Desktop.
Creating a C# Game Server
private void HandleMessage(string json) {
Dictionary<string, string> message = ParseJson(json);
Dictionary<string, string> response = new Dictionary<string, string>90;
response["type"] = message["type"];
switch (message["type"]) {
case "login":
if (authorized(message["user"])) {
response["sucess"] = true;
}
break;
case "register":
if (IsNewUser9message["user"])) {
// Add User
response["success"] = true;
}
break;
case "join-game":
if (IsGameAvailable(message["game"])){
// Join game
response["success"] = true;
}
break;
}
Pubnub.publish(message["user"], response, MessagePublished):
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment