public override void OnHttpStatusOK(QQHttpResponse response) { //{"retcode":0,"result":{"uin":236557647,"cip":1991953329,"index":1075,"port":51494,"status":"online","vfwebqq":"41778677efd86bae2ed575eea02349046a36f3f53298a34b97d75297ec1e67f6ee5226429daa6aa7","psessionid":"8368046764001d636f6e6e7365727665725f77656271714031302e3133332e342e31373200005b9200000549016e04004f95190e6d0000000a4052347371696a62724f6d0000002841778677efd86bae2ed575eea02349046a36f3f53298a34b97d75297ec1e67f6ee5226429daa6aa7","user_state":0,"f":0}} var str = response.GetResponseString(); var json = JObject.Parse(str); var session = Context.Session; var account = Context.Account; var retcode = json["retcode"].ToString(); if (retcode == "0") { var ret = json["result"].ToObject <JObject>(); account.Uin = ret["uin"].ToObject <long>(); account.QQ = ret["uin"].ToObject <long>(); session.SessionId = ret["psessionid"].ToString(); // session.Vfwebqq = ret["vfwebqq"].ToString(); account.Status = QQStatus.ValueOfRaw(ret["status"].ToString()); session.State = QQSessionState.Online; session.Index = ret["index"].ToObject <int>(); session.Port = ret["port"].ToObject <int>(); NotifyActionEvent(QQActionEventType.EvtOK, null); } else { //var msg = $"errmsg: {json["errmsg"] ?? ""}, retcode: {retcode}"; //NotifyActionEvent(QQActionEventType.EVT_ERROR, new QQException(QQErrorCode.INVALID_RESPONSE, msg)); //TODO .. throw new QQException(QQErrorCode.UnexpectedResponse, str); } }
public override void OnHttpStatusOK(QQHttpResponse response) { var rex = new Regex(QQConstants.REGXP_LOGIN); var m = rex.Match(response.GetResponseString()); if (m.Success) { var ret = m.Groups[1].Value; switch (ret) { //case "0": NotifyActionEvent(QQActionEventType.EVT_OK, m.Groups[3].Value); break; //case "66": throw new QQException(QQErrorCode.QRCODE_OK, m.Groups[5].Value); //case "67": throw new QQException(QQErrorCode.QRCODE_AUTH, m.Groups[5].Value); case "0": NotifyActionEvent(QQActionEventType.EvtOK, new CheckQRCodeArgs(QRCodeStatus.QRCODE_OK, m.Groups[3].Value)); break; case "66": NotifyActionEvent(QQActionEventType.EvtOK, new CheckQRCodeArgs(QRCodeStatus.QRCODE_VALID, m.Groups[5].Value)); break; case "67": NotifyActionEvent(QQActionEventType.EvtOK, new CheckQRCodeArgs(QRCodeStatus.QRCODE_AUTH, m.Groups[5].Value)); break; case "65": NotifyActionEvent(QQActionEventType.EvtOK, new CheckQRCodeArgs(QRCodeStatus.QRCODE_INVALID, m.Groups[5].Value)); break; default: throw new QQException(QQErrorCode.InvalidUser, m.Groups[5].Value); } } else { throw new QQException(QQErrorCode.UnexpectedResponse); } }
public virtual void onHttpStatusError(QQHttpResponse response) { if (!doRetryIt(QQWpfApplication1.action.QQException.QQErrorCode.ERROR_HTTP_STATUS, null)) { throw new QQException(QQWpfApplication1.action.QQException.QQErrorCode.ERROR_HTTP_STATUS); } }
public override void OnHttpStatusOK(QQHttpResponse response) { var rex = new Regex(QQConstants.REGXP_LOGIN); var mc = rex.Match(response.GetResponseString()); if (mc.Success) { var ret = int.Parse(mc.Groups[1].Value); switch (ret) { case 0: NotifyActionEvent(QQActionEventType.EVT_OK, mc.Groups[3].Value); break; case 3: throw new QQException(QQErrorCode.WRONG_PASSWORD, mc.Groups[5].Value); case 4: throw new QQException(QQErrorCode.WRONG_CAPTCHA, mc.Groups[5].Value); case 7: throw new QQException(QQErrorCode.IO_ERROR, mc.Groups[5].Value); default: throw new QQException(QQErrorCode.INVALID_USER, mc.Groups[5].Value); } } else { throw new QQException(QQErrorCode.UNEXPECTED_RESPONSE); } }
public override void OnHttpStatusOK(QQHttpResponse response) { //{"retcode":0,"result":{"dnamelist":[{"did":3536443553,"name":"\u8FD9\u662F\u6807\u9898"}, //{"did":625885728,"name":""}],"dmasklist":[{"did":1000,"mask":0}]}} JObject json = JObject.Parse(response.GetResponseString()); QQStore store = Context.Store; if (json["retcode"].ToString() == "0") { JObject result = json["result"].ToObject <JObject>(); JArray dizlist = result["dnamelist"].ToObject <JArray>(); for (int i = 0; i < dizlist.Count; i++) { QQDiscuz discuz = new QQDiscuz(); JObject dizjson = dizlist[i].ToObject <JObject>(); discuz.Did = dizjson["did"].ToObject <long>(); discuz.Name = dizjson["name"].ToString(); store.AddDiscuz(discuz); } NotifyActionEvent(QQActionEventType.EVT_OK, store.GetDiscuzList()); } else { NotifyActionEvent(QQActionEventType.EVT_ERROR, new QQException(QQErrorCode.UNEXPECTED_RESPONSE)); } }
public HttpActor(HttpActorType type, QQContext context, IHttpAction action, QQHttpResponse response) { _type = type; _context = context; _action = action; _response = response; }
public override void OnHttpStatusOK(QQHttpResponse response) { var rex = new Regex(QQConstants.REGXP_JSON_SINGLE_RESULT); var str = response.GetResponseString(); var m = rex.Match(str); if (!m.Success) { throw new QQException(QQErrorCode.UnexpectedResponse, str); } var pic = new OffPicItem(); var regResult = Regex.Replace(Regex.Replace(m.Groups[0].Value, "[\\r]?[\\n]", " "), "[\r]?[\n]", " "); var obj = JObject.Parse(regResult); var retcode = obj["retcode"].ToObject <int>(); if (retcode == 0) { pic.IsSuccess = (obj["progress"].ToObject <int>() == 100) ? true : false; pic.FileSize = obj["filesize"].ToObject <int>(); pic.FileName = obj["filename"].ToString(); pic.FilePath = obj["filepath"].ToString(); NotifyActionEvent(QQActionEventType.EvtOK, pic); return; } // 失败后返回路径 pic.FilePath = _file; pic.IsSuccess = false; throw new QQException(QQErrorCode.UnexpectedResponse, str); }
public override void OnHttpStatusOK(QQHttpResponse response) { var rex = new Regex(QQConstants.REGXP_LOGIN); var mc = rex.Match(response.GetResponseString()); if (mc.Success) { var ret = int.Parse(mc.Groups[1].Value); switch (ret) { case 0: NotifyActionEvent(QQActionEventType.EvtOK, mc.Groups[3].Value); break; case 3: throw new QQException(QQErrorCode.WrongPassword, mc.Groups[5].Value); case 4: throw new QQException(QQErrorCode.WrongCaptcha, mc.Groups[5].Value); case 7: throw new QQException(QQErrorCode.IOError, mc.Groups[5].Value); default: throw new QQException(QQErrorCode.InvalidUser, mc.Groups[5].Value); } } else { throw new QQException(QQErrorCode.UnexpectedResponse); } }
public override void OnHttpStatusOK(QQHttpResponse response) { var image = Image.FromStream(response.ResponseStream); _user.Face = image; NotifyActionEvent(QQActionEventType.EvtOK, _user); }
public override void OnHttpStatusOK(QQHttpResponse response) { var str = response.ResponseString; var json = JObject.Parse(str); var store = Context.Store; if (json["retcode"].ToString() == "0") { var result = json["result"].ToObject <JArray>(); foreach (var token in result) { var obj = token.ToObject <JObject>(); var uin = obj["uin"].ToObject <long>(); var status = obj["status"].ToString(); var clientType = obj["client_type"].ToObject <int>(); var buddy = store.GetBuddyByUinOrAdd(uin); buddy.Status = QQStatus.ValueOfRaw(status); buddy.ClientType = QQClientTypeInfo.ValueOfRaw(clientType); } NotifyActionEvent(QQActionEventType.EvtOK, null); } else { throw new QQException(QQErrorCode.InvalidResponse, str); } }
public virtual void OnHttpFinish(QQHttpResponse response) { try { string type = response.GetContentType() ?? ""; if ((type.StartsWith("application/x-javascript") || type.StartsWith("application/json") || type.Contains("text") ) && response.GetContentLength() > 0) { MyLogger.Default.Debug(response.GetResponseString()); } if (response.ResponseCode == QQHttpResponse.S_OK) { OnHttpStatusOK(response); } else { OnHttpStatusError(response); } } catch (QQException e) { NotifyActionEvent(QQActionEventType.EVT_ERROR, e); } catch (JsonException e) { NotifyActionEvent(QQActionEventType.EVT_ERROR, new QQException(QQErrorCode.JSON_ERROR, e)); } catch (Exception e) { NotifyActionEvent(QQActionEventType.EVT_ERROR, new QQException(QQErrorCode.UNKNOWN_ERROR, e)); } }
public override void OnHttpStatusOK(QQHttpResponse response) { // {'ret':0,'msg':'5F7E31F0001EF4310865F1FF4549B12B.jPg'} Regex rex = new Regex(QQConstants.REGXP_JSON_SINGLE_RESULT); Match m = rex.Match(response.GetResponseString()); CFaceItem pic = new CFaceItem(); JObject obj = null; if (m.Success) { try { string regResult = Regex.Replace(Regex.Replace(m.Groups[0].Value, "[\\r]?[\\n]", " "), "[\r]?[\n]", " "); obj = JObject.Parse(regResult); int retcode = obj["ret"].ToObject <int>(); if (retcode == 0) { pic.IsSuccess = true; pic.FileName = obj["msg"].ToString(); NotifyActionEvent(QQActionEventType.EVT_OK, pic); Context.Store.AddPicItem(pic); return; } else if (retcode == 4) { // {'ret':4,'msg':'D81AB7A7627ED673FDCD4DD24220C192.jPg // -6102 upload cface failed'} string prefix = "\"msg\":\""; string suffix = ".jPg"; rex = new Regex(prefix + "([\\s\\S]*)" + suffix, RegexOptions.IgnoreCase); m = rex.Match(obj.ToString()); if (m.Success) { string r = Regex.Replace(m.Groups[0].Value, prefix, ""); //LOG.debug("ret 4: " + r); pic.IsSuccess = true; pic.FileName = r; NotifyActionEvent(QQActionEventType.EVT_OK, pic); return; } } else { MyLogger.Default.Debug($"ret: {retcode}"); } } catch (Exception e) { MyLogger.Default.Warn(e.Message, e); } } // 失败后返回路径 pic.FileName = file; pic.IsSuccess = false; NotifyActionEvent(QQActionEventType.EVT_ERROR, new QQException(QQErrorCode.UNEXPECTED_RESPONSE, "CFace: " + response.GetResponseString())); }
public virtual void OnHttpStatusError(QQHttpResponse response) { if (!DoRetryIt(QQErrorCode.ERROR_HTTP_STATUS, new QQException(QQErrorCode.ERROR_HTTP_STATUS, response.ResponseMessage))) { throw new QQException(QQErrorCode.ERROR_HTTP_STATUS, response.ResponseMessage); } }
public virtual void OnHttpStatusError(QQHttpResponse response) { var ex = new QQException(QQErrorCode.ErrorHttpStatus, response.ResponseMessage); if (!DoRetryIt(ex, QQConstants.MAX_RETRY_TIMES)) { // NotifyActionEvent(QQActionEventType.EVT_ERROR, ex); throw ex; } }
public override void OnHttpStatusOK(QQHttpResponse response) { JObject json = JObject.Parse(response.GetResponseString()); if (json["retcode"].ToString() == "0") { JObject obj = json["result"].ToObject <JObject>(); buddy.QQ = obj["account"].ToObject <long>(); } NotifyActionEvent(QQActionEventType.EVT_OK, buddy); }
public override void OnHttpStatusOK(QQHttpResponse response) { var json = JObject.Parse(response.GetResponseString()); if (json["retcode"].ToString() == "0") { var obj = json["result"].ToObject <JObject>(); _group.Gid = obj["account"].ToObject <long>(); } NotifyActionEvent(QQActionEventType.EvtOK, _group); }
public override void OnHttpStatusOK(QQHttpResponse response) { try { MemoryStream ms = new MemoryStream(response.ResponseData); NotifyActionEvent(QQActionEventType.EVT_OK, Image.FromStream(ms)); } catch (IOException e) { NotifyActionEvent(QQActionEventType.EVT_ERROR, new QQException(QQErrorCode.UNKNOWN_ERROR, e)); } }
public override void OnHttpStatusOK(QQHttpResponse response) { var json = JObject.Parse(response.GetResponseString()); var recents = new List <object>(); var store = Context.Store; if (json["retcode"].ToString() == "0") { var result = json["result"].ToObject <JArray>(); for (var i = 0; i < result.Count; i++) { var rejson = result[i].ToObject <JObject>(); switch (rejson["type"].ToObject <int>()) { case 0: { //好友 var buddy = store.GetBuddyByUin(rejson["uin"].ToObject <long>()); if (buddy != null) { recents.Add(buddy); } break; } case 1: { //群 var group = store.GetGroupByCode(rejson["uin"].ToObject <long>()); if (group != null) { recents.Add(group); } break; } case 2: { //讨论组 var discuz = store.GetDiscuzByDid(rejson["uin"].ToObject <long>()); if (discuz != null) { recents.Add(discuz); } break; } } } NotifyActionEvent(QQActionEventType.EvtOK, recents); } else { NotifyActionEvent(QQActionEventType.EvtError, new QQException(QQErrorCode.UnexpectedResponse)); } }
public override void OnHttpStatusOK(QQHttpResponse response) { var json = JObject.Parse(response.GetResponseString()); var account = Context.Account; if (json["retcode"].ToString() == "0") { var obj = json["result"].ToObject <JObject>(); try { account.Birthday = DateUtils.Parse(obj["birthday"].ToObject <JObject>()); } catch (Exception e) { //Context.Logger.LogWarning($"日期转换失败:{obj["birthday"]}", e); account.Birthday = null; } account.Occupation = obj["occupation"].ToString(); account.Phone = obj["phone"].ToString(); account.Allow = (QQAllow)obj["allow"].ToObject <int>(); account.College = obj["college"].ToString(); account.RegTime = obj["reg_time"]?.ToObject <int>() ?? 0; account.Uin = obj["uin"].ToObject <long>(); account.Constel = obj["constel"].ToObject <int>(); account.Blood = obj["blood"].ToObject <int>(); account.Homepage = obj["homepage"].ToString(); account.Stat = obj["stat"]?.ToObject <int>() ?? 0; account.Sign = obj["lnick"].ToString(); account.VipLevel = obj["vip_info"].ToObject <int>(); // VIP等级 0为非VIP account.Country = obj["country"].ToString(); account.City = obj["city"].ToString(); account.Personal = obj["personal"].ToString(); account.Nickname = obj["nick"].ToString(); account.ChineseZodiac = obj["shengxiao"].ToObject <int>(); account.Email = obj["email"].ToString(); account.Province = obj["province"].ToString(); account.Gender = obj["gender"].ToString(); account.Mobile = obj["mobile"].ToString(); account.Vfwebqq = obj["vfwebqq"].ToString(); // 重要 var clientType = obj["client_type"]; if (clientType != null) { account.ClientType = QQClientTypeInfo.ValueOfRaw(clientType.ToString()); } NotifyActionEvent(QQActionEventType.EvtOK, account); } else { throw new QQException(QQErrorCode.InvalidResponse, response.ResponseString); } }
public override void OnHttpStatusOK(QQHttpResponse response) { JObject json = JObject.Parse(response.GetResponseString()); List <object> recents = new List <object>(); QQStore store = Context.Store; if (json["retcode"].ToString() == "0") { JArray result = json["result"].ToObject <JArray>(); for (int i = 0; i < result.Count; i++) { JObject rejson = result[i].ToObject <JObject>(); switch (rejson["type"].ToObject <int>()) { case 0: { //好友 QQBuddy buddy = store.GetBuddyByUin(rejson["uin"].ToObject <long>()); if (buddy != null) { recents.Add(buddy); } break; } case 1: { //群 QQGroup group = store.GetGroupByCode(rejson["uin"].ToObject <long>()); if (group != null) { recents.Add(group); } break; } case 2: { //讨论组 QQDiscuz discuz = store.GetDiscuzByDid(rejson["uin"].ToObject <long>()); if (discuz != null) { recents.Add(discuz); } break; } } } NotifyActionEvent(QQActionEventType.EVT_OK, recents); } else { NotifyActionEvent(QQActionEventType.EVT_ERROR, new QQException(QQErrorCode.UNEXPECTED_RESPONSE)); } }
public override void OnHttpStatusOK(QQHttpResponse response) { var json = JObject.Parse(response.GetResponseString()); if (json["retcode"].ToString() == "0") { var result = json["result"].ToObject <JArray>(); var obj = result[0].ToObject <JObject>(); _buddy.Sign = obj["lnick"].ToString(); } NotifyActionEvent(QQActionEventType.EvtOK, _buddy); }
public override void OnHttpFinish(QQHttpResponse response) { //如果返回的内容为空,认为这次PollMsg仍然成功 if (response.GetContentLength() == 0) { // LOG.debug("PollMsgAction: empty response!!!!"); NotifyActionEvent(QQActionEventType.EVT_OK, new List <QQNotifyEvent>()); } else { base.OnHttpFinish(response); } }
public override void OnHttpStatusOK(QQHttpResponse response) { var json = JObject.Parse(response.GetResponseString()); if (json["retcode"].ToString() == "0") { NotifyActionEvent(QQActionEventType.EvtOK, _user); } else { NotifyActionEvent(QQActionEventType.EvtError, new QQException(QQErrorCode.UnexpectedResponse)); } }
public override void OnHttpStatusOK(QQHttpResponse response) { JObject json = JObject.Parse(response.GetResponseString()); if (json["retcode"].ToString() == "0") { NotifyActionEvent(QQActionEventType.EVT_OK, user); } else { NotifyActionEvent(QQActionEventType.EVT_ERROR, new QQException(QQErrorCode.UNEXPECTED_RESPONSE)); } }
public override void OnHttpStatusOK(QQHttpResponse response) { try { var image = Image.FromStream(response.ResponseStream); _group.Face = image; } catch (IOException e) { throw new QQException(QQErrorCode.IOError, e); } NotifyActionEvent(QQActionEventType.EvtOK, _group); }
public override void OnHttpStatusOK(QQHttpResponse response) { // {'ret':0,'msg':'5F7E31F0001EF4310865F1FF4549B12B.jPg'} var rex = new Regex(QQConstants.REGXP_JSON_SINGLE_RESULT); var str = response.GetResponseString(); var m = rex.Match(str); var pic = new CFaceItem(); if (m.Success) { var regResult = Regex.Replace(Regex.Replace(m.Groups[0].Value, "[\\r]?[\\n]", " "), "[\r]?[\n]", " "); var obj = JObject.Parse(regResult); var retcode = obj["ret"].ToObject <int>(); if (retcode == 0) { pic.IsSuccess = true; pic.FileName = obj["msg"].ToString(); NotifyActionEvent(QQActionEventType.EvtOK, pic); Context.Store.AddPicItem(pic); return; } else if (retcode == 4) { // {'ret':4,'msg':'D81AB7A7627ED673FDCD4DD24220C192.jPg // -6102 upload cface failed'} var prefix = "\"msg\":\""; var suffix = ".jPg"; rex = new Regex(prefix + "([\\s\\S]*)" + suffix, RegexOptions.IgnoreCase); m = rex.Match(obj.ToString()); if (m.Success) { var r = Regex.Replace(m.Groups[0].Value, prefix, ""); //LOG.debug("ret 4: " + r); pic.IsSuccess = true; pic.FileName = r; NotifyActionEvent(QQActionEventType.EvtOK, pic); return; } } else { Context.Logger.LogDebug($"ret: {retcode}"); } } throw new QQException(QQErrorCode.UnexpectedResponse, "CFace: " + str); }
public override void OnHttpStatusOK(QQHttpResponse response) { // {"retcode":0,"result":{"gmasklist":[{"gid":1000,"mask":0},{"gid":1638195794,"mask":0},{"gid":321105219,"mask":0}], // "gnamelist":[{"flag":16777217,"name":"iQQ","gid":1638195794,"code":2357062609},{"flag":1048577,"name":"iQQ核心开发区","gid":321105219,"code":640215156}],"gmarklist":[]}} QQStore store = Context.Store; JObject json = JObject.Parse(response.GetResponseString()); int retcode = json["retcode"].ToObject<int>(); if (retcode == 0) { // 处理好友列表 JObject results = json["result"].ToObject<JObject>(); JArray groupJsonList = results["gnamelist"].ToObject<JArray>(); // 群列表 // 禁止接收群消息标志:正常 0, 接收不提醒 1, 完全屏蔽 2 JArray groupMaskJsonList = results["gmasklist"].ToObject<JArray>(); foreach (JToken t in groupJsonList) { JObject groupJson = t.ToObject<JObject>(); QQGroup group = new QQGroup(); group.Gin = groupJson["gid"].ToObject<long>(); group.Code = groupJson["code"].ToObject<long>(); group.Flag = groupJson["flag"].ToObject<int>(); group.Name = groupJson["name"].ToString(); //添加到Store store.AddGroup(group); } foreach (JToken t in groupMaskJsonList) { JObject maskObj = t.ToObject<JObject>(); long gid = maskObj["gid"].ToObject<long>(); int mask = maskObj["mask"].ToObject<int>(); QQGroup group = store.GetGroupByGin(gid); if (group != null) { group.Mask = mask; } } NotifyActionEvent(QQActionEventType.EVT_OK, store.GetGroupList()); } else { // LOG.warn("unknown retcode: " + retcode); NotifyActionEvent(QQActionEventType.EVT_ERROR, null); } }
public override void OnHttpStatusOK(QQHttpResponse response) { // {"result":null,"retcode":0} var json = JObject.Parse(response.GetResponseString()); if (json["retcode"].ToString() == "0") { NotifyActionEvent(QQActionEventType.EvtOK, Context.Store.GetGroupList()); } else { NotifyActionEvent(QQActionEventType.EvtError, QQErrorCode.UnexpectedResponse); } }
public override void OnHttpStatusOK(QQHttpResponse response) { // ({msg : "new successful",rbkey : "1391255617",status : "false"}) string ct = response.GetResponseString(); if (ct.Contains("success")) { NotifyActionEvent(QQActionEventType.EVT_OK, ct); } else { NotifyActionEvent(QQActionEventType.EVT_ERROR, ct); } }
public override void OnHttpStatusOK(QQHttpResponse response) { // {"result":null,"retcode":0} JObject json = JObject.Parse(response.GetResponseString()); if (json["retcode"].ToString() == "0") { NotifyActionEvent(QQActionEventType.EVT_OK, Context.Store.GetGroupList()); } else { NotifyActionEvent(QQActionEventType.EVT_ERROR, QQErrorCode.UNEXPECTED_RESPONSE); } }