Exemplo n.º 1
0
 /// <summary>
 /// 直接调用发送弹幕。
 /// </summary>
 /// <param name="text"></param>
 private void SendDanmu(string text)
 {
     Task.Run(async() =>
     {
         try
         {
             string result = await SendDanmaku.SendDanmakuAsync(PluginMain.RoomId.Value, text, LoginCenter.API.LoginCenterAPI.getCookies());
             if (result == null)
             {
                 PluginMain.Log("发送弹幕时网络错误");
             }
             else
             {
                 var j = JObject.Parse(result);
                 if (j["msg"].ToString() != string.Empty)
                 {
                     PluginMain.Log("发送弹幕时服务器返回:" + j["msg"].ToString());
                 }
             }
         }
         catch (Exception ex)
         {
             if (ex.GetType().FullName.Equals("LoginCenter.API.PluginNotAuthorizedException"))
             {
                 IsLogRedirectDanmaku = false;
             }
             else
             {
                 PluginMain.Log("弹幕发送错误 " + ex.ToString());
             }
         }
     });
 }
Exemplo n.º 2
0
        public static async Task <string> HttpPostAsync(string url, IDictionary <string, object> parameters = null, int timeout = 0, string userAgent = null, CookieContainer cookie = null, IDictionary <string, string> headers = null)
        {
            string formdata = string.Join("&", from p in parameters
                                          select string.Format("{0}={1}", p.Key, p.Value));

            return(await SendDanmaku.HttpPostAsync(url, formdata, timeout, userAgent, cookie, headers));
        }