private void addDisplayComment(namaichi.info.ChatInfo chat) { if (chat.root.Equals("thread")) { return; } if (chat.contents == "再読み込みを行いました<br>読み込み中のままの方はお手数ですがプレイヤー下の更新ボタンをお試し下さい") { util.debugWriteLine("chat 再読み込みを行いました"); return; } if (chat.contents == null) { return; } // var time = util.getUnixToDatetime(chat.vpos / 100); // var unixKijunDt = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); var __time = chat.date - wsr.openTime; //- (60 * 60 * 9); if (__time < 0) { __time = 0; } // var __timeDt = util.getUnixToDatetime(__time); // var openTimeDt = util.getUnixToDatetime(openTime); // var __timeDt0 = __timeDt - openTimeDt; // var __timeDt1 = __timeDt0. - new timespunixKijunDt; var h = (int)(__time / (60 * 60)); var m = (int)((__time % (60 * 60)) / 60); var _m = (m < 10) ? ("0" + m.ToString()) : m.ToString(); var s = __time % 60; var _s = (s < 10) ? ("0" + s.ToString()) : s.ToString(); var keikaTime = h + ":" + _m + ":" + _s + ""; /* * // - unixKijunDt; * * // var __time = new TimeSpan(chat.vpos * 10000); * var h = (int)(__timeSpan.TotalHours); * var m = __timeSpan.Minutes; * var s = __timeSpan.Seconds; */ // - new TimeSpan(9,0,0); var c = (chat.premium == "3") ? "red" : ((chat.premium == "7") ? "blue" : "black"); if (chat.root == "control") { c = "red"; } cf.addComment(keikaTime, chat.contents, chat.userId, chat.score, c); }
private void onWscMessageReceive(object sender, MessageReceivedEventArgs e) { var eMessage = isConvertSpace ? util.getOkSJisOut(e.Message, " ") : e.Message; if (isNormalizeComment) { eMessage = eMessage.Replace("\"premium\":24", "\"premium\":0"); } try { if (rm.rfu != rfu || !isRetry) { try { if (wsc != null) { wsc.Close(); } } catch (Exception ee) { util.debugWriteLine("wsc message receive exception " + ee.Source + " " + ee.StackTrace + " " + ee.TargetSite + " " + ee.Message); } //stopRecording(); util.debugWriteLine("tigau rfu comment" + eMessage + " " + isRetry); return; } var xml = JsonConvert.DeserializeXNode(eMessage); var chatinfo = new namaichi.info.ChatInfo(xml); XDocument chatXml; var vposStartTime = (isVposStartTime) ? (long)rp.firstSegmentSecond : 0; if (isRtmp) { chatXml = chatinfo.getFormatXml(_openTime + vposStartTime); } else { if (programType == "official") { chatXml = chatinfo.getFormatXml(0, true, vposStartTime); // chatXml = chatinfo.getFormatXml(_openTime + vposStartTime); } else { chatXml = chatinfo.getFormatXml(openTime + vposStartTime); } } if (isGetCommentXmlInfo && chatinfo.no == -1) { chatXml.Root.Add(new XAttribute("no", "0")); } // else chatXml = chatinfo.getFormatXml(serverTime); // util.debugWriteLine("xml " + chatXml.ToString()); if (chatinfo.root == "chat" && (chatinfo.contents.IndexOf("/hb ifseetno") != -1 && chatinfo.premium == "3")) { return; } if (chatinfo.root == "ping" && chatinfo.contents.IndexOf("rf:") > -1) { //var addList = gotCommentListBuf.Where((a) => gotCommentList.IndexOf(a) == -1); gotCommentList.AddRange(gotCommentListBuf); gotCommentListBuf = new List <GotCommentInfo>(); gotMinTime = _gotMinTime; gotMinXml = _gotMinXml; wsc.Close(); } if (chatinfo.root != "chat" && chatinfo.root != "thread") { return; } if (chatinfo.root == "thread") { // serverTime = chatinfo.serverTime; ticket = chatinfo.ticket; // lastLastRes = (chatinfo.lastRes == null) ? 0 : int.Parse(chatinfo.lastRes); //lastLastRes = (chatinfo.lastRes != null) ? int.Parse(chatinfo.lastRes) : 0; if (chatinfo.lastRes == null) { chatinfo.lastRes = "0"; } if (eMessage.IndexOf("resultcode\":0") == -1) { //((WebSocket)(sender)).Close(); return; } if (chatinfo.lastRes != null) { lastLastRes = int.Parse(chatinfo.lastRes); } util.debugWriteLine("thread " + eMessage); } // util.debugWriteLine(chatXml.ToString()); // util.debugWriteLine(gotMinXml[1]); if (chatXml.ToString().Equals(_gotMinXml[1])) { isSave = false; //var addList = gotCommentListBuf.Where((a) => gotCommentList.IndexOf(a) == -1); gotCommentList.AddRange(gotCommentListBuf); gotCommentListBuf = new List <GotCommentInfo>(); gotMinTime = _gotMinTime; gotMinXml = _gotMinXml; } if (!isSave) { return; } if (chatinfo.root == "chat" && chatinfo.date < _gotMinTime) { _gotMinTime = chatinfo.date; _gotMinXml[1] = _gotMinXml[0]; _gotMinXml[0] = chatXml.ToString(); } try { // if (commentSW != null) { string s; if (isGetXml) { s = chatXml.ToString(); } else { var vposReplaced = Regex.Replace(eMessage, "\"vpos\"\\:(\\d+)", "\"vpos\":" + chatinfo.vpos + ""); s = vposReplaced; } if (chatinfo.root == "thread") { if (threadLine == null) { threadLine = s; if (!rfu.isPlayOnlyMode) { form.addLogText("アリーナ席に" + chatinfo.lastRes + "件ぐらいの" + (isStore ? "ストア" : "") + "コメントが見つかりました(追い出しコメント含む)"); } } } else { // commentSW.WriteLine(s + "}>"); // commentSW.Flush(); // gotCount++; // if (gotCount % 2000 == 0) form.addLogText(gotCount + "件のコメントを保存しました"); var isComSave = (!tsConfig.isAfterStartTimeComment || chatinfo.date > _openTime + tsConfig.timeSeconds - 10) && (!tsConfig.isBeforeEndTimeComment || tsConfig.endTimeSeconds == 0 || chatinfo.date < _openTime + tsConfig.endTimeSeconds + 10); //if (!tsConfig.isAfterStartTimeComment || // chatinfo.date > _openTime + tsConfig.timeSeconds - 10) { if (isComSave) { gotCommentListBuf.Add(new GotCommentInfo(s, chatinfo.no, chatinfo.date, chatinfo.vpos)); gotCount++; if (gotCount % 2000 == 0 && !rfu.isPlayOnlyMode) { form.addLogText(gotCount + "件のコメントを保存しました"); gotCommentList = gotCommentList.Distinct().ToList(); } } } // } } catch (Exception ee) { util.debugWriteLine(ee.Message + " " + ee.StackTrace); } if (eMessage.IndexOf("rf:") > -1) { ((WebSocket)(sender)).Close(); } //if (!isTimeShift) // addDisplayComment(chatinfo); } catch (Exception eee) { util.debugWriteLine(eee.Message + eee.Source + eee.StackTrace + eee.TargetSite); } }