Example #1
0
        private void addMessageWithChecks(string text, bool isAction = false, bool isImportant = false, string username = null)
        {
            int index   = textContainer.Count + 1;
            var newLine = new ChatLine(new DummyMessage(text, isAction, isImportant, index, username));

            textContainer.Add(newLine);
        }
Example #2
0
    void OnRecvChatMessage(ChatLine line)
    {
        if (DraggedScrollView == true)
        {
            need_refresh = true;
            return;
        }

        var line_obj = ChatLinePrefabManager.GetNewObject <PopupChatLine>(ChatLineGrid.transform, Vector3.zero);

        line_obj.Init(line, new OnNicknameClickDelegate(OnClickNickname), new OnItemClickDelegate(OnClickItem));

        float v = (ChatLineScrollView.transform.localPosition.y - m_start_scrollview_transform_y);

        if (v < 1)
        {
            ChatLineScrollView.ResetPosition();
        }

        ChatLineGrid.Reposition();

        if (ChatLineGrid.GetChildList().Count > ChatLineManager.Instance.ChattingMaxLine)
        {
            ChatLinePrefabManager.Free(ChatLineGrid.GetChild(ChatLineGrid.GetChildList().Count - 1).gameObject);
        }
    }
Example #3
0
    void GuildJoinNotificationHandler(GuildJoinNotification packet)
    {
        if (packet.is_refuse == false)
        {
            GuildManager.Instance.SetGuildInfo(packet.guild_info);
            if (packet.user_info.account_idx == SHSavedData.AccountIdx)
            {
                JoinGuildChannel();
            }
            if (GameMain.Instance.CurrentGameMenu == GameMenu.Guild)
            {
                GameMain.Instance.GetCurrentMenu().UpdateMenu();
            }
            else
            {
                Network.Instance.SendGuildUpdate();
            }
        }

        if (IsListenGuild == true && packet.is_refuse == false)
        {
            ChatLine line = new ChatLine(packet);
            ChatLineManager.Instance.AddLine(line);
            m_ChatLabelCallback(line);
        }
    }
Example #4
0
    void GuildLeaveNotificationHandler(H2C.GuildLeaveNotification packet)
    {
        if (GuildManager.Instance.IsGuildJoined == false)
        {
            return;
        }
        if (GuildManager.Instance.GuildInfo.info.guild_idx != packet.guild_idx)
        {
            return;
        }

        if (packet.user_info.account_idx == SHSavedData.AccountIdx)
        {
            return;
        }

        if (IsListenGuild == true)
        {
            ChatLine line = new ChatLine(packet);
            ChatLineManager.Instance.AddLine(line);
            m_ChatLabelCallback(line);
        }


        GuildManager.Instance.RemoveMember(packet.user_info.account_idx);

        if (GameMain.Instance.CurrentGameMenu == GameMenu.Guild)
        {
            GameMain.Instance.GetCurrentMenu().UpdateMenu();
        }
    }
Example #5
0
    void OnNotifyLootRuneMessage(H2C.NotifyLootRune packet)
    {
        ChatLine line = new ChatLine(packet);

        ChatLineManager.Instance.AddLine(line);
        m_ChatLabelCallback(line);
    }
Example #6
0
    void OnSendMessage(H2C.SendMessage packet)
    {
        if (IsConnected == false)
        {
            return;
        }

        if (packet.msg_type == pe_MsgType.Normal && IsListenChannel == false)
        {
            return;
        }
        if (packet.msg_type == pe_MsgType.Guild && IsListenGuild == false)
        {
            return;
        }
        if (packet.msg_type == pe_MsgType.RecvWhisper && isListenWhisper == false)
        {
            return;
        }
        if (packet.msg_type == pe_MsgType.Yell && IsListenYell == false)
        {
            return;
        }

        ChatLine line = new ChatLine(packet);

        ChatLineManager.Instance.AddLine(line);

        m_ChatLabelCallback(line);
    }
Example #7
0
        public static void enqueueChatLine(String line)
        {
            ChatLine chat_line = new ChatLine(line);

            //Check if the message has a name
            if (line.Length > 3 && line.First() == '[')
            {
            int name_length = line.IndexOf(']');
            if (name_length > 0)
            {
                name_length = name_length - 1;
                String name = line.Substring(1, name_length);
                if (name == "Server")
                    chat_line.color = new Color(0.65f, 1.0f, 1.0f);
                else
                    chat_line.color = KLFVessel.generateActiveColor(name) * NAME_COLOR_SATURATION_FACTOR
                                      + Color.white * (1.0f-NAME_COLOR_SATURATION_FACTOR);
            }
            }

            chatLineQueue.Enqueue(chat_line);
            while (chatLineQueue.Count > MAX_CHAT_LINES)
            chatLineQueue.Dequeue();
            scrollPos.y += 100;
        }
