private void DeviceAddedHandler(object aObj, DeviceAddedEventArgs aEvent) { // Devices can be turned off by the time they get to this point, at which point they end // up null. Make sure the device isn't null. if (aEvent.Device == null) { return; } var duplicates = from x in Devices where x.Value.Identifier == aEvent.Device.Identifier select x; if (duplicates.Any()) { _bpLogger.Debug($"Already have device {aEvent.Device.Name} in Devices list"); return; } // If we get to 4 billion devices connected, this may be a problem. var deviceIndex = DeviceIds.ContainsKey(aEvent.Device.Identifier) ? DeviceIds[aEvent.Device.Identifier] : (uint)Interlocked.Increment(ref _deviceIndexCounter); _bpLogger.Info((DeviceIds.ContainsKey(aEvent.Device.Identifier) ? "Re-" : string.Empty) + $"Adding Device {aEvent.Device.Name} at index {deviceIndex}"); DeviceIds[aEvent.Device.Identifier] = deviceIndex; Devices[deviceIndex] = aEvent.Device; aEvent.Device.DeviceRemoved += DeviceRemovedHandler; aEvent.Device.MessageEmitted += MessageEmittedHandler; var msg = new DeviceAdded( deviceIndex, aEvent.Device.Name, GetAllowedMessageTypesAsDictionary(aEvent.Device, SpecVersion)); DeviceMessageReceived?.Invoke(this, new MessageReceivedEventArgs(msg)); }
public static DeviceIds GetDevices( [ActivityTrigger] string req, [CosmosDB("devices", "rooms", ConnectionStringSetting = "CosmosDbConnectionString", Id = "{req}", PartitionKey = "{req}")] DeviceIds devices, ILogger log) { log.LogInformation($"Getting devices for room {req}"); return(devices); }
public override void Process(ResolveMobileDevicePipelineArgs args) { var browserCapabilitiesService = new BrowserCapabilitiesService(new HttpContextWrapper().Request); var deviceIds = new DeviceIds(new SitecoreSettingsWrapper()); IDeviceService requestDeviceService = new DeviceService(browserCapabilitiesService, deviceIds); args.DeviceId = requestDeviceService.GetDeviceId(); }
static void HandleDeviceNotify(object sender, LibUsbDotNet.DeviceNotify.DeviceNotifyEventArgs e) { var device = e.Device; var connected = e.EventType == LibUsbDotNet.DeviceNotify.EventType.DeviceArrival; var changeInfo = new DeviceIds( device.IdProduct, device.IdVendor); ProcessUsbChange(changeInfo, connected); }
public override void Process(HttpRequestArgs args) { var resolveMobilePipelineArgs = new ResolveMobileDevicePipelineArgs(); IDeviceIds deviceIds = new DeviceIds(new SitecoreSettingsWrapper()); CorePipeline.Run("resolveMobileDevice", resolveMobilePipelineArgs); if (resolveMobilePipelineArgs.Device != null && resolveMobilePipelineArgs.Device.ID != new ID(deviceIds.Default)) { Context.Device = resolveMobilePipelineArgs.Device; } }
public override void Process(ResolveMobileDevicePipelineArgs args) { if (Context.Device != null) { var contextDeviceId = Context.Device.ID.ToString(); IDeviceIds deviceIds = new DeviceIds(new SitecoreSettingsWrapper()); if (!contextDeviceId.Equals(deviceIds.Default)) { args.AbortPipeline(); } } }
public void ResetPlayerInput(PlayerInput input) { // Change the mock input device back to what it was originally ReadOnlyArray <InputDevice> devices = InputSystem.devices; InputDevice deviceToRemove = null; foreach (InputDevice d in devices) { if (d.deviceId == mockDeviceId) { deviceToRemove = d; } } InputDevice[] originalDevices = InputSystem.devices.Where(e => DeviceIds.Contains(e.deviceId)).ToArray(); input.SwitchCurrentControlScheme(ControlScheme, originalDevices); // Remove the mock input device from the input system InputSystem.RemoveDevice(deviceToRemove); }
public static async Task <string> RunOrchestrator( [OrchestrationTrigger] IDurableOrchestrationContext context, ILogger log) { log = context.CreateReplaySafeLogger(log); log.LogInformation("Someone entered meeting. Starting orchestration..."); var req = context.GetInput <RoomRequest>(); log.LogInformation($"Getting devices for room {req.RoomId}"); // Get all devices for the room DeviceIds devices = await context.CallActivityAsync <DeviceIds>("GetDevices", req.RoomId); var taskList = new List <Task>(); // Toggle all of the lights foreach (var lightId in devices.Lights) { taskList.Add( context.CallActivityAsync("ToggleLights", new LightToggleRequest(lightId, req.Toggle)) ); } // Connect room device IN PARALLEL taskList.Add( context.CallActivityAsync("ConnectRoom", new ConnectRoomRequest(devices.ConferencePhone, req.Toggle)) ); // Wait for all lights and room connected await Task.WhenAll(taskList); // Notify attendees the room is dialed in await context.CallActivityAsync("NotifyAttendees", req); return("Room Activated"); }
public override string ToString() { StringBuilder __sb = new StringBuilder("THTargetedNotification("); bool __first = true; if (Name != null && __isset.name) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("Name: "); __sb.Append(Name); } if (Title != null && __isset.title) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("Title: "); __sb.Append(Title.ToDebugString()); } if (Text != null && __isset.text) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("Text: "); __sb.Append(Text.ToDebugString()); } if (__isset.timezone) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("Timezone: "); __sb.Append(Timezone); } if (__isset.status) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("Status: "); __sb.Append(Status); } if (Properties != null && __isset.properties) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("Properties: "); __sb.Append(Properties.ToDebugString()); } if (AudienceId != null && __isset.audienceId) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("AudienceId: "); __sb.Append(AudienceId); } if (SendAfter != null && __isset.sendAfter) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("SendAfter: "); __sb.Append(SendAfter); } if (Id != null && __isset.id) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("Id: "); __sb.Append(Id); } if (AppId != null && __isset.appId) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("AppId: "); __sb.Append(AppId); } if (__isset.createdAt) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("CreatedAt: "); __sb.Append(CreatedAt); } if (__isset.sentCount) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("SentCount: "); __sb.Append(SentCount); } if (Action != null && __isset.action) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("Action: "); __sb.Append(Action == null ? "<null>" : Action.ToString()); } if (__isset.targetType) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("TargetType: "); __sb.Append(TargetType); } if (DeviceIds != null && __isset.deviceIds) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("DeviceIds: "); __sb.Append(DeviceIds.ToDebugString()); } if (ActionButtons != null && __isset.actionButtons) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("ActionButtons: "); __sb.Append(ActionButtons.ToDebugString()); } if (__isset.expiryMin) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("ExpiryMin: "); __sb.Append(ExpiryMin); } if (Image != null && __isset.image) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("Image: "); __sb.Append(Image); } if (Video != null && __isset.video) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("Video: "); __sb.Append(Video); } if (Template != null && __isset.template) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("Template: "); __sb.Append(Template == null ? "<null>" : Template.ToString()); } __sb.Append(")"); return(__sb.ToString()); }
static void ProcessUsbChange(DeviceIds device, Boolean connected) { if (UsbChanged != null) UsbChanged(device, connected); }