public async Task <bool> Dial(string number) { IsInCall = true; Command cmd = _commandBuilder.Create(CommandName.Dial, number); Command response = await _transportManager.SendCommandAndGetAnswerAsync(cmd); var result = _commandBuilder.GetUnderlyingObject <DialResult>(response); if (result.Result != DialResultType.Answered) { IsInCall = false; } else { _audioDevice.StartCapture(); } return(IsInCall); }
private async Task <AuthenticationResult> Authorize() { var token = await _deviceInfo.GetPushUri(); var osName = await _deviceInfo.GetOsName(); var deviceName = await _deviceInfo.GetDeviceName(); var request = new AuthenticationRequest { UserId = _accountManager.UserId, PushUri = token, OsName = osName, DeviceName = deviceName }; Command requestCmd = _commandBuilder.Create(CommandName.Authentication, request); Command replyCmd = await _transportManager.SendCommandAndGetAnswerAsync(requestCmd); var result = _commandBuilder.GetUnderlyingObject <AuthenticationResult>(replyCmd); return(result); }
public async Task <bool> Register(string number) { Number = null; UserId = null; var request = new RegistrationRequest { Number = number }; var commandRequest = _commandBuilder.Create(CommandName.Register, request); var commandReply = await _transportManager.SendCommandAndGetAnswerAsync(commandRequest); var result = _commandBuilder.GetUnderlyingObject <RegistrationResult>(commandReply); if (result.Result == RegistrationResultType.Success) { _storage.SetValue(NumberKey, number); _storage.SetValue(UserIdKey, result.UserId); Number = number; UserId = result.UserId; return(true); } return(false); }