Example #8
0
    void GuildAttendNotificationHandler(H2C.GuildAttendNotification packet)
    {
        if (GuildManager.Instance.IsGuildJoined == false)
        {
            return;
        }
        if (GuildManager.Instance.GuildInfo.info.guild_idx != packet.guild_idx)
        {
            return;
        }
        GuildManager.Instance.UpdateGuildMembers(packet.user_info.account_idx, packet.exp, true);

        if (IsListenGuild == true)
        {
            ChatLine line = new ChatLine(packet);
            ChatLineManager.Instance.AddLine(line);
            m_ChatLabelCallback(line);
        }

        GuildManager.Instance.SetGuildInfo(packet.guild_info);
        if (GameMain.Instance.CurrentGameMenu == GameMenu.Guild)
        {
            GameMain.Instance.GetCurrentMenu().UpdateMenu();
        }
    }
Example #9
0
        public static void enqueueChatLine(String line)
        {
            ChatLine chat_line = new ChatLine(line);

            //Check if the message has a name
            if (line.Length > 3 && line.First() == '[')
            {
                int name_length = line.IndexOf(']');
                if (name_length > 0)
                {
                    name_length = name_length - 1;
                    String name = line.Substring(1, name_length);
                    if (name == "Server")
                    {
                        chat_line.color = new Color(0.65f, 1.0f, 1.0f);
                    }
                    else
                    {
                        chat_line.color = KMPVessel.generateActiveColor(name) * NAME_COLOR_SATURATION_FACTOR
                                          + Color.white * (1.0f - NAME_COLOR_SATURATION_FACTOR);
                    }
                }
            }

            chatLineQueue.Enqueue(chat_line);
            while (chatLineQueue.Count > MAX_CHAT_LINES)
            {
                chatLineQueue.Dequeue();
            }
            scrollPos.y += 100;
        }
 public void Clear()
 {
     for (int i = 0; i < numChatLines; i++)
     {
         chatLine[i] = new ChatLine();
     }
 }
Example #11
0
 public void Fill(ChatLine chatLine)
 {
     text.text = string.Format("<color=#{2}>{0}:</color> <color=#{3}>{1}</color>",
                               chatLine.ChatterName,
                               chatLine.Message,
                               ColorUtility.ToHtmlStringRGBA(playerNameColor),
                               ColorUtility.ToHtmlStringRGBA(textColor));
 }
Example #12
0
 public void PushToBacklog(ChatLine chatLine)
 {
     if (_backlog.Count >= 100)
     {
         _backlog.RemoveAt(0);
     }
     _backlog.Add(chatLine);
 }
Example #13
0
        public void TestTimestampNull()
        {
            ChatLine testChatLine = new ChatLine("Test Line");

            testChatLine.Timestamp = DateTime.FromBinary(0);

            Assert.That(testChatLine.Timestamp, Is.EqualTo(MagicNumbers.MinSQLDateTime));
        }
Example #14
0
    public void Init(ChatLine line, PopupChat.OnNicknameClickDelegate nick_delegate, PopupChat.OnItemClickDelegate item_delegate)
    {
        nickname_delegate  = nick_delegate;
        this.item_delegate = item_delegate;

        this.line         = line;
        m_MainLabel.color = line.GetColor();
        m_MainLabel.text  = line.Msg;
    }
Example #15
0
        public void TestConstruction2()
        {
            DateTime timestamp    = DateTime.Now;
            ChatLine testChatLine = new ChatLine("Test Line", timestamp);

            Assert.That(testChatLine.Timestamp, Is.EqualTo(timestamp));

            Assert.That(testChatLine.ChatText, Is.EqualTo("Test Line"));
        }
Example #16
0
        public void TestTimestampSet()
        {
            ChatLine testChatLine = new ChatLine("Test Line");

            DateTime timestamp = DateTime.Now.AddMinutes(1);

            testChatLine.Timestamp = timestamp;

            Assert.That(testChatLine.Timestamp, Is.EqualTo(timestamp));
        }
