Exemplo n.º 1
0
        private async Task CreateRoom(string mid)
        {
            try
            {
                string url = string.Format("http://message.bilibili.com/api/msg/query.double.room.do?access_key={0}&actionKey=appkey&appkey={1}&build=422000&data_type=1&mobi_app=android&platform=android&mid={2}&ts={3}000", ApiHelper.access_key, ApiHelper._appKey_Android, mid, ApiHelper.GetTimeSpan);
                url += "&sign=" + ApiHelper.GetSign_Android(url);
                string results = await WebClientClass.GetResults(new Uri(url));

                CreateRoomModel m = JsonConvert.DeserializeObject <CreateRoomModel>(results);
                if (m.code == 0)
                {
                    top_txt_Header.Text = m.data.room_name;
                    room = m.data;
                }
                else
                {
                    messShow.Show("创建聊天失败", 2000);
                }
            }
            catch (Exception ex)
            {
                messShow.Show("创建聊天失败\r\n" + ex.Message, 2000);
                //throw;
            }
        }
Exemplo n.º 2
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            messages       = new ObservableCollection <ChatModel>();
            timer          = new DispatcherTimer();
            timer.Interval = new TimeSpan(0, 0, 3);
            timer.Tick    += Timer_Tick;

            list_view.ItemsSource = messages;
            await Task.Delay(200);

            object[] ob = e.Parameter as object[];
            await GetCaptchaKey();

            switch ((ChatType)ob[1])
            {
            case ChatType.New:
                pr_Load.Visibility = Visibility.Visible;
                await CreateRoom(ob[0].ToString());

                if (room != null)
                {
                    await GetRoomMessage(room.rid);
                }
                timer.Start();
                pr_Load.Visibility = Visibility.Collapsed;
                break;

            case ChatType.Old:
                pr_Load.Visibility = Visibility.Visible;
                room = new CreateRoomModel()
                {
                    rid = ob[0].ToString()
                };
                await GetRoomMessage(room.rid);

                pr_Load.Visibility = Visibility.Collapsed;
                timer.Start();
                break;

            default:
                break;
            }
        }