Пример #1
0
        /// <summary>
        /// Registers a IChatInterface.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="chatinterface"></param>
        /// <exception cref="ChatInterfacePermissionException">Thrown if the given name is already registered.</exception>
        /// <returns></returns>
        public bool RegisterInterface(string name, IChatInterface chatinterface)
        {
            if (this.interfaces.ContainsKey(name))
            {
                throw new ChatInterfacePermissionException(String.Format("The ChatInterface {0} is already registered.", name));
            }

            this.interfaces.Add(name, chatinterface);
            this.registrars.Add(name, Assembly.GetCallingAssembly());
            return(true);
        }
Пример #2
0
 protected MenuScreen(IChatInterface chatUi)
 {
     _chatUi = chatUi;
 }
Пример #3
0
 public MainMenuScreen(IChatInterface chatUi) : base(chatUi)
 {
 }
Пример #4
0
        public ChatInterfaceHelper(IChatInterface chatInterface)
        {
            this.chatInterface    = chatInterface;
            Startup.chatInterface = chatInterface;

            string host = System.Configuration.ConfigurationSettings.AppSettings["ChatInterfaceHost"];
            string port = System.Configuration.ConfigurationSettings.AppSettings["ChatInterfacePort"];

            Debug.Assert(port != null, "Please add a key to configuration as follows:" +
                         "<configuration>" +
                         "<runtime>" +
                         "<appSettings>" +
                         "<add key = \"ChatInterfaceHost\" value = \"localhost\" />" +
                         "<add key = \"ChatInterfacePort\" value = \"20000\" />" +
                         "</appSettings>" +
                         "</runtime>" +
                         "</configuration>");

            string url = "http://+:" + port;

            try
            {
                webapp = WebApp.Start <Startup>(url);
            }
            catch (Exception)
            {
                try
                {
                    url    = "http://" + host + ":" + port;
                    webapp = WebApp.Start <Startup>(url);
                }
                catch (Exception ex)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine($"ChatInterface failed to start on {host} at {port}\nException: " + ex.ToString());
                    Console.ResetColor();

                    return;
                }
            }

            signalRHub = GlobalHost.ConnectionManager.GetHubContext <ChatInterfaceSignalRHub>();
            Debug.Assert(signalRHub != null, "No chatInterface signalR running hub found");

            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.Write("[INFO] HTTP ChatInterface started at ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("{0}/ChatInterface", url);
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.Write("[INFO] HTTP ChatApi started at ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("{0}/ChatApi", url);
            Console.ResetColor();
            Console.WriteLine("[INFO] GET /ChatApi : Help menu");
            Console.WriteLine("[INFO] POST /ChatApi : Post an IUserResponse");

            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.Write("[INFO] HTTP MachineMessageApi started at ");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("{0}/MachineMessageApi", url);
            Console.ResetColor();
            Console.WriteLine("[INFO] GET /MachineMessageApi : Help menu");
            Console.WriteLine("[INFO] POST /MachineMessageApi : Post an IMachineMessage");
        }
Пример #5
0
 public ChatInterfaceSignalRHub(IChatInterface chatInterface)
 {
     this.chatInterface = chatInterface;
 }
Пример #6
0
 public ChatService(IChatInterface chatUi, IChatClient chatClient, ClientConfiguration configuration)
 {
     (_chatUi, _chatClient, _configuration) = (chatUi, chatClient, configuration);
 }
Пример #7
0
 public ChatAppController(IChatInterface newInterface, ChatApplicationContext newDb)
 {
     _Ichat   = newInterface;
     _context = newDb;
 }
Пример #8
0
 public ChatApplication(IChatInterface chat)
 {
     //Interface segregation
     this.talker   = chat;
     this.listener = chat;
 }