Example #17
0
        public async Task Post([FromBody] ChatLine line)
        {
            await Repository.Insert(line);

            Lines.Value.Add(line);

            var context = GlobalHost.ConnectionManager.GetHubContext <PalanteerHub>();

            context.Clients.All.ChatLineAdded(line);
        }
Example #18
0
        public void TestConstruction1()
        {
            DateTime timestamp    = DateTime.Now.ToUniversalTime();
            ChatLine testChatLine = new ChatLine("Test Line");

            Assert.That(testChatLine.Timestamp, Is.GreaterThanOrEqualTo(timestamp));
            Assert.That(testChatLine.Timestamp, Is.LessThanOrEqualTo(DateTime.Now.ToUniversalTime()));

            Assert.That(testChatLine.ChatText, Is.EqualTo("Test Line"));
        }
Example #19
0
        public static void enqueueChatLine(String line)
        {
            ChatLine chat_line = new ChatLine(line);

            chatLineQueue.Enqueue(chat_line);
            while (chatLineQueue.Count > MAX_CHAT_LINES)
                chatLineQueue.Dequeue();

            //scrollPos.y += 100;
        }
Example #20
0
        public void TestTokenizeTextWithAutotranslate()
        {
            string chatText = "05,00,00,8020c0a0,00000018,00000018,0020,00,01,01,00,(Motenten) stuff for ï'Salvageï(";

            DateTime timestamp = DateTime.Now;
            ChatLine chatLine  = new ChatLine(chatText, timestamp);

            MessageLine msgLine = new MessageLine(chatLine);

            Assert.That(msgLine.TextOutput, Is.EqualTo("(Motenten) stuff for [Salvage]"));
        }
Example #21
0
        public void TestTokenizeTextWithItems()
        {
            string chatText = "55,00,00,80808010,0000265a,00002c51,0022,00,01,02,00,Lans uses a toolbag (shihei).1";

            DateTime timestamp = DateTime.Now;
            ChatLine chatLine  = new ChatLine(chatText, timestamp);

            MessageLine msgLine = new MessageLine(chatLine);

            Assert.That(msgLine.TextOutput, Is.EqualTo("Lans uses a toolbag (shihei)."));
        }
Example #22
0
        public void TestTokenizeTextWithKeyItems()
        {
            string chatText = "94,02,00,80808080,00000010,00000010,0033,00,01,00,00,Obtained key item: Healer's attire claim slip.1";

            DateTime timestamp = DateTime.Now;
            ChatLine chatLine  = new ChatLine(chatText, timestamp);

            MessageLine msgLine = new MessageLine(chatLine);

            Assert.That(msgLine.TextOutput, Is.EqualTo("Obtained key item: Healer's attire claim slip."));
        }
Example #23
0
        public void TestCorrectItemDrops()
        {
            string chatText = "79,00,00,80c0c050,000026cd,00002cd6,0035,00,01,02,00,yYou find a wind crystal on the Greater Colibri.1";

            DateTime timestamp = DateTime.Now;
            ChatLine chatLine  = new ChatLine(chatText, timestamp);

            MessageLine msgLine = new MessageLine(chatLine);

            Assert.That(msgLine.TextOutput, Is.EqualTo("You find a wind crystal on the Greater Colibri."));
        }
Example #24
0
        public void TestCorrectItemDistribution()
        {
            string chatText = "7f,00,00,80c0c050,0000277a,00002dac,0022,00,01,02,00,Motenten obtains a wind crystal.1";

            DateTime timestamp = DateTime.Now;
            ChatLine chatLine  = new ChatLine(chatText, timestamp);

            MessageLine msgLine = new MessageLine(chatLine);

            Assert.That(msgLine.TextOutput, Is.EqualTo("Motenten obtains a wind crystal."));
        }
 public LegacyChatMonitor()
 {
     showCount    = 10;
     numChatLines = 500;
     chatLength   = 600;
     chatLine     = new ChatLine[numChatLines];
     for (int i = 0; i < numChatLines; i++)
     {
         chatLine[i] = new ChatLine();
     }
 }
Example #26
0
        public void TestCorrectAssaultTimeLimit()
        {
            string chatText = "92,02,00,80808080,00006c88,00007d44,002b,00,01,00,00,?Time remaining: 5 minutes (Earth time).1";

            DateTime timestamp = DateTime.Now;
            ChatLine chatLine  = new ChatLine(chatText, timestamp);

            MessageLine msgLine = new MessageLine(chatLine);

            Assert.That(msgLine.TextOutput, Is.EqualTo("Time remaining: 5 minutes (Earth time)."));
        }
