/// <summary> /// Constructor /// </summary> /// <param name="requestHeader">Header of the Directice</param> public Event(DirectiveHeader requestHeader) { if (requestHeader.PayloadVersion != "3") { throw new ArgumentOutOfRangeException(nameof(Type), $"Not supported Payload Version: {requestHeader.PayloadVersion}. Only Version 3 is supported"); } Header = new EventHeader(requestHeader); Payload = _GetPayloadForEvent(requestHeader.Namespace); }
/// <summary> /// Creates a ErrorResponse with given RequestHeader and the Error Type. If needed a special Namespace can be given. /// </summary> /// <param name="header"></param> /// <param name="type"></param> /// <returns></returns> public static SmartHomeResponse CreateErrorResponse(DirectiveHeader header, ErrorTypes type) { if (header.Name == HeaderNames.DISCOVERY_REQUEST) { throw new UnvalidDiscoveryResponseException(); } SmartHomeResponse sResponse = new SmartHomeResponse(); sResponse.Event = RKon.Alexa.NET46.Response.Event.CreateErrorEvent(header.CorrelationToken, type, header.Namespace); return(sResponse); }
private string _GetNamespace(DirectiveHeader reqHeader) { string name_space = Namespaces.ALEXA; if (reqHeader.Namespace == Namespaces.ALEXA_DISCOVERY) { name_space = Namespaces.ALEXA_DISCOVERY; } else if (reqHeader.Namespace == Namespaces.ALEXA_CAMERASTREAMCONTROLLER) { name_space = Namespaces.ALEXA_CAMERASTREAMCONTROLLER; } else if (reqHeader.Namespace == Namespaces.ALEXA_SCENECONTROLLER) { name_space = Namespaces.ALEXA_SCENECONTROLLER; } else if (reqHeader.Namespace == Namespaces.ALEXA_AUTHORIZATION) { name_space = Namespaces.ALEXA_AUTHORIZATION; } return(name_space); }
/// <summary> /// Constructor /// </summary> /// <param name="requestHeader">Header of the SmartHomeRequests</param> public SmartHomeResponse(DirectiveHeader requestHeader) { Event = new Event(requestHeader); }