Esempio n. 1
0
        internal static LifxResponse Create(FrameHeader header, MessageType type, uint source, byte[] payload)
        {
            LifxResponse response = null;

            switch (type)
            {
            case MessageType.DeviceAcknowledgement:
                response = new AcknowledgementResponse(payload);
                break;

            case MessageType.DeviceStateLabel:
                response = new StateLabelResponse(payload);
                break;

            case MessageType.LightState:
                response = new LightStateResponse(payload);
                break;

            case MessageType.LightStatePower:
                response = new LightPowerResponse(payload);
                break;

            case MessageType.DeviceStateVersion:
                response = new StateVersionResponse(payload);
                break;

            case MessageType.DeviceStateHostFirmware:
                response = new StateHostFirmwareResponse(payload);
                break;

            case MessageType.DeviceStateService:
                response = new StateServiceResponse(payload);
                break;

            default:
                response = new UnknownResponse(payload);
                break;
            }
            response.Header  = header;
            response.Type    = type;
            response.Payload = payload;
            response.Source  = source;
            return(response);
        }
Esempio n. 2
0
        private static LifxMessage FromPayloadBytes(LifxHeader header, byte[] payload, IUdpClient respondClient)
        {
            ILifxPayload parsedPayload = null;

            switch (header.ProtocolHeader.MessageType)
            {
            case MessageType.DeviceAcknowledgement:
                parsedPayload = AcknowledgementResponse.FromBytes();
                break;

            case MessageType.DeviceStateLabel:
                parsedPayload = StateLabelResponse.FromBytes(payload);
                break;

            case MessageType.LightState:
                parsedPayload = LightStateResponse.FromBytes(payload);
                break;

            case MessageType.LightStatePower:
                parsedPayload = LightPowerResponse.FromBytes(payload);
                break;

            case MessageType.DeviceStateVersion:
                parsedPayload = StateVersionResponse.FromBytes(payload);
                break;

            case MessageType.DeviceStateHostFirmware:
                parsedPayload = StateHostFirmwareResponse.FromBytes(payload);
                break;

            case MessageType.DeviceStateService:
                parsedPayload = StateServiceResponse.FromBytes(payload);
                break;

            default:
                parsedPayload = UnknownResponse.FromBytes(payload);
                break;
            }

            return(new LifxMessage(header, parsedPayload, respondClient));
        }
Esempio n. 3
0
		internal static LifxResponse Create(FrameHeader header, MessageType type, UInt32 source, byte[] payload)
		{
			LifxResponse response = null;
			switch(type)
			{
				case MessageType.DeviceAcknowledgement:
					response = new AcknowledgementResponse(payload);
					break;
				case MessageType.DeviceStateLabel:
					response = new StateLabelResponse(payload);
					break;
				case MessageType.LightState:
					response = new LightStateResponse(payload);
					break;
				case MessageType.LightStatePower:
					response = new LightPowerResponse(payload);
					break;
				case MessageType.DeviceStateVersion:
					response = new StateVersionResponse(payload);
					break;
				case MessageType.DeviceStateHostFirmware:
					response = new StateHostFirmwareResponse(payload);
					break;
				case MessageType.DeviceStateService:
					response = new StateServiceResponse(payload);
					break;
				default:
					response = new UnknownResponse(payload);
					break;
			}
			response.Header = header;
			response.Type = type;
			response.Payload = payload;
			response.Source = source;
			return response;
		}