public MessageAdapter(ChatActivity chatActivity, List <Messages> messagesList, string userName, int width)
 {
     this.chatActivity = chatActivity;
     this.messagesList = messagesList;
     this.userName     = userName;
     this.width        = width;
 }
        public async Task <IChatState <TModel> > HandleActivity(ChatActivity activity, ChatContext <TModel> context)
        {
            var textMessage = activity.CreateActivity(GetType().Name);
            await context.SendAsync(textMessage);

            return(null);
        }
        public async Task <IChatState <TModel> > HandleActivity(ChatActivity activity, ChatContext <TModel> context)
        {
            var textMessage = activity.CreateActivity(GetType().Name);

            await context.SendAsync(textMessage);

            return(provider.GetRequiredService <TestState3 <TModel> >());
        }
Beispiel #4
0
        public async Task <TelegramActivity> ConvertBack(ChatActivity model)
        {
            if (model is TextActivity textMessage)
            {
                return(mapper.Map <TelegramActivity>(textMessage));
            }

            throw new NotSupportedException("Не поддерживается конвертирование");
        }
        private async void OnConversation(Object[] obj)
        {
            Log.Error("WebSocket", "OnConversation");
            var    data = (JSONObject)obj[0];
            string room;
            string message;
            string username;

            try {
                username = data.GetString("username");
                message  = data.GetString("message");
                room     = data.GetString("room");
            } catch (JSONException e) {
                Log.Error("message send error: ", e.Message);
                return;
            }

            try {
                if (!string.IsNullOrEmpty(message))
                {
                    await _conversationsRecords.Insert(new ConversationsRecords {
                        Message         = message,
                        Room            = room,
                        MessageDateTime = DateTime.Now,
                        MessageType     = 1
                    });
                }
                Utils.CreateChannels("ConversationChannel", "ConversationChannel");
                //CAZUL 1 chat simplu intre 2 useri
                bool c = Utils.IsActivityRunning(Class.FromType(typeof(ChatActivity)));
                if (c && ChatActivity.RoomName.Equals(room))
                {
                    Log.Error("Caz 1", "*********************");
                    ChatActivity.AddMessage(message, ChatModel.TypeMessage);
                }
                //CAZUL 2 user offline primeste chat
                else if (!c && ChatActivity.RoomName.Equals(room))
                {
                    Log.Error("Caz 2", "*********************");

                    Notification nb = Utils.CreateChatNotification(username, message, username, room, _context, 3, "Vizualizare");

                    var ids = room.Split(':');
                    Utils.GetManager().Notify(ids[0] == Utils.GetDefaults("Id") ? int.Parse(ids[1]) : int.Parse(ids[0]), nb);
                }
                //CAZUL 3 user 1, user 2 converseaza, al3lea se baga in seama
                else if (!ChatActivity.RoomName.Equals(room))
                {
                    Log.Error("Caz 3", "*********************");
                    Notification nb  = Utils.CreateChatNotification(username, message, username, room, _context, 3, "Vizualizare");
                    var          ids = room.Split(':');
                    Utils.GetManager().Notify(ids[0] == Utils.GetDefaults("Id") ? int.Parse(ids[1]) : int.Parse(ids[0]), nb);
                }
            } catch (Exception ex) {
                Log.Error("Eroare da nu ii bai", ex.ToString());
            }
        }
Beispiel #6
0
        public async Task <IChatState <TModel> > HandleActivity(ChatActivity activity, ChatContext <TModel> context)
        {
            await context.SendAsync(new TextActivity
            {
                Chat = activity.Chat,
                Text = $"Count: {Counter++}"
            });

            return(this);
        }
        public static async Task SendTextAsync <TModel>(this ChatContext <TModel> context, ChatActivity activity, string text)
        {
            if (activity is TextActivity textActivity)
            {
                var message = textActivity.Copy();
                message.Text = text;

                await context.SendAsync(message);
            }

            throw new ArgumentException("Activity is not TextActivity");
        }
Beispiel #8
0
        public async Task SendAsync(ChatActivity activity)
        {
            var converted = await converter.ConvertBack(activity);

            await connector.SendActivity(converted);
        }
 public ListViewAdapter(ChatActivity chatActivity, List <MessageContent> list)
 {
     _listAdapter  = list;
     _chatActivity = chatActivity;
 }
Beispiel #10
0
        public async Task <IChatState <TModel> > HandleActivity(ChatActivity activity, ChatContext <TModel> context)
        {
            await context.SendAsync(activity);

            return(this);
        }