/// <summary> /// 動画のコメント取得。コメント投稿後に差分を取得する際に使用する。 /// </summary> /// <param name="from"></param> /// <returns></returns> public async Task <NMSG_Response> GetDifferenceCommentAsync() { ThreadKeyResponse threadKey = null; if (DefaultPostTargetThread.IsThreadkeyRequired) { threadKey = await GetThreadKeyAsync(DefaultPostTargetThread.Id); } object[] commentCommandList = new object[] { new PingItem($"rs:{_SubmitTimes}"), new PingItem($"ps:{_SeqNum}"), new ThreadItem() { Thread = new Thread_CommentRequest() { Fork = DefaultPostTargetThread.Fork, UserId = UserId, ThreadId = DefaultPostTargetThreadId, Version = "20061206", Userkey = UserKey, ResFrom = _LastRes, Threadkey = threadKey?.ThreadKey, Force184 = threadKey?.Force184, } }, new PingItem($"pf:{_SeqNum}"), new PingItem($"rf:{_SubmitTimes}"), }; // コメント取得リクエストを送信 var responseString = await SendCommentCommandAsync(DefaultPostTargetThread.Server, commentCommandList); // コメント取得結果をパース var res = ParseNMSGResponseJson(responseString); var defaultPostThreadInfo = res.Threads.FirstOrDefault(x => x.Thread == DefaultPostTargetThreadId); if (defaultPostThreadInfo != null) { _LastRes = defaultPostThreadInfo.LastRes; _Ticket = defaultPostThreadInfo.Ticket ?? _Ticket; IncrementSequenceNumber(commentCommandList.Length); } return(res); }
public async Task <NMSG_Response> GetCommentFirstAsync() { var hasCommunityThread = CommenctComposite.Threads.Any(x => x.Label == "community"); List <object> commentCommandList = new List <object>(); commentCommandList.Add(new PingItem($"rs:{_SubmitTimes}")); var seqNum = _SeqNum; foreach (var thread in CommenctComposite.Threads) { if (!thread.IsActive || thread.Label == "easy") { continue; } commentCommandList.Add(new PingItem($"ps:{_SeqNum + seqNum}")); ThreadKeyResponse threadKey = null; if (thread.IsThreadkeyRequired) { threadKey = await GetThreadKeyAsync(thread.Id); } if (thread.IsOwnerThread) { commentCommandList.Add(new ThreadItem() { Thread = new Thread_CommentRequest() { Fork = thread.Fork, UserId = UserId, ThreadId = thread.Id.ToString(), Version = "20061206", Userkey = UserKey, ResFrom = -1000, } }); } else { commentCommandList.Add(new ThreadItem() { Thread = new Thread_CommentRequest() { Fork = thread.Fork, UserId = UserId, ThreadId = thread.Id.ToString(), Version = "20090904", Userkey = !thread.IsThreadkeyRequired ? UserKey : null, Threadkey = threadKey?.ThreadKey, Force184 = threadKey?.Force184, } }); } commentCommandList.Add(new PingItem($"pf:{_SeqNum + seqNum}")); ++seqNum; if (thread.IsLeafRequired) { commentCommandList.Add(new PingItem($"ps:{_SeqNum + seqNum}")); commentCommandList.Add(new ThreadLeavesItem() { ThreadLeaves = new ThreadLeaves() { UserId = UserId, ThreadId = thread.Id.ToString(), Userkey = !thread.IsThreadkeyRequired ? UserKey : null, Threadkey = threadKey?.ThreadKey, Force184 = threadKey?.Force184, Content = _ThreadLeavesContentString, } }); commentCommandList.Add(new PingItem($"pf:{_SeqNum + seqNum}")); ++seqNum; } } commentCommandList.Add(new PingItem($"rf:{_SubmitTimes}")); // コメント取得リクエストを送信 var responseString = await SendCommentCommandAsync(DefaultPostTargetThread.Server, commentCommandList.ToArray()); // コメント取得結果をパース var res = ParseNMSGResponseJson(responseString); var defaultPostThreadInfo = res.Threads.FirstOrDefault(x => x.Thread == DefaultPostTargetThreadId); if (defaultPostThreadInfo != null) { _LastRes = defaultPostThreadInfo.LastRes; _Ticket = defaultPostThreadInfo.Ticket ?? _Ticket; IncrementSequenceNumber(commentCommandList.Count); } return(res); }