//method for finding endpoint of Makao engine host (Windows Service) //while current player's computer is hosting the service public static Uri GetHostEndpointWhileBeeingHost() { string IPaddress = MakaoGameClientServiceAddresObtainer.GetLocalIPAddress(); Uri endpoint; if (IPaddress != "0.0.0.0") { endpoint = new Uri(String.Concat(@"http://" + IPaddress + @":9500/MakaoGameHostWindowsService")); } else { endpoint = null; } return(endpoint); }
//constructor public MainWindow() { InitializeComponent(); //seting default user data (ID and login) playerDBID = 0; //inicialize datapleceholders SavedDataPlaceholder = new SavedDataClass(); //variables for logging unhandled exceptions AppDomain currentDomain = default; currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += GlobalUnhandledExceptionHandler; //Synchronization context SynchCont = SynchronizationContext.Current; //NLOG configutation methos string logsLocation = logLocationString + @"MakaoGameLogs" + DateTime.Now.ToString() + ".txt"; NLogConfigMethod(logsLocation); //setting directory of avatars used in game location avatarTempLocation = logLocationString.Substring(0, logLocationString.Length - 5) + @"AvatarsTemp\"; //reading saved data at the start of application ReadDataFromSettings(DefaultUserSettings.GetDefaultSettings()); //Avatar AssignAvatar(SavedDataPlaceholder.CurrentAvatarPicture); //assign background AssignMainWindowBackgroundGraphics(); //generate cliend endpoint Uri thisClientEndpoint = MakaoGameClientServiceAddresObtainer.GetClientServiceEndpoint(); //delete host endpoint - assign null makaoGameHostEndpoint = null; //deleting old logs in new task Task deleteOldLogs = new Task(new Action(DeleteOldLogFiles)); deleteOldLogs.Start(); //subscription of event - the event is fired, when host user deleted the room DataPlaceholder.TheRoomWasDeleted += DataPlaceholder_TheRoomWasDeleted; //subscription for an event of opening new window game command from game host service DataPlaceholder.NewGameStarted += DataPlaceholder_NewGameStarted; //changing status of application (host, client or none) ApplicationStatusChanged += MainWindow_ApplicationStatusChanged; //start client service StartMakaoGameClientService(); //assign rules window as null rulesWindow = null; //assign local IP address of endpoint of this devce UserIPString.Text = $"IP: {MakaoGameClientServiceAddresObtainer.GetLocalIPAddressString()}, "; }