Exemplo n.º 1
0
        internal void BroadcastInterChat(MessageSession session, InterChatMsg msg)
        {
            _interChatLock.DoRead(() =>
                {
                    var userName = "******";
                    if (_interChatUserMap.ContainsKey(session))
                        userName = _interChatUserMap[session];

                    BroadcastChatMsgWithNoLock(userName, msg.Message);
                });
        }
Exemplo n.º 2
0
        internal void BroadcastChatMsgWithNoLock(string userName, string message)
        {
            var msg = new InterChatMsg
                {
                    Name = userName,
                    Message = message,
                    Ticks = DateTime.Now.Ticks
                };

            _interChatMessageLock.DoWrite(() =>
                {
                    _lastMessages.Enqueue(msg);
                    while (_lastMessages.Count > PreserveMessageCount)
                        _lastMessages.Dequeue();
                });

            foreach (var eachSession in _interChatUserMap.Keys)
                eachSession.Send(msg);
        }
Exemplo n.º 3
0
        private void buttonSend_Click(object sender, EventArgs e)
        {
            var message = textMessage.Text.TrimEnd();

            if (string.IsNullOrWhiteSpace(message))
            {
                return;
            }

            try
            {
                var captured = false;
                if (message.StartsWith("."))
                {
                    if (HookCommand(message))
                    {
                        captured = true;
                    }
                }

                if (!captured)
                {
                    var msg = new InterChatMsg {
                        Message = message
                    };
                    _session.Send(msg);
                }

                textMessage.Text = "";
                textMessage.Focus();
            }
            catch (Exception exception)
            {
                ShowError("Cannot connect to mmo.pe.kr: {0}", exception.Message);
                textMessage.Enabled = false;
            }
        }