Example #27
0
        public void TestCorrectLimbusTimeLimit()
        {
            string chatText = "8d,00,00,60808010,00000023,00000023,0028,00,01,02,00,Moogle : Chaaange...job! Kupopopooo!1";

            DateTime timestamp = DateTime.Now;
            ChatLine chatLine  = new ChatLine(chatText, timestamp);

            MessageLine msgLine = new MessageLine(chatLine);

            Assert.That(msgLine.TextOutput, Is.EqualTo("Moogle : Chaaange...job! Kupopopooo!"));
        }
Example #28
0
    void FriendsRequestHandler(H2C.FriendsRequest packet)
    {
        if (packet.target_user.account_idx == SHSavedData.AccountIdx)
        {
            ChatLine line = new ChatLine(packet);
            ChatLineManager.Instance.AddLine(line);
            m_ChatLabelCallback(line);

            Network.Instance.NotifyMenu.is_friends_requested = true;
        }
    }
Example #29
0
        public static void enqueueChatLine(String line)
        {
            ChatLine chat_line = new ChatLine(line);

            chatLineQueue.Enqueue(chat_line);
            while (chatLineQueue.Count > MAX_CHAT_LINES)
            {
                chatLineQueue.Dequeue();
            }

            //scrollPos.y += 100;
        }
Example #30
0
    void WhisperMessageSendAck(C2H.WhisperMessageSendAck packet)
    {
        if (IsConnected == false)
        {
            return;
        }

        ChatLine line = new ChatLine(packet);

        ChatLineManager.Instance.AddLine(line);
        m_ChatLabelCallback(line);
    }
Example #31
0
        /// <summary>
        /// Broadcasts a chat message to all users
        /// </summary>
        /// <param name="message"></param>
        public void Broadcast(string message)
        {
            var chatLine = new ChatLine
            {
                mPlayer     = -1,
                mPlayerName = "", // TODO: Test if prefix can be left out
                mText       = message,
                mType       = ChatLine.Type.Normal
            };

            NetworkManager.instance.QueueChatMessage(chatLine);
            ServerConsole.DebugLog($"[SERVER] {message}");
        }
Example #32
0
 public static void AddLine(string name, string text)
 {
     if (singleton != null)
     {
         GameObject obj2 = (GameObject)Object.Instantiate(singleton.chatLine);
         if (obj2 != null)
         {
             ChatLine component = obj2.GetComponent <ChatLine>();
             component.Setup(name + ":", text);
             singleton.chatContainer.AddControl(component.GetComponent <dfPanel>());
         }
     }
 }
Example #33
0
        public static void enqueueChatLine(String line)
        {
            Color lineColor = Color.yellow;
            bool colorSet = false;
            foreach (String singleLine in line.Split('\n'))
            {
                string choppedLine = "";
                foreach (String word in singleLine.Split(' '))
                {
                    //if (GUI.skin.GetStyle("Box").CalcSize(new GUIContent(choppedLine + word)).x > chatboxWidth)
                    if (choppedLine.Length + word.Length > chatboxWidth / 7) //Kludgy but works relatively reliably
                    {
                        ChatLine chat_line = new ChatLine(choppedLine.Substring(0,choppedLine.Length-1));
                        if (!colorSet)
                        {
                            lineColor = chat_line.color;
                            colorSet = true;
                        }
                        else
                        {
                            chat_line.color = lineColor;
                        }
                        chatLineQueue.Enqueue(chat_line);
                        choppedLine = word + " ";
                    }
                    else
                    {
                        choppedLine += word + " ";
                    }
                }
                if (choppedLine.Length > 0)
                {
                    ChatLine chat_line = new ChatLine(choppedLine.Substring(0,choppedLine.Length-1));
                    if (colorSet)
                    {
                        chat_line.color = lineColor;
                    }
                    chatLineQueue.Enqueue(chat_line);
                }
            }
            while (chatLineQueue.Count > MAX_CHAT_LINES)
                chatLineQueue.Dequeue();

            //scrollPos.y += 100;
        }
