Example #1
0
        private async Task CreateRoom(string mid)
        {
            try
            {
                wc = new WebClientClass();
                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.GetTimeSpen);
                url += "&sign=" + ApiHelper.GetSign_Android(url);
                string results = await wc.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;
            }
        }
Example #2
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            bg.Color       = ((SolidColorBrush)this.Frame.Tag).Color;
            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[];
            switch ((ChatsType)ob[1])
            {
            case ChatsType.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 ChatsType.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;
            }
        }