2169【前端】【1.2.0】【1.1.0】聊天自动播放语音在无数据时请求过于频繁
| | |
| | | var _player = int.Parse(speech.playerID);
|
| | | if (string.IsNullOrEmpty(speech.content))
|
| | | {
|
| | | if ((TimeUtility.ServerNow - TimeUtility.ClientOriginalTime.AddTicks(_tick)).TotalMinutes < 2)//可能是语音未上传成功
|
| | | var seconds = (TimeUtility.ServerNow - TimeUtility.ClientOriginalTime.AddTicks(_tick)).TotalSeconds;
|
| | | if (seconds < 10 && seconds >= 0)//可能是语音未上传成功
|
| | | {
|
| | | AutoPlayVoice();
|
| | | if (!CheckAutoRequestInDelay(tick, _player))
|
| | | {
|
| | | AutoPlayVoice();
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | private bool CheckAutoRequestInDelay(long tick, int playerId)
|
| | | {
|
| | | var autoPlayVoice = autoPlayVoices.Find((x) =>
|
| | | {
|
| | | return x.tick == tick && x.playerId == playerId;
|
| | | });
|
| | | var seconds = 0f;
|
| | | if (!autoPlayVoice.Equals(default(VoiceInfo)))
|
| | | {
|
| | | seconds = (float)(TimeUtility.ServerNow - autoPlayVoice.lastRequestTime).TotalSeconds;
|
| | | }
|
| | | if (seconds < 2f && seconds > 0)
|
| | | {
|
| | | TimeMgr.Instance.Register(TimeMgr.SyntonyType.AutoPlayVoice, 2 - seconds, () =>
|
| | | {
|
| | | AutoPlayVoice();
|
| | | });
|
| | | }
|
| | | return seconds < 2f && seconds > 0;
|
| | | }
|
| | |
|
| | | private bool CheckRequestTimeLimit(int _playerId, long _tick)
|
| | |
| | | }
|
| | | else
|
| | | {
|
| | | _speech.lastRequestTime = TimeUtility.ServerNow;
|
| | | DownloadSpeech(_speech.playerId, _speech.tick);
|
| | | }
|
| | | }
|
| | |
| | | });
|
| | | }
|
| | |
|
| | | public struct VoiceInfo
|
| | | public class VoiceInfo
|
| | | {
|
| | | public int playerId;
|
| | | public long tick;
|
| | | public float length;
|
| | | public ChatInfoType type;
|
| | | public DateTime lastRequestTime;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | GetFairyInfo,
|
| | | Audio,
|
| | | OSRedEnvelope,
|
| | | AutoPlayVoice,
|
| | | }
|
| | | }
|
| | |
| | | /// 服务器起始时间
|
| | | /// </summary>
|
| | | public static readonly DateTime OriginalTime = new DateTime(1970, 1, 1, 8, 0, 0);
|
| | | public static readonly DateTime ClientOriginalTime = new DateTime(1, 1, 1, 12, 0, 0);
|
| | | public static readonly DateTime ClientOriginalTime = new DateTime(1, 1, 1, 0, 0, 0);
|
| | | /// <summary>
|
| | | /// 服务器时间相比起始时间的秒数(主要方便比较)
|
| | | /// </summary>
|