Example #34
0
		void EnterLine(ChatLine data)
		{
			data.Id = Interlocked.Increment(ref id);
			data.Time = DateTime.Now;

			if (lines.Count > 100)
			{
				ChatLine old;
				lines.TryDequeue(out old);
				foreach (var win in windows)
					win.Key.RemoveLine(old);
			}

			lines.Enqueue(data);
			
			foreach (var win in windows)
				win.Key.AddLine(data);
		}
Example #35
0
		void AddLine(ChatLine line)
		{
			store.Set(line);
			if (!registered)
			{
				registered = true;
				if (windows.Count == 1)
					EnterLine(new ChatLine
					{
						Name = "Dextop",
						Text = String.Format("Hi {0}, unfortunately you're alone here.", line.Name)
					});
				else
					EnterLine(new ChatLine
					{
						Name = "Dextop",
						Text = String.Format("Hi {0}, there are {1} people in the room.", line.Name, windows.Count)
					});
			}
		}
Example #36
0
 public static void Line(String line)
 {
     ChatLine chatLine = new ChatLine(line);
     if (line.Length > 3 && line.First() == '[')
     {//Check if the message starts with name
         int nameLength = line.IndexOf(']');
         if (nameLength > 0)
         {//render name colour
             nameLength = nameLength - 1;
             String name = line.Substring(1, nameLength);
             if (name == "Server")
                 chatLine.Color = new Color(0.65f, 1.0f, 1.0f);
             else
                 chatLine.Color =
                     KLFVessel.GenerateActiveColor(name) * NameColorSaturationFactor + Color.white * (1.0f - NameColorSaturationFactor);
         }
     }
     ChatLineQueue.Enqueue(chatLine);
     while (ChatLineQueue.Count > MaxChatLines)
         ChatLineQueue.Dequeue();
     ScrollPos.y += 100;
 }
Example #37
0
 /// <summary>
 /// Send a message as the bot. Should call base.
 /// </summary>
 public virtual void Send(string str)
 {
     var line = new ChatLine(Util.GetCurrentTimestamp(), RoomInfo.ShortName, "Steam", Program.Settings.PersonaName, "0", "", str, false);
     SendLine(line);
 }
Example #38
0
 /// <summary>
 /// Add a chat line to the chat history of a hub
 /// if the chat history max length is != 0
 /// it will automatically remove the first lines added if needed
 /// (FIFO buffer)
 /// </summary>
 /// <param name="username">the user who wrote the chat message</param>
 /// <param name="message">the message contents</param>
 private void AddChatToHistory(string username, string message)
 {
     if (chat_history_max_length != 0)
     {//using max history -> delete first line added to list
         if (chat_history.Count > chat_history_max_length)
             chat_history.RemoveAt(0);
     }
     ChatLine cline = new ChatLine(username, message);
     chat_history.Add(cline);
     if (MainChatLineReceived != null)
         MainChatLineReceived(this,cline);
 }
Example #39
0
        /// <summary>
        /// Called when somebody sends a message.
        /// </summary>
        public void SendMessage(Connection connection, string message)
        {
            if (connection.Session == null) // should never happen
                return;

            var roomName = RoomInfo.ShortName;
            var account = connection.Session.Account;

            if (!message.StartsWith("//") && Command.Handle(new CommandTarget(connection, roomName), message, "/"))
                return;

            if (!message.StartsWith("~~") && Command.Handle(new CommandTarget(connection, roomName), message, "~"))
                return;

            if (message.StartsWith("//") || message.StartsWith("~~"))
                message = message.Substring(1);

            if (IsBanned(account.Name))
            {
                connection.SendSysMessage("You are banned from this room.");
                return;
            }

            var userName = account.Name;
            var userId = account.Id.ToString("D");
            var userStyle = account.EnabledStyle;
            var line = new ChatLine(Util.GetCurrentTimestamp(), roomName, "RohBot", userName, userId, userStyle, message, false);
            SendLine(line);
        }
Example #40
0
            internal ChatLine GetCurrentLine(LineSettings lineSettings)
            {
                ChatLine line = null;
                /*
                new ChatLine() {
                    Color = Color.Empty,
                    NowDate = DateTime.Now,
                    Now = "[" + DateTime.Now.ToString("HH:mm:ss") + "] ",
                    Text = String.Empty,
                    Type = ChatMode.Error
                };*/

                // update our local cache of chat lines
                Update();

                // if we have a new line
                if (NumberOfUnparsedLines() != 0)
                {
                    line = new ChatLine();
                    // get the next chat line
                    line.Type = _ChatLog.Peek().LineType;
                    line.Text = _ChatLog.Peek().LineText;
                    line.Index = _ChatLog.Peek().Index;
                    line.RawString = _ChatLog.Peek().RawString;

                    try
                    {
                        line.Color = ColorTranslator.FromHtml("#" + _ChatLog.Peek().LineColor.Trim('#'));
                    }
                    catch
                    {
                        line.Color = _ChatLog.Peek().ActualLineColor;
                    }
                    // if user wanted to strip off color characters, do so
                    line.Text = FFACE.ChatTools.CleanLine(line.Text, lineSettings);

                } // @ if (!NumberOfUnparsedLines().Equals(0))

                return line;
            }
