Last active
December 21, 2015 02:18
-
-
Save ToeJamson/6233756 to your computer and use it in GitHub Desktop.
Creating a C# Game Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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