Exemplo n.º 1
0
        public async Task ConnectInternalAsync(string input, IBrowserProfile browserProfile)
        {
            var channelName = Tools.ExtractUserId(input);

            if (string.IsNullOrEmpty(channelName))
            {
                SendSystemInfo("入力値からチャンネル名を取得できませんでした", InfoType.Error);
                return;
            }
            var cc = GetCookieContainer(browserProfile, "mixer.com");

            await InitAsync();

            //var p2 = new MetadataProvider2(_server, _siteOptions);
            //p2.MetadataUpdated += P2_MetadataUpdated;
            //p2.Master = p1;
            try
            {
                var dummy             = new DummyImpl(_server, input, _logger, cc, _siteOptions, _p1);
                var connectionManager = new ConnectionManager(_logger);
                _autoReconnector = new NewAutoReconnector(connectionManager, dummy, new MessageUntara(), _logger);
                await _autoReconnector.AutoReconnectAsync();
            }
            finally
            {
                //p1.MessageReceived -= P1_MessageReceived;
                //p1.MetadataUpdated -= P1_MetadataUpdated;
                //p2.MetadataUpdated -= P2_MetadataUpdated;
            }
        }
Exemplo n.º 2
0
        private async Task ConnectInternalAsync(string input, IBrowserProfile browserProfile)
        {
            _isBeeingSentInitialComments = true;
            var mayBeRoomId = Tools.ExtractRoomId(input);

            if (!mayBeRoomId.HasValue)
            {
                //不正なURL
                return;
            }
            var roomId = mayBeRoomId.Value;
            var cc     = GetCookieContainer(browserProfile);

            _imageDict = await Api.GetImageDictionary(_server, roomId, cc);

            _giftDict = await Tools.GetGiftDict(_server);

            //TODO:websocketUrlをAPI経由で取得する
            //https://im.mildom.com/?room_id=10045175&type=chat&call=get_server&cluster=aws_japan
            var websocketUrl = "wss://jp-room1.mildom.com/?roomId=" + roomId;
            var p1           = new MessageProvider(new SytemNetWebSockets(websocketUrl), _logger);

            p1.MessageReceived       += P1_MessageReceived;
            p1.BinaryMessageReceived += P1_BinaryMessageReceived;
            p1.MetadataUpdated       += P1_MetadataUpdated;
            //var p2 = new MetadataProvider2(_server, _siteOptions);
            //p2.MetadataUpdated += P2_MetadataUpdated;
            //p2.Master = p1;
            try
            {
                var dummy             = new DummyImpl(_server, input, browserProfile, _logger, _siteOptions, p1);//, p2);
                var connectionManager = new ConnectionManager(_logger);
                _autoReconnector = new NewAutoReconnector(connectionManager, dummy, new MessageUntara(), _logger);
                await _autoReconnector.AutoReconnectAsync();
            }
            finally
            {
                p1.MessageReceived       -= P1_MessageReceived;
                p1.BinaryMessageReceived -= P1_BinaryMessageReceived;
                p1.MetadataUpdated       -= P1_MetadataUpdated;
                //p2.MetadataUpdated -= P2_MetadataUpdated;
            }
        }
Exemplo n.º 3
0
        private async Task ConnectInternalAsync(string input, IBrowserProfile browserProfile)
        {
            await InitAsync();

            //var p1 = new MessageProvider2(new WebSocket("wss://online.mirrativ.com/"), _logger);
            //p1.MessageReceived += P1_MessageReceived;
            //p1.MetadataUpdated += P1_MetadataUpdated;
            //var p2 = new MetadataProvider2(_server, _siteOptions);
            //p2.MetadataUpdated += P2_MetadataUpdated;
            //p2.Master = p1;
            try
            {
                var dummy             = new DummyImpl(_server, input, _logger, _siteOptions, _p1, _p2);
                var connectionManager = new ConnectionManager(_logger);
                _autoReconnector = new NewAutoReconnector(connectionManager, dummy, new MessageUntara(), _logger);

                //isInitialCommentを取得する
                var liveId = await GetCurrentLiveIdAsync(input);

                if (!string.IsNullOrEmpty(liveId))
                {
                    var initialComments = await Api.GetLiveComments(_server, liveId);

                    foreach (var c in initialComments)
                    {
                        var userId         = c.UserId;
                        var isFirstComment = _first.IsFirstComment(userId);
                        var user           = GetUser(userId);
                        var context        = CreateMessageContext(c, true, "");
                        RaiseMessageReceived(context);
                    }
                }

                //接続開始
                await _autoReconnector.AutoReconnectAsync();
            }
            finally
            {
                //p1.MessageReceived -= P1_MessageReceived;
                //p1.MetadataUpdated -= P1_MetadataUpdated;
                //p2.MetadataUpdated -= P2_MetadataUpdated;
            }
        }