Exemplo n.º 1
0
        public ChatHtmlView(IChatStorage storage, IDictionary <string, BotConfig> bots)
        {
            ChatHandlers = new ChatHandler(storage, bots);

            if (!HttpListener.IsSupported)
            {
                return;
            }

            Listener     = new HttpListener();
            UserSessions = new Dictionary <string, ClientModel>();

            Prefixes = new string[]
            {
                Host + IndexPath,
                Host + LoginPath,
                Host + PostMessagePath,
                Host + DeleteMessagePath,
                Host + LogoutPath
            };

            foreach (var prefix in Prefixes)
            {
                Listener.Prefixes.Add(prefix);
            }
        }
Exemplo n.º 2
0
        public ChatConsoleView(IChatStorage storage, IDictionary <string, BotConfig> bots)
        {
            ChatHandlers  = new ChatHandler(storage, bots);
            ChatCmd       = new CommandsForChat();
            OnlineClients = new Dictionary <string, ClientModel>();

            var chatInfoBuilder = new StringBuilder(ChatInfoBase);

            foreach (var(botName, botConfig) in bots)
            {
                if (botConfig.Bot == null)
                {
                    throw new ArgumentNullException(nameof(bots));
                }

                chatInfoBuilder.AppendLine(botName + $" - {botConfig.Discription}");
            }

            ChatInfo = chatInfoBuilder.ToString();

            IsWorking = false;
        }
Exemplo n.º 3
0
 public ChatHandler(IChatStorage storage, IDictionary <string, BotConfig> bots)
 {
     ChatStorage = storage ?? throw new ArgumentNullException(nameof(storage));
     Bots        = bots ?? throw new ArgumentNullException(nameof(bots));
 }