private unsafe void DeviceNotifyCallback(ref AMDeviceNotificationCallbackInfo callback_info) { var threadSafeEventHandler = DeviceDiscovered; if (threadSafeEventHandler != null) { var iPhone = CreateiPhone(callback_info.dev); threadSafeEventHandler(this, new iPhoneEventArgs { iPhone = iPhone }); } }
private unsafe void NotifyCallback(ref AMDeviceNotificationCallbackInfo callback) { if (callback.msg == NotificationMessage.Connected) { this.iPhoneHandle = callback.dev; if (this.ConnectToPhone()) { this.OnConnect(new ConnectEventArgs(callback)); } } else if (callback.msg == NotificationMessage.Disconnected) { this.connected = false; this.OnDisconnect(new ConnectEventArgs(callback)); } }
/// <summary> /// 正常链接回调 /// </summary> /// <param name="callback">The callback.</param> private void NotificationCallback(ref AMDeviceNotificationCallbackInfo callback) { try { switch (callback.Msg) { case ConnectNotificationMessage.Connected: var device = FindConnectedDevice(callback.DevicePtr); if (device == null) { device = new iOSDevice(callback.DevicePtr); this.currentConnectedDevice.Add(device); } if (CommonConnectEvent != null) { CommonConnectEvent(this, new DeviceCommonConnectEventArgs(device, ConnectNotificationMessage.Connected)); } break; case ConnectNotificationMessage.Disconnected: var disConnectDevice = FindConnectedDevice(callback.DevicePtr); if (disConnectDevice == null) { this.currentConnectedDevice.Remove(disConnectDevice); } if (CommonConnectEvent != null) { CommonConnectEvent(this, new DeviceCommonConnectEventArgs(disConnectDevice, ConnectNotificationMessage.Disconnected)); } break; case ConnectNotificationMessage.Unknown: break; } } catch (Exception ex) { ListenErrorEvent(this, new ListenErrorEventHandlerEventArgs(ex.Message, ListenErrorEventType.Connect)); } }
internal unsafe ConnectEventArgs(AMDeviceNotificationCallbackInfo cbi) { this.message = cbi.msg; this.device = cbi.dev; }