Exemplo n.º 1
0
        public NiwavidedNicoTimeshiftCommentClient(string messageServerUrl, string threadId, string userId, string waybackkey, DateTimeOffset startTime)
        {
            StartTime = startTime;

            WaybackKey         = waybackkey;
            CommentSessionInfo = new CommentSessionInfo()
            {
                MessageServerUrl = messageServerUrl,
                ThreadId         = threadId,
                UserId           = userId
            };
        }
        public NiwavidedNicoLiveCommentClient(string messageServerUrl, string threadId, string userId, HttpClient httpClient)
        {
            CommentSessionInfo = new CommentSessionInfo()
            {
                MessageServerUrl = messageServerUrl,
                ThreadId         = threadId,
                UserId           = userId
            };
            _HttpClient = httpClient;
            _CommentSessionWebSocket = new MessageWebSocket();
            _CommentSessionWebSocket.Control.MessageType = SocketMessageType.Utf8;
            _CommentSessionWebSocket.Control.SupportedProtocols.Add("msg.nicovideo.jp#json");

            _CommentSessionWebSocket.SetRequestHeader("Pragma", "not-cache");
            _CommentSessionWebSocket.SetRequestHeader("Sec-WebSocket-Extensions", "permessage-deflate");
            _CommentSessionWebSocket.SetRequestHeader("Sec-WebSocket-Extensions", "client_max_window_bits");
            _CommentSessionWebSocket.SetRequestHeader("User-Agent", "Hohoema_UWP");

            _CommentSessionWebSocket.MessageReceived += _CommentSessionWebSocket_MessageReceived;
            _CommentSessionWebSocket.ServerCustomValidationRequested += _CommentSessionWebSocket_ServerCustomValidationRequested;
            _CommentSessionWebSocket.Closed += _CommentSessionWebSocket_Closed;
        }