public static void InitClient() { // Initialize all Players //ToDO: Create InitPlayers(); //Initialize the packet list to listen to from server ClientHandleData.InitPacketsFromServer(); //Connect to the Server ClientTcp.ConnectClientToServer(Constants.SERVER_IP, Constants.PORT); }
static void MainThread() { General.InitClient(); bool isChatting = true; //create chat user //create thanos //ClientTcp.CreateChatUser(cryptobaronsAppId, thanosUserEmail, thanosUsername); //create rony ClientTcp.CreateChatUser(cryptobaronsAppId, ronyUserEmail, ronysername); //get the chat history if any ClientTcp.ChatHistory(cryptobaronsAppId); while (isChatting) { string message = Console.ReadLine(); string chatJsonString = GetChatMessageJsonString(message); ClientTcp.SendMessage(chatJsonString); } }
static void MainThread() { General.InitClient(); bool isChatting = true; //create chat user //create thanos //ClientTcp.CreateChatUser(cryptobaronsAppId, thanosUserEmail, thanosUsername); //create rony ClientTcp.CreateChatUser(cryptobaronsAppId, ronyUserEmail, ronysername); //get the chat history if any ClientTcp.ChatHistory(cryptobaronsAppId); //get the type of chat the user wants to enter Text.WriteLine("Press 1 for general chat ", TextType.INFO); Text.WriteLine("Press 2 for Group chat ", TextType.INFO); //check validity of input bool isValid = int.TryParse(Console.ReadLine(), out int groupType); if (!isValid) { Text.WriteLine("Ehee!!!", TextType.WARNING); } string groupName = null; if (groupType == (int)GroupType.Private) { Text.WriteLine("Enter a valid group name like [email protected] ", TextType.INFO); groupName = Console.ReadLine(); Text.WriteLine("You are in the group chat module. Type your chat message...", TextType.INFO); } else if (groupType == (int)GroupType.General) { Text.WriteLine("You are in the general chat module. Type your chat message...", TextType.INFO); } while (isChatting) { string message = Console.ReadLine(); switch (message) { //Create group case "creategroup": ClientTcp.CreateGroup(cryptobaronsAppId, thanosGroupCreatorEmail); break; //Kill app case "kill": isChatting = false; ClientTcp.DisconnectFromServer(); break; case "joingroup": //let rony join thano's group ClientTcp.JoinGroup(cryptobaronsAppId, ronyUserEmail, thanosGroupCreatorEmail); break; //normal chat action default: string chatJsonString = GetChatMessageJsonString(message); if (groupType == (int)GroupType.General) { ClientTcp.SendMessage(chatJsonString); } else if (groupType == (int)GroupType.Private) { ClientTcp.SendGroupMessage(chatJsonString, groupName, ronyUserEmail); } break; } } }