Ejemplo n.º 1
0
 public MetadataProvider(ILogger logger, IDataServer server, string broadcasterId, MessageUntara messenger)
 {
     _logger        = logger;
     _server        = server;
     _broadcasterId = broadcasterId;
     _messenger     = messenger;
 }
 public TestAutoReconnector(ConnectionManager connectionManager, IDummy2 dummy, MessageUntara messageUntara, ILogger logger, IUrl url, IDataServer server)
 {
     _connectionManager = connectionManager;
     _dummy             = dummy;
     _messageUntara     = messageUntara;
     _logger            = logger;
     _url    = url;
     _server = server;
 }
 public DummyImpl(IDataServer server, IUrl url, IBrowserProfile browserProfile, ILogger logger, IPeriscopeSiteOptions siteOptions, MessageProvider p1, MessageUntara messageSetter)
 {
     _server         = server;
     _url            = url;
     _browserProfile = browserProfile;
     _logger         = logger;
     _siteOptions    = siteOptions;
     _p1             = p1;
     _messageSetter  = messageSetter;
     //_p2 = p2;
 }
        private async Task ConnectInternalAsync(string input, IBrowserProfile browserProfile)
        {
            var roomName = GetRoomNameFromInput(input);

            if (string.IsNullOrEmpty(roomName))
            {
                throw new Exception("invalid input");
            }
            var livePageUrl  = "https://www.showroom-live.com/" + roomName;
            var livePageHtml = await _server.GetAsync(livePageUrl);

            var match = Regex.Match(livePageHtml, "room_id=(\\d+)");

            if (!match.Success)
            {
                throw new Exception("room_idが無い");
            }
            var room_id = match.Groups[1].Value;

            var messageProvider = new MessageProvider(new Websocket(), _logger);

            messageProvider.Received += MessageProvider_Received;
            var connector = new PeriscopeConnector(_server, room_id, messageProvider, _logger);
            var me        = new MessageUntara();

            me.SystemInfoReiceved += Me_SystemInfoReiceved;
            _autoReconnector       = new AutoReconnector(connector, me);
            await _autoReconnector.AutoConnect();

            me.SystemInfoReiceved    -= Me_SystemInfoReiceved;
            messageProvider.Received -= MessageProvider_Received;
            //var liveInfo = await Api.GetLiveInfo(_server, room_id);
            //if(liveInfo.LiveStatus == 1)
            //{
            //    //放送終了?
            //    return;
            //}
            //_pingTimer.Enabled = true;
            //try
            //{
            //    await _messageProvider.ReceiveAsync(liveInfo.BcsvrHost, liveInfo.BcsvrKey);
            //}
            //finally
            //{
            //    _pingTimer.Enabled = false;
            //}
            //return;
        }
Ejemplo n.º 5
0
        private async Task ConnectInternal2Async(string input, IBrowserProfile browserProfile)
        {
            var(channelName, broadcastId) = Tools.ExtractChannelNameAndLiveId(input);
            if (string.IsNullOrEmpty(broadcastId))
            {
                return;
            }
            var messageProvider = new MessageProvider(new Websocket(), _logger);

            messageProvider.Received += MessageProvider_Received;
            var connector = new PeriscopeConnector(_server, broadcastId, messageProvider, _logger);
            var me        = new MessageUntara();

            me.SystemInfoReiceved += Me_SystemInfoReiceved;
            _autoReconnector       = new AutoReconnector(connector, me);
            await _autoReconnector.AutoConnect();

            me.SystemInfoReiceved    -= Me_SystemInfoReiceved;
            messageProvider.Received -= MessageProvider_Received;
        }
        private async Task ConnectInternalAsync(string input, IBrowserProfile browserProfile)
        {
            var url = Tools.GetUrl(input);

            if (url is UnknownUrl)
            {
                //不正なURL
                return;
            }
            var cc = GetCookieContainer(browserProfile);

            var messageSetter = new MessageUntara();

            messageSetter.SystemInfoReiceved += MessageSetter_SystemInfoReiceved;
            var p1 = new MessageProvider(_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, url, browserProfile, _logger, _siteOptions, p1, messageSetter);//, p2);
                var connectionManager = new ConnectionManager(_logger);
                _autoReconnector = new TestAutoReconnector(connectionManager, dummy, messageSetter, _logger, url, _server);
                await _autoReconnector.AutoReconnectAsync();
            }
            finally
            {
                messageSetter.SystemInfoReiceved -= MessageSetter_SystemInfoReiceved;
                p1.MessageReceived -= P1_MessageReceived;
                p1.MetadataUpdated -= P1_MetadataUpdated;
                //p2.MetadataUpdated -= P2_MetadataUpdated;
            }
        }