Example #41
0
        private void HandleMessage(SteamChat chat, SteamPersona user, string message)
        {
            _lastMessage.Restart();

            var senderName = user.DisplayName;
            var senderId = user.Id.ConvertToUInt64().ToString("D");
            var inGame = user.Playing != null && user.Playing.ToUInt64() != 0;

            var line = new ChatLine(Util.GetCurrentTimestamp(), RoomInfo.ShortName, "Steam", senderName, senderId, "", message, inGame);
            SendLine(line);

            Command.Handle(new CommandTarget(this, user.Id), message, "~");
        }
Example #42
0
 private void SendPersistentSysMessage(string str)
 {
     var line = new ChatLine(Util.GetCurrentTimestamp(), RoomInfo.ShortName, "Steam", Program.Settings.PersonaName, "0", "", str, false);
     base.SendLine(line);
 }
Example #43
0
        private static void PrintChatLine(ChatLine chatLine)
        {
            if (_chatLines.Count >= MaxChatRows)
            {
                // Delete first entry and move everything up, then add entry to last position.
                _chatLines.Remove(_chatLines[0]);
                for (int i = 1; i < _chatLines.Count; i++)
                {
                    _chatLines[i - 1] = _chatLines[i];
                }

                _chatLines.Add(chatLine);
            }
            else
            {
                _chatLines.Add(chatLine);
            }
        }
Example #44
0
 public static void AddMessage(ChatLine line)
 {
     _toSendChatLines.Add(line);
 }
