示例#1
0
        public async Task Start(CancellationToken cancellationToken = default(CancellationToken))
        {
            Log.Info($"{nameof(Start)}: CreateSession");
            var client = new Octgn.Site.Api.ApiClient();
            var result = await client.CreateSession(AppConfig.Instance.ComUsername, AppConfig.Instance.ComPassword, AppConfig.Instance.ComDeviceId);

            _clientAuthenticator.SessionKey = result.SessionKey;
            _clientAuthenticator.UserId     = result.UserId;
            _clientAuthenticator.DeviceId   = AppConfig.Instance.ComDeviceId;

            Log.Info($"{nameof(Start)}: Connect");
            await _chatClient.Connect(cancellationToken);
        }
示例#2
0
        public async Task Start(CancellationToken cancellationToken = default(CancellationToken))
        {
            Log.Info($"{nameof(Start)}: CreateSession");
            var client = new Octgn.Site.Api.ApiClient();
            var result = await client.CreateSession(AppConfig.Instance.ComUsername, AppConfig.Instance.ComPassword, AppConfig.Instance.ComDeviceId);

            if (result.Result.Type != Site.Api.LoginResultType.Ok)
            {
                throw new InvalidOperationException($"Couldn't not start. Error creating session: {result.Result.Type}");
            }

            _clientAuthenticator.SessionKey = result.SessionKey;
            _clientAuthenticator.UserId     = result.UserId;
            _clientAuthenticator.DeviceId   = AppConfig.Instance.ComDeviceId;

            Log.Info($"{nameof(Start)}: Connect");
            await _chatClient.Connect(cancellationToken);
        }