예제 #1
0
 public static void registerLock(AlexaLock device)
 {
     lock (devices)
     {
         devices.Add(device.applianceId, device);
     }
 }
예제 #2
0
        public static AlexaLock GetLock(string applianceId)
        {
            AlexaLock device = DeviceList.GetDevice(applianceId) as AlexaLock;

            if (device == null)
            {
                throw new Exception(String.Format(
                                        "Device {0} is not a lock",
                                        applianceId
                                        ));
            }
            return(device);
        }
예제 #3
0
 private Object HandleGetLockStateRequest(AlexaLock device)
 {
     return(new Response()
     {
         Header = new Header()
         {
             Namespace = "Alexa.ConnectedHome.Query",
             Name = DirectiveName.GetLockStateResponse,
             PayloadVersion = "2",
             MessageID = Guid.NewGuid(),
         },
         Payload = new GetLockStateResponsePayload()
         {
             LockState = device.isLocked == 1 ? "LOCKED" : "UNLOCKED"
         },
     });
 }
예제 #4
0
        private Object HandleSetLockStateRequest(AlexaLock device, bool shouldLock)
        {
            if (shouldLock)
            {
                device.Lock();
            }

            return(new Response()
            {
                Header = new Header()
                {
                    Namespace = "Alexa.ConnectedHome.Control",
                    Name = DirectiveName.SetLockStateConfirmation,
                    PayloadVersion = "2",
                    MessageID = Guid.NewGuid(),
                },
                Payload = new SetLockStateResponsePayload()
                {
                    LockState = "LOCKED"
                },
            });
        }