Exemplo n.º 1
0
        private async void Live2WebSocket_RecieveCurrentRoom(Live2CurrentRoomEventArgs e)
        {
            RoomName = e.RoomName;

            if (e.MessageServerType == "niwavided")
            {
                _NicoLiveCommentClient = new Niwavided.NiwavidedNicoLiveCommentClient(
                    e.MessageServerUrl,
                    e.ThreadId,
                    this.HohoemaApp.LoginUserId.ToString(),
                    HohoemaApp.NiconicoContext.HttpClient
                    );

                _NicoLiveCommentClient.Connected       += _NicoLiveCommentClient_Connected;
                _NicoLiveCommentClient.Disconnected    += _NicoLiveCommentClient_Disconnected;
                _NicoLiveCommentClient.CommentRecieved += _NicoLiveCommentClient_CommentRecieved;
                _NicoLiveCommentClient.CommentPosted   += _NicoLiveCommentClient_CommentPosted;

                // コメントの受信処理と映像のオープンが被ると
                // 自動再生が失敗する?ので回避のため数秒遅らせる

                _NicoLiveCommentClient.Open();

                await Task.Delay(500);

                await RefreshLeoPlayer();
            }
        }
Exemplo n.º 2
0
        private void EndCommentClientConnection()
        {
            if (_NicoLiveCommentClient != null)
            {
                _NicoLiveCommentClient.Connected       -= _NicoLiveCommentClient_Connected;
                _NicoLiveCommentClient.Disconnected    -= _NicoLiveCommentClient_Disconnected;
                _NicoLiveCommentClient.CommentRecieved -= _NicoLiveCommentClient_CommentRecieved;
                _NicoLiveCommentClient.CommentPosted   -= _NicoLiveCommentClient_CommentPosted;

                (_NicoLiveCommentClient as IDisposable)?.Dispose();

                _NicoLiveCommentClient = null;
            }
        }
Exemplo n.º 3
0
        private void StartCommentClientConnection()
        {
            EndCommentClientConnection();

            var baseTime = PlayerStatusResponse.Program.BaseAt;

            _NicoLiveCommentClient                  = new NicoLiveCommentClient(LiveId, PlayerStatusResponse.Program.CommentCount, PlayerStatusResponse.User.Id.ToString(), baseTime, PlayerStatusResponse.Comment.Server, HohoemaApp.NiconicoContext);
            _NicoLiveCommentClient.Connected       += _NicoLiveCommentClient_Connected;
            _NicoLiveCommentClient.Disconnected    += _NicoLiveCommentClient_Disconnected;
            _NicoLiveCommentClient.CommentRecieved += _NicoLiveCommentClient_CommentRecieved;
            _NicoLiveCommentClient.CommentPosted   += _NicoLiveCommentClient_CommentPosted;

            _NicoLiveCommentClient.Open();
        }
Exemplo n.º 4
0
        private async void Live2WebSocket_RecieveCurrentRoom(Live2CurrentRoomEventArgs e)
        {
            RoomName = e.RoomName;

            if (e.MessageServerType == "niwavided")
            {
                if (IsWatchWithTimeshift)
                {
                    string waybackKey = await NicoLiveProvider.GetWaybackKeyAsync(e.ThreadId);

                    _NicoLiveCommentClient = new Niwavided.NiwavidedNicoTimeshiftCommentClient(
                        e.MessageServerUrl,
                        e.ThreadId,
                        NiconicoSession.UserIdString,
                        waybackKey,
                        LiveInfo.VideoInfo.Video.OpenTime.Value
                        );
                }
                else
                {
                    _NicoLiveCommentClient = new Niwavided.NiwavidedNicoLiveCommentClient(
                        e.MessageServerUrl,
                        e.ThreadId,
                        NiconicoSession.UserIdString,
                        NiconicoSession.Context.HttpClient
                        );
                }

                _NicoLiveCommentClient.Connected       += _NicoLiveCommentClient_Connected;
                _NicoLiveCommentClient.Disconnected    += _NicoLiveCommentClient_Disconnected;
                _NicoLiveCommentClient.CommentRecieved += _NicoLiveCommentClient_CommentRecieved;
                _NicoLiveCommentClient.CommentPosted   += _NicoLiveCommentClient_CommentPosted;

                // コメントの受信処理と映像のオープンが被ると
                // 自動再生が失敗する?ので回避のため数秒遅らせる
                // タイムシフトコメントはStartTimeへのシーク後に取得されることを想定して
                if (!(_NicoLiveCommentClient is Niwavided.NiwavidedNicoTimeshiftCommentClient))
                {
                    _NicoLiveCommentClient.Open();

                    await Task.Delay(Services.Helpers.DeviceTypeHelper.IsMobile? 3000 : 500);
                }
            }
        }