Example #45
0
        /// <summary>
        /// Interpret a single command 
        /// </summary>
        /// <param name="received_command">the command to interpret</param>
        private void InterpretCommand(string received_command)
        {
            int command_end = received_command.IndexOf(" ");
            if (command_end == -1) command_end = received_command.Length;

            if (command_end != -1)
            {
                string parameter = "";
                string[] parameters ={ };
                string command = received_command.Substring(1);
                if (command_end != received_command.Length)
                {
                    command = received_command.Substring(1, command_end - 1);
                    parameter = received_command.Substring(command_end + 1);
                    parameters = parameter.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    //Console.WriteLine("Command: '" + command + "' ,Parameter(" + parameters.Length + "): '" + parameter + "'");
                }
                switch (command)
                {
                    case "HubName" :
                        //Console.WriteLine("Hubname Command received: " + parameter);
                        name = parameter;
                        //fire nameChange event
                        break;

                    case "Hello" :
                        //Console.WriteLine("Hello Command received: " + parameters[0]);
                        if (!is_logged_in)
                        {
                            is_logged_in = true;
                            SendCommand("Version", my_version);
                            SendCommand("GetNickList");
                            SendMyInfo();
                            //Console.WriteLine("Logged in Hub: "+name);
                            try
                            {
                                if (LoggedIn != null)
                                    LoggedIn(this);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("Exception in LoggedIn: " + ex.Message);
                            }
                        }
                        else
                        {//new user announced by server
                            //Console.WriteLine("User "+parameters[0]+" has joined Hub: "+name);
                            UserListAdd(parameters[0]);
                        }
                        break;

                    case "Quit":
                        //Console.WriteLine("User "+parameters[0]+" has left Hub: "+name);
                        UserListRemove(parameters[0]);
                        break;

                    case "NickList":
                        Console.WriteLine("NickList Message received.");
                        UserListClear();
                        string[] temp_users = parameters[0].Split("$$".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        foreach (string temp_user in temp_users)
                        {
                            UserListAdd(temp_user);
                        }
                        break;

                    case "OpList":
                        op_list.Clear();
                        string[] temp_ops = parameters[0].Split("$$".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        foreach (string temp_op in temp_ops)
                        {
                            op_list.Add(temp_op);
                        }
                        break;

                    case "ConnectToMe":
                            try
                            {
                                string peer_address = "";
                                if (parameters.Length == 2)
                                {
                                    peer_address = parameters[1];
                                }
                                else if (parameters.Length == 3)
                                {
                                    peer_address = parameters[2];
                                }
                                else break;
                                Peer peer = new Peer(peer_address); //add username also, to counter possible network attacks
                                if (ConnectToMeReceived != null)
                                    ConnectToMeReceived(this, peer);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("Exception in ConnectToMe EventHandler: " + ex.Message);
                            }
                        break;

                    case "RevConnectToMe":
                        SendConnectToMe(parameters[0]);
                        break;

                    case "HubTopic":
                        //topic = parameters[0];
                        topic = parameter;
                        break;

                    case "UserCommand":
                        //Console.WriteLine("User Command received: "+parameter);
                        //TODO support user context menu entries
                        break;

                    case "Search":
                        //Console.WriteLine("Search Command received: "+parameter);
                        SearchParameters search = new SearchParameters();
                        if(parameters[0].StartsWith("Hub:"))
                        {
                            search.mode = ConnectionMode.Passive;
                            int username_start = parameters[0].IndexOf(":");
                            if (username_start == -1 || username_start + 1 > parameters[0].Length) break;
                            search.username = parameters[0].Substring(username_start + 1);
                        }
                        else
                        {
                            search.mode = ConnectionMode.Active;
                            int port_start = parameters[0].IndexOf(":");
                            if (port_start == -1 || port_start + 1 > parameters[0].Length) break;
                            search.ip = parameters[0].Substring(0,port_start);
                            try
                            {
                                search.port = int.Parse(parameters[0].Substring(port_start + 1));
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("error parsing port in search: " + ex.Message);
                                break;
                            }
                        }

                        char[] seps ={ '?' };
                        string[] search_parameters = parameters[1].Split(seps,StringSplitOptions.RemoveEmptyEntries);
                        if (search_parameters.Length < 4) break;
                        if (search_parameters[0] == "F")
                            search.size_restricted = false;
                        else search.size_restricted = true;
                        if (search_parameters[1] == "F")
                            search.is_max_size = false;
                        else search.is_max_size = true;
                        try
                        {
                            search.size = long.Parse(search_parameters[2]);
                            search.file_type = (SearchFileType)int.Parse(search_parameters[3]);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("error parsing ints in search: " + ex.Message);
                            break;
                        }
                        if (search_parameters[4].StartsWith("TTH:") && search.file_type == SearchFileType.tth && search_parameters[4].Length > 4)
                            search.tth = search_parameters[4].Substring(4);
                        else search.search_string = search_parameters[4];
                        //TODO above throws exceptions
                        if (SearchReceived != null)
                            SearchReceived(this,search);
                        break;

                    case "Supports":
                        supports = (string[])parameters.Clone();
                        break;

                    case "UserIP":
                        Console.WriteLine("UserIP Message received: " + parameter);
                        break;

                    case "MCTo:":
                        string mcto_username = parameters[1].Substring(1); //to skip the leading $
                        int mcto_message_start = parameters[0].Length + parameters[1].Length + 2;
                        if (mcto_message_start < parameter.Length)
                        {
                            string mcto_message = parameter.Substring(mcto_message_start);
                            AddChatToHistory(mcto_username, mcto_message);
                        }
                        break;

                    case "To:":
                        //Console.WriteLine("Private Message received: " + parameter);
                        string to_username = parameters[2];
                        int to_message_start = parameters[0].Length + parameters[1].Length + parameters[2].Length + parameters[3].Length + 4;
                        if (to_message_start < parameter.Length )
                        {
                            string to_message = parameter.Substring(to_message_start);
                            ChatLine to_message_line = new ChatLine(to_username, to_message);
                            if (PrivateChatLineReceived != null)
                                PrivateChatLineReceived(this, to_message_line);
                        }
                        break;

                    case "SR":
                        //Console.WriteLine("Search result received: " + parameter);
                        SearchResults.SearchResult result = new SearchResults.SearchResult();
                        result.ResultLine = parameter;
                        try
                        {
                            if (SearchResultReceived != null)
                                SearchResultReceived(this, result);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Exception in event handler: " + ex.Message);
                        }

                        break;

                    case "LogedIn":
                        Console.WriteLine("LogedIn Message received: " + parameter);
                        //what the hell is this and who forgot to take some english lessons ?
                        break;
                    case "MyINFO":
                        //Console.WriteLine("MyINFO Message received: " + parameter);
                        UserListAdd(parameters[1]);
                        break;
                    case "GetPass":
                        Console.WriteLine("GetPass Message received: " + parameter);
                        if (PasswordRequested != null)
                        {
                            string password = PasswordRequested(this);
                            SendPassword(password);
                        }
                        break;

                    case "ForceMove":
                        //Console.WriteLine("FORCE MOVE NOT IMPLEMENTED");
                        if (MoveForced != null)
                        {
                            Hub dst_hub = this.Copy();
                            MoveForced(this, dst_hub);
                        }
                        break;

                    case "ValidateDenide":
                        Console.WriteLine("Nick: "+parameters[0]+" on Hub: " + name + " is already in use.");
                        break;

                    case "HubIsFull":
                        Console.WriteLine("Hub: " + name + " is full.");
                        Disconnect();
                        break;

                    case "Lock" :
                        //Console.WriteLine("Lock Command received: "+parameter);
                        //int key_end = parameter.IndexOf(" ");
                        //if (key_end != -1)
                        //{
                            //string key = parameter.Substring(0, key_end);
                        if (parameters.Length > 1)
                        {
                            string key = parameters[0];
                            //Console.WriteLine("Key: " + key);
                            if (key.StartsWith("EXTENDEDPROTOCOL"))
                            {
                                is_extended_protocol = true;
                                //Console.WriteLine("Hub is using the dc++ protocol enhancements.");
                                //SendCommand("Supports", "UserCommand NoGetINFO NoHello UserIP2 TTHSearch ZPipe0 GetZBlock ");
                                SendCommand("Supports", "UserCommand TTHSearch NoGetINFO NoHello ");
                            }

                            //string decoded_key = MyLockToKey(key);
                            string decoded_key = L2K(key);
                            //Console.WriteLine("Decoded key: " + decoded_key);
                            SendCommand("Key" , decoded_key);
                            SendCommand("ValidateNick", nick);

                        }
                        break;
                    default:
                        Console.WriteLine("Unknown Command received: " + command + ", Parameter: " + parameter);
                        break;
                }
            }
            else Console.WriteLine("Error interpreting command: " + received_command);
        }
Example #46
0
		void RemoveLine(ChatLine data)
		{
			store.Remove(data);
		}
Example #47
0
            public ChatLine GetNextLine()
            {
                var message = _eliteApi.Chat.GetNextChatLine();

                if (message == null) return null;

                var chatLine = new ChatLine
                {
                    Color = message.ChatColor,
                    Now = message.Timestamp.ToShortTimeString(),
                    RawString = message.RawText,
                    Text = message.Text,
                    Type = (ChatMode) message.ChatType
                };

                return chatLine;
            }
Example #48
0
        /// <summary>
        /// Called when somebody sends a message.
        /// </summary>
        public virtual void SendMessage(Connection connection, string message)
        {
            if (connection.Session == null) // should never happen
                return;

            var roomName = RoomInfo.ShortName;
            var account = connection.Session.Account;

            if (IsBanned(account.Name))
            {
                connection.SendSysMessage("You are banned from this room.");
                return;
            }

            var userName = account.Name;
            var userId = account.Id.ToString("D");
            var userStyle = account.EnabledStyle;
            var line = new ChatLine(Util.GetCurrentTimestamp(), roomName, "RohBot", userName, userId, userStyle, message, false);
            SendLine(line);
        }
Example #49
0
        /// <summary>
        /// Called when somebody sends a message.
        /// </summary>
        public void SendMessage(Session session, string message)
        {
            if (!message.StartsWith("//") && Command.Handle(new CommandTarget(session), message, "/"))
                return;

            if (!message.StartsWith("~~") && Command.Handle(new CommandTarget(session), message, "~"))
                return;

            if (message.StartsWith("//") || message.StartsWith("~~"))
                message = message.Substring(1);

            if (IsBanned(session.Account.Name))
            {
                session.SendSysMessage("You are banned from this room.");
                return;
            }

            var roomName = RoomInfo.ShortName;
            var userName = session.Account.Name;
            var userId = session.Account.Id.ToString();
            var userStyle = session.Account.EnabledStyle;
            var line = new ChatLine(Util.GetCurrentUnixTimestamp(), roomName, "RohBot", userName, userId, userStyle, message, false);
            SendLine(line);
        }