Ejemplo n.º 1
0
        public ChatControl() : base()
        {
            AppEvents.On(AppEventType.OpenChat, OpenChat);

            LongPollServer.On(LPEventType.MessageAdded, async e =>
            {
                if (this._chat == null)
                {
                    return;
                }

                int msgID = (int)((long)((JValue)e.Data[0]).Value);

                Message msg = await Message.Get(msgID);

                if (msg.UserID == this._chat.Message.UserID || (msg.ChatID != 0 && msg.ChatID == this._chat.Message.ChatID))
                {
                    (new Thread(() =>
                    {
                        if (msg.Attachments != null && msg.Attachments.Length > 0)
                        {
                            foreach (Attachment a in msg.Attachments)
                            {
                                if (a.Type == "photo" && a.Photo != null)
                                {
                                    a.Photo.Load();
                                }
                            }
                        }

                        if (msg.CryptedNow && this._chat.CryptKey != null)
                        {
                            msg.Decrypt(this._chat.CryptKey);
                        }

                        msg.Author.GetPhoto();

                        this._messages.Add(msg);

                        this._loaded = true;

                        this._heightCalculated = false;

                        this.InvokeEx(t =>
                        {
                            t.Invalidate();
                        });
                    })).Start();
                }
            });
        }
Ejemplo n.º 2
0
Archivo: API.cs Proyecto: Strije/WinVK
        public static async Task <APISession> Auth(Func <String> authProvider)
        {
            String res = authProvider();

            if (res == null)
            {
                return(null);
            }

            await APISession.Parse(res);

            LongPollServer.Connect();

            return(Session);
        }