Пример #1
0
        public void Message_Sent_Appends_To_Log_File()
        {
            var listener = new ChatListener(_mockFileSystem.Object, _mockClient.Object, _config);
            var msg = new MessageEventArgs(false, "#chan1", "NORBERT", "WELCOME");
            _mockClient.Raise(m => m.MessageSent += null, msg);

            const string file = "ChatLogs/#chan1.log";
            const string regex = @"^\[.+\]\s<NORBERT>\sWELCOME$";
            _mockFileSystem.Verify(m => m.AppendText(file, It.IsRegex(regex)));
        }
Пример #2
0
        public void Message_Received_Appends_To_Log_File()
        {
            var listener = new ChatListener(_mockFileSystem.Object, _mockClient.Object, _config);
            var msg = new MessageEventArgs(false, "#chan1", "JIM", "HELLO");
            _mockClient.Raise(m => m.MessageReceived += null, msg);

            const string file = "ChatLogs/#chan1.log";
            const string regex = @"^\[.+\]\s<JIM>\sHELLO$";
            _mockFileSystem.Verify(m => m.AppendText(file, It.IsRegex(regex)));
        }
Пример #3
0
        public void Message_Sent_Exception_Caught()
        {
            _mockFileSystem
                .Setup(m => m.AppendText(It.IsAny<string>(), It.IsAny<string>()))
                .Throws(new Exception());

            var listener = new ChatListener(_mockFileSystem.Object, _mockClient.Object, _config);
            var msg = new MessageEventArgs(false, "", "", "");
            _mockClient.Raise(m => m.MessageSent += null, msg);

            _mockFileSystem.Verify(m => m.AppendText(It.IsAny<string>(), It.IsAny<string>()));
        }
Пример #4
0
        /// <summary>
        /// Example of using components
        /// </summary>
        public ComponentsUsageExample()
        {
            var chatListenerComponent = new ChatListener();

            var welcomeText = new ShowTextAtBeginning("Welcome. Type -cmd for commands");

            var commandTrigger = chatListenerComponent.TriggerOnCommand("-cmd");

            commandTrigger.ShowText("The following commands are:");
            commandTrigger.ShowText("-help");

            var commandHelp = chatListenerComponent.TriggerOnCommand("-help");
            var helpShower  = new Hint().ShowForDuration("There are no help here! Muhahahaha", Units.SecondsToGameTicks(3));

            commandHelp.Execute(helpShower);
        }
Пример #5
0
        public void Invoke()
        {
            var serverListener = new ServerListener();
            var listener       = new ThreadStart(serverListener.Listen);
            var receiveClients = new Thread(listener);

            var displayClients = new DisplayClients();
            var display        = new Thread(() => { displayClients.Display(serverListener); });

            var chat       = new ChatListener();
            var chatThread = new Thread(() => { chat.StartChat(serverListener.Clients); });

            receiveClients.Start();
            display.Start();
            chatThread.Start();
            Console.ReadKey();
        }
        public void OnMessageReceived(BacktoryListener backtoryListener)
        {
            ChatListener chatListener = (ChatListener)backtoryListener;

            if (SenderId == null && GroupId == null)
            {
                chatListener.OnPushMessage(this);
            }
            else if (SenderId != null && GroupId == null)
            {
                chatListener.OnChatMessage(this);
            }
            else if (SenderId == null && GroupId != null)
            {
                chatListener.OnGroupPushMessage(this);
            }
            else if (SenderId != null && GroupId != null)
            {
                chatListener.OnGroupChatMessage(this);
            }
        }
        public void OnMessageReceived(BacktoryListener backtoryListener)
        {
            ChatListener chatListener = (ChatListener)backtoryListener;

            chatListener.OnChatGroupUserJoinedMessage(this);
        }
Пример #8
0
        void ChatListenerWork()
        {
            ChatListener listenChat = ChatListener.Instance;

            listenChat.Listener();
        }
        public void OnMessageReceived(BacktoryListener backtoryListener)
        {
            ChatListener chatListener = (ChatListener)backtoryListener;

            chatListener.OnChatInvitationMessage(this);
        }
Пример #10
0
 public void Loaded(IConfigLoader configLoader, IChatClient chatClient, 
     IHttpClient httpClient, IFileSystem fileSystem, IRandomiser randomiser)
 {
     var config = LoadConfig(configLoader, fileSystem);
     _chatListener = new ChatListener(fileSystem, chatClient, config);
 }
 public void SetChatListener(ChatListener chatListener)
 {
     backtoryConnectivityApi.setChatListener(chatListener);
 }
Пример #12
0
 public Config()
 {
     InitializeComponent();
     Reader = new ChatListener();
 }
Пример #13
0
 public void setChatListener(ChatListener chatListener)
 {
     this.chatListener = chatListener;
 }