public async Task <EltraDevice> GetDevice(int nodeId) { EltraDevice result = null; bool signInResult = await _connector.SignIn(_identity, true); if (signInResult) { var deviceIdentity = new UserIdentity() { Login = "******", Password = "******" }; var connectResult = await _connector.Connect(deviceIdentity); if (connectResult) { var channels = await _connector.GetChannels(); foreach (var channel in channels) { foreach (var device in channel.Devices) { if (device.NodeId == nodeId) { result = device; break; } } } } } return(result); }
public async Task <EltraDevice> GetDevice(int nodeId, string deviceLogin, string devicePassword) { EltraDevice result = null; if (string.IsNullOrEmpty(Settings.Default.LoginName)) { Settings.Default.LoginName = _identity.Login; Settings.Default.Password = _identity.Password; Settings.Default.Save(); } else { _identity.Login = Settings.Default.LoginName; _identity.Password = Settings.Default.Password; } bool signInResult = await _connector.SignIn(_identity, true); if (signInResult) { var deviceIdentity = new UserIdentity() { Login = deviceLogin, Password = devicePassword }; var connectResult = await _connector.Connect(deviceIdentity); if (connectResult) { var channels = await _connector.GetChannels(); foreach (var channel in channels) { foreach (var device in channel.Devices) { if (device.NodeId == nodeId) { result = device; break; } } } } } return(result); }
public async Task PlayWithDevices() { var channels = await _connector.GetChannels(); Console.WriteLine($"channels count = {channels.Count}"); foreach (var channel in channels) { //let's grab some informations about our channel Console.WriteLine($"channel found = {channel.Id}, owner = {channel.UserName}"); Console.WriteLine($"channel location = {channel.Location.City}, {channel.Location.Country}, {channel.Location.Latitude}, {channel.Location.Longitude}"); //we would like to receive the notification if the channel is going offline channel.StatusChanged += OnChannelStatusChanged; Console.WriteLine($"devices count = {channel.Devices.Count}"); //list the devices attached to channel foreach (var device in channel.Devices) { await PlayWithDevice(device); } } }