/// <summary> /// Handle a client first connecting /// </summary> /// <returns></returns> public Guid RegisterApplicationStartup(String IPAddress, int Port, String MachineName) { MM_Notification.WriteLine(ConsoleColor.Cyan, "New connection from {0} {1} on port {2}", IPAddress, MachineName, Port); Guid UserGUID = Guid.NewGuid(); this.User = new MM_User() { UserId = UserGUID, UserName = "******", LoggedOnTime = DateTime.Now, IPAddress = IPAddress, MachineName = MachineName, Port = Port, LastReceivedMessage = DateTime.Now }; User.LastReceivedMessage = DateTime.Now; MM_Server.AddUser(this); return(UserGUID); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { //If we're in console mode, display the console view. Otherwise, start the service mode. if (Environment.UserInteractive) { // Console.SetWindowSize(132, 43); MM_Server.StartServer(); } else { ServiceBase.Run(new MM_Service()); } }
/// <summary> /// Send a message to our client /// </summary> /// <param name="SystemGuid"></param> /// <param name="ProcedureName"></param> /// <param name="Parameters"></param> public static void SendMessage(Guid SystemGuid, String ProcedureName, params object[] Parameters) { //First, try and find our client MM_WCF_Interface FoundConnection; MethodInfo FoundMethod; if (MM_Server.FindUser(SystemGuid, out FoundConnection)) { if (FoundConnection.ConversationHandler != null) { if ((FoundMethod = typeof(IMM_ConversationMessage_Types).GetMethod(ProcedureName)) != null) { new SendMessageDelegate(SendMessageInternal).BeginInvoke(FoundMethod, FoundConnection, Parameters, MessageSentCompletion, FoundConnection); } } } }
/// <summary> /// Handle a user's logout /// </summary> /// <param name="UserGuid"></param> /// <returns></returns> public bool HandleUserLogout(Guid UserGuid) { User.LastReceivedMessage = DateTime.Now; MM_Server.RemoveUser(this); return(true); }
/// <summary> /// Handle our channel closing /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void Channel_Closed(object sender, EventArgs e) { MM_Server.RemoveAdministrator(this); }
/// <summary> /// Register our callback of admin push /// </summary> /// <param name="VersionNumber"></param> /// <returns></returns> public bool RegisterCallback(string VersionNumber = "Unknown") { ConversationHandler = OperationContext.Current.GetCallbackChannel <IMM_AdministratorMessage_Types>(); MM_Server.AddAdministrator(this); return(true); }
/// <summary> /// Handle the stress testing of our clients /// </summary> /// <param name="Active"></param> /// <returns></returns> public bool SetServerClientStressTest(bool Active) { MM_Server.StressTestClients(Active); return(true); }