public void HandleMessage(byte[] message, Socket socket, NetworkStream stream)
        {
            IMessage decodedMessage;

            switch ((MessageIds)message[0])
            {
            case MessageIds.Heartbeat:
                decodedMessage = new HeartbeatMessage();
                decodedMessage.Unpack(message);
                TakeAction((HeartbeatMessage)decodedMessage, socket);
                break;

            case MessageIds.JoinChatroom:
                decodedMessage = new JoinChatroomMessage();
                decodedMessage.Unpack(message);
                TakeAction((JoinChatroomMessage)decodedMessage, socket, stream);
                break;

            case MessageIds.SendChat:
                decodedMessage = new SendChatMessage();
                decodedMessage.Unpack(message);
                TakeAction((SendChatMessage)decodedMessage);
                break;

            default:
                break;
            }
        }
Пример #2
0
 public PublicChat(int p_chat_id, List <string> p_chat_persons, SendChatMessage p_send_message
                   , RemoveChatFormManager p_remove, StartLeaveChatRequest p_start_leave_chat_request)
 {
     InitializeComponent();
     base.BaseConstruct(p_chat_id, TypeOfChat.Public, p_chat_persons, p_send_message, p_remove
                        , p_start_leave_chat_request, ChatPersons_list, MessagesList_TextBox);
 }
Пример #3
0
        public AllChats(SendChatMessage p_send_message, StartLeaveChatRequest p_start_leave_chat_request)
        {
            send_message             = p_send_message;
            start_leave_chat_request = p_start_leave_chat_request;

            public_chat_manager  = new Ma_PublicChatManager(new SendChatMessage(AllCh_SendChatMessage), new StartLeaveChatRequest(AllCh_StartLeaveChatRequest));
            private_chat_manager = new Ma_PrivateChatManager(new SendChatMessage(AllCh_SendChatMessage), new StartLeaveChatRequest(AllCh_StartLeaveChatRequest));
        }
Пример #4
0
        public async Task SendChatMessage([FromBody] SendChatMessage chatMessage)
        {
            if (chatMessage == null)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            await ChannelSession.Chat.SendMessage(chatMessage.Message, chatMessage.SendAsStreamer);
        }
        private void TakeAction(SendChatMessage message)
        {
            var newChat = new Chat()
            {
                Username = message.Username,
                Message  = message.Message
            };

            _chatQueue.Enqueue(newChat);
        }
Пример #6
0
        public static async Task SendMessageAsync(string message, bool sendAsStreamer)
        {
            var model = new SendChatMessage
            {
                Message        = message,
                SendAsStreamer = sendAsStreamer
            };

            await RestClient.PostAsync("chat/message", model);
        }
        private void SendChat()
        {
            var newMessage = new SendChatMessage()
            {
                Message  = Text,
                Username = _informationHolding.Username
            };

            _queueService.Enqueue(newMessage);
            Text = "";
        }
Пример #8
0
        public async Task SendMessageAsync(SendChatMessage message)
        {
            State.Participants ??= new HashSet <Guid>();
            State.Participants.Add(message.SenderUserId);
            var messageIndex = State.MessageCount + 1;
            var messageGrain = GrainFactory.GetGrain <IChatMessageGrain>(messageIndex, this.GetPrimaryKeyString());
            await messageGrain.UpdateMessageDetailsAsync(message, messageIndex);

            State.MessageCount++;
            Dirty = true;
        }
Пример #9
0
        public PrivateChat(int p_chat_id, string p_own_user_name, SendChatMessage p_send_message, RemoveChatFormManager p_remove
                           , StartLeaveChatRequest p_start_leave_chat_request)
        {
            InitializeComponent();

            List <string> temp_users_list = new List <string>();

            temp_users_list.Add(p_own_user_name);

            base.BaseConstruct(p_chat_id, TypeOfChat.Private, temp_users_list, p_send_message, p_remove, p_start_leave_chat_request, ChatPersons_list
                               , MessagesList_TextBox);
        }
Пример #10
0
        private void SendMessage()
        {
            if (characterName == null)
            {
                characterName = GetCharacterName();
            }

            var message = $"{characterName}: {inputField.text}";

            SendChatMessage?.Invoke(message);

            AddMessage(message);
        }
Пример #11
0
        public async Task SendChatMessage([FromBody] SendChatMessage chatMessage)
        {
            if (chatMessage == null)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.BadRequest)
                {
                    Content = new ObjectContent <Error>(new Error {
                        Message = "Unable to parse chat message from POST body."
                    }, new JsonMediaTypeFormatter(), "application/json"),
                    ReasonPhrase = "Invalid POST Body"
                };
                throw new HttpResponseException(resp);
            }

            await ChannelSession.Chat.SendMessage(chatMessage.Message, chatMessage.SendAsStreamer);
        }
Пример #12
0
        private void GetMessageFromClient(Connection con, SendChatMessage cmd)
        {
            if (con.ConnectionId > 0)
            {
                var    key = $"txtChat{con.ConnectionId}";
                string msg = (string)cmd.GetData()[0];
                this.Invoke(new Action(() =>
                {
                    var txt = con.TabPage.Controls.Find(key, false).FirstOrDefault();

                    if (txt != null)
                    {
                        txt.Text += $"{DateTime.Now.ToString()} {con.ClientIP}: \n{msg} \n\n";
                    }
                }));
            }
        }
Пример #13
0
        protected void BaseConstruct(int p_chat_id, TypeOfChat p_chat_type, List <string> p_chat_persons, SendChatMessage p_send_message
                                     , RemoveChatFormManager p_remove, StartLeaveChatRequest p_start_leave_chat_request, ListBox p_chat_persons_list_box
                                     , RichTextBox p_message_list_text_box)
        {
            chat_id      = p_chat_id;
            chat_type    = p_chat_type;
            chat_persons = p_chat_persons;

            send_message             = p_send_message;
            start_leave_chat_request = p_start_leave_chat_request;
            remove = p_remove;

            chat_persons_list_box  = p_chat_persons_list_box;
            messages_list_text_box = p_message_list_text_box;

            close_flag = false;
            chat_persons_list_box.Items.Clear();

            foreach (string t_user_name in p_chat_persons)
            {
                chat_persons_list_box.Items.Add(t_user_name);
            }
            this.Show();
        }
Пример #14
0
 public Ma_PublicChatManager(SendChatMessage p_send_message, StartLeaveChatRequest p_start_leave_chat_request)
 {
     base.BaseConstruct(TypeOfChat.Public, p_send_message, p_start_leave_chat_request);
     all_chats = new Dictionary <int, PublicChat>();
 }
Пример #15
0
 public void BaseConstruct(TypeOfChat p_chat_type, SendChatMessage p_send_message, StartLeaveChatRequest p_start_leave_chat_request)
 {
     chat_type                = p_chat_type;
     send_message             = p_send_message;
     start_leave_chat_request = p_start_leave_chat_request;
 }
Пример #16
0
 private bool onSendChatMessage(SendChatMessage evt)
 {
     Service.Get <INetworkServicesManager>().ChatService.SendMessage(evt.Message, (!(evt.SizzleClip == null)) ? evt.SizzleClip.Id : 0, evt.Quest.QuestId, evt.Quest.Objective);
     return(false);
 }