示例#1
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 WebSocket(websocketUrl), _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, 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.MetadataUpdated -= P1_MetadataUpdated;
                //p2.MetadataUpdated -= P2_MetadataUpdated;
            }
        }
示例#2
0
 public DummyImpl(IDataServer server, string input, IBrowserProfile browserProfile, ILogger logger, IMildomSiteOptions siteOptions, MessageProvider p1)
 {
     _server         = server;
     _input          = input;
     _browserProfile = browserProfile;
     _logger         = logger;
     _siteOptions    = siteOptions;
     _p1             = p1;
     //_p2 = p2;
 }