/// <summary> /// CAUTION: YOU MUST <see langword="await"/> <see cref="_InitTask"/> BEFORE USING THIS OBJECT! /// </summary> /// <param name="device"></param> /// <param name="connectResponse"></param> /// <param name="cryptoContext"></param> private SmartGlassClient( Device device, ConnectResponseMessage connectResponse, CryptoContext cryptoContext) { _messageTransport = new MessageTransport(device.Address.ToString(), cryptoContext); _sessionMessageTransport = new SessionMessageTransport( _messageTransport, new SessionInfo() { ParticipantId = connectResponse.ParticipantId }); _sessionMessageTransport.ProtocolTimeoutOccured += (_, e) => ProtocolTimeoutOccured?.Invoke(this, e); _sessionMessageTransport.MessageReceived += (s, e) => { if (e.Message is ConsoleStatusMessage consoleStatusMessage) { CurrentConsoleStatus = new ConsoleStatus() { Configuration = consoleStatusMessage.Configuration, ActiveTitles = consoleStatusMessage.ActiveTitles }; ConsoleStatusChanged?.Invoke(this, new ConsoleStatusChangedEventArgs( CurrentConsoleStatus )); } }; _InitTask = InitializeAsync(); }
private SmartGlassClient( Device device, ConnectResponseMessage connectResponse, CryptoContext cryptoContext) { Device = device; _messageTransport = new MessageTransport(device.Address.ToString(), cryptoContext); _sessionMessageTransport = new SessionMessageTransport( _messageTransport, new SessionInfo() { ParticipantId = connectResponse.ParticipantId }); _sessionMessageTransport.MessageReceived += (s, e) => { var consoleStatusMessage = e.Message as ConsoleStatusMessage; if (consoleStatusMessage != null) { CurrentConsoleStatus = new ConsoleStatus() { Configuration = consoleStatusMessage.Configuration, ActiveTitles = consoleStatusMessage.ActiveTitles }; ConsoleStatusChanged?.Invoke(this, new ConsoleStatusChangedEventArgs( CurrentConsoleStatus )); } }; _sessionMessageTransport.SendAsync(new LocalJoinMessage()).Wait(); OpenChannels().Wait(); _sessionMessageTransport.StartHeartbeat(); }
/// <summary> /// CAUTION: YOU MUST <see langword="await"/> <see cref="_InitTask"/> BEFORE USING THIS OBJECT! /// </summary> /// <param name="device"></param> /// <param name="connectResponse"></param> /// <param name="cryptoContext"></param> private SmartGlassClient( Device device, ConnectResponseMessage connectResponse, CryptoContext cryptoContext, bool connectedAuthenticated) { this.connectedAuthenticated = connectedAuthenticated; _messageTransport = new MessageTransport(device.Address.ToString(), cryptoContext); _sessionMessageTransport = new SessionMessageTransport( _messageTransport, new SessionInfo() { ParticipantId = connectResponse.ParticipantId }); _sessionMessageTransport.MessageReceived += (s, e) => { var consoleStatusMessage = e.Message as ConsoleStatusMessage; if (consoleStatusMessage != null) { CurrentConsoleStatus = new ConsoleStatus() { Configuration = consoleStatusMessage.Configuration, ActiveTitles = consoleStatusMessage.ActiveTitles }; ConsoleStatusChanged?.Invoke(this, new ConsoleStatusChangedEventArgs( CurrentConsoleStatus )); } }; _InitTask = InitializeAsync(); }
public ConsoleStatusChangedEventArgs(ConsoleStatus status) { _status = status; }