private void Window_Loaded(object sender, RoutedEventArgs e) { // Obtain Plantronics API singleton m_spokes = Spokes.Instance; // Register for Plantronics API events of interest // Have I got a Plantronics device? m_spokes.Attached += new Spokes.AttachedEventHandler(m_spokes_Attached); m_spokes.Detached += new Spokes.DetachedEventHandler(m_spokes_Detached); // Am I wearing Plantronics device? m_spokes.PutOn += new Spokes.PutOnEventHandler(m_spokes_PutOn); m_spokes.TakenOff += new Spokes.TakenOffEventHandler(m_spokes_TakenOff); // Is Plantronics device docked? m_spokes.Docked += new Spokes.DockedEventHandler(m_spokes_Docked); m_spokes.UnDocked += new Spokes.DockedEventHandler(m_spokes_UnDocked); // Is Plantronics device near or far m_spokes.Near += new Spokes.NearEventHandler(m_spokes_Near); m_spokes.Far += new Spokes.FarEventHandler(m_spokes_Far); // Is Plantronics device connected (InRange) or disconnected (OutOfRange) m_spokes.InRange += new Spokes.InRangeEventHandler(m_spokes_InRange); m_spokes.OutOfRange += new Spokes.OutOfRangeEventHandler(m_spokes_OutOfRange); // Did Plantronics device disconnect from paired mobile device (receive ProximityDisabled event when that occurs) m_spokes.ProximityDisabled += new Spokes.ProximityDisabledEventHandler(m_spokes_ProximityDisabled); m_spokes.ProximityEnabled += new Spokes.ProximityEnabledEventHandler(m_spokes_ProximityEnabled); // Finally connect to Plantronics API m_spokes.Connect("ScreenLockSample"); }
/// <summary> /// Constructor for PLTLabsAPI object which is used to connect /// to the Plantronics motion sensor headset devices. /// ***NOTE: Only instantiate 1 of these objects - pending to do make a singleton*** /// </summary> /// <param name="aCallBackHandler">Pass reference to your object class that implements /// the PLTLabsCallbackHandler interface to be able to receive motion tracking and other /// sensor data.</param> public PLTLabsAPI(PLTLabsCallbackHandler aCallBackHandler) { m_callbackhandler = aCallBackHandler; m_quatproc = new QuaternionProcessor(this); m_spokes = Spokes.Instance; // register for device attach/detach events m_spokes.Attached += new Spokes.AttachedEventHandler(m_spokes_Attached); m_spokes.Detached += new Spokes.DetachedEventHandler(m_spokes_Detached); // Register for some special device events that we need initial // status for as soon as we call connect m_spokes.PutOn += new Spokes.PutOnEventHandler(m_spokes_PutOn); m_spokes.TakenOff += new Spokes.TakenOffEventHandler(m_spokes_TakenOff); // register for battery level events m_spokes.BatteryLevelChanged += new Spokes.BatteryLevelChangedEventHandler(m_spokes_BatteryLevelChanged); // register for device proximity events // NOTE: these are also used to infer whether the actual Concept 1 headset is connected // to the BT300 dongle - i.e. if we have any of Near/Far/InRange then we can announce // the device as attached to the application m_spokes.OutOfRange += new Spokes.OutOfRangeEventHandler(m_spokes_OutOfRange); m_spokes.InRange += new Spokes.InRangeEventHandler(m_spokes_InRange); m_spokes.Near += new Spokes.NearEventHandler(m_spokes_Near); m_spokes.Far += new Spokes.FarEventHandler(m_spokes_Far); // call state events: m_spokes.MobileCallerId += new Spokes.MobileCallerIdEventHandler(m_spokes_MobileCallerId); m_spokes.OnCall += new Spokes.OnCallEventHandler(m_spokes_OnCall); m_spokes.OnMobileCall += new Spokes.OnMobileCallEventHandler(m_spokes_OnMobileCall); m_spokes.NotOnCall += new Spokes.NotOnCallEventHandler(m_spokes_NotOnCall); m_spokes.NotOnMobileCall += new Spokes.NotOnMobileCallEventHandler(m_spokes_NotOnMobileCall); // Docked state m_spokes.Docked += new Spokes.DockedEventHandler(m_spokes_Docked); m_spokes.UnDocked += new Spokes.DockedEventHandler(m_spokes_UnDocked); m_isConnectedToSpokes = m_spokes.Connect("PLTLabsAPI"); // we are connected to Spokes at this point in time // however lets still let connecting app openConnection to a specific device // (even though Spokes PC only has 1 active call control device configured // through spokes settings) // mark constructor as done so we can avoid sending // client app a DeviceChanged callback m_constructordone = true; }
static void Main(string[] args) { spokes = Spokes.Instance; spokes.PutOn += spokes_PutOn; spokes.TakenOff += spokes_TakenOff; spokes.Connect("Spokes Quick Start"); Console.WriteLine("Press enter to quit..."); Console.ReadLine(); spokes.PutOn -= spokes_PutOn; spokes.TakenOff -= spokes_TakenOff; spokes.Disconnect(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { // get Spokes singleton m_spokes = Spokes.Instance; // set us as the Spokes debug logger m_spokes.SetLogger(this); // register event handlers... // detect when Plantronics device is added or removed from PC: m_spokes.Attached += new Spokes.AttachedEventHandler(m_spokes_Attached); m_spokes.Detached += new Spokes.DetachedEventHandler(m_spokes_Detached); // detect when we are on a VoIP call: m_spokes.OnCall += new Spokes.OnCallEventHandler(m_spokes_OnCall); m_spokes.NotOnCall += new Spokes.NotOnCallEventHandler(m_spokes_NotOnCall); // detect when user answers/ends a call using headset buttons: m_spokes.CallAnswered += new Spokes.CallAnsweredEventHandler(m_spokes_CallAnswered); m_spokes.CallEnded += new Spokes.CallEndedEventHandler(m_spokes_CallEnded); // detect when we are on a Mobile call: m_spokes.OnMobileCall += new Spokes.OnMobileCallEventHandler(m_spokes_OnMobileCall); m_spokes.NotOnMobileCall += new Spokes.NotOnMobileCallEventHandler(m_spokes_NotOnMobileCall); m_spokes.MobileCallerId += new Spokes.MobileCallerIdEventHandler(m_spokes_MobileCallerId); // detect if we are wearing the headset: m_spokes.PutOn += new Spokes.PutOnEventHandler(m_spokes_PutOn); m_spokes.TakenOff += new Spokes.TakenOffEventHandler(m_spokes_TakenOff); // detect if headset is docked: m_spokes.Docked += new Spokes.DockedEventHandler(m_spokes_Docked); m_spokes.UnDocked += new Spokes.DockedEventHandler(m_spokes_UnDocked); #if doubloon // NEW CC events m_spokes.Connected += new Spokes.ConnectedEventHandler(m_spokes_Connected); m_spokes.Disconnected += new Spokes.DisconnectedEventHandler(m_spokes_Disconnected); #endif // now connect to Spokes m_spokes.Connect("Hello Spokes 3.0 World"); }
public void StartSocket() { //socketThread = new serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); serverSocket.Bind(new IPEndPoint(0, 8887)); Console.WriteLine("Awaiting Connection"); serverSocket.Listen(0); while (!quit) { clientSocket = serverSocket.Accept(); Console.WriteLine(" >> Accept connection from client"); sendMsg("Hello From Spokes"); if (!connected) { spokes.Connect("Spokes Socket Middleware"); } recMsg(); } }
/// <summary> /// Call setup to instruct PLTLayer object to connect to Plantronics Hub runtime engine /// and register itself so that it can begin to communicate with the attached Plantronics device. /// </summary> /// <param name="AppName">Optional name of your appplication's session within Spokes runtime engine. If omitted it will default to "PLTLayer App".</param> public void setup(string AppName = "PLTLayer App") { try { // Obtain Spokes Wrapper singtleton object instance m_spokes = Spokes.Instance; // request log info m_spokes.SetLogger(this); // Sign up for Plantronics events of interest... // Wearing sensor: m_spokes.PutOn += new Spokes.PutOnEventHandler(m_spokes_PutOn); m_spokes.TakenOff += new Spokes.TakenOffEventHandler(m_spokes_TakenOff); // Proximity: m_spokes.Near += new Spokes.NearEventHandler(m_spokes_Near); m_spokes.Far += new Spokes.FarEventHandler(m_spokes_Far); m_spokes.InRange += new Spokes.InRangeEventHandler(m_spokes_InRange); m_spokes.OutOfRange += new Spokes.OutOfRangeEventHandler(m_spokes_OutOfRange); m_spokes.Docked += new Spokes.DockedEventHandler(m_spokes_Docked); m_spokes.UnDocked += new Spokes.DockedEventHandler(m_spokes_UnDocked); // Mobile caller id: m_spokes.MobileCallerId += new Spokes.MobileCallerIdEventHandler(m_spokes_MobileCallerId); m_spokes.OnMobileCall += new Spokes.OnMobileCallEventHandler(m_spokes_OnMobileCall); m_spokes.NotOnMobileCall += new Spokes.NotOnMobileCallEventHandler(m_spokes_NotOnMobileCall); // Serial Number: m_spokes.SerialNumber += new Spokes.SerialNumberEventHandler(m_spokes_SerialNumber); // Call control: m_spokes.CallAnswered += new Spokes.CallAnsweredEventHandler(m_spokes_CallAnswered); m_spokes.CallEnded += new Spokes.CallEndedEventHandler(m_spokes_CallEnded); m_spokes.CallSwitched += new Spokes.CallSwitchedEventHandler(m_spokes_CallSwitched); m_spokes.OnCall += new Spokes.OnCallEventHandler(m_spokes_OnCall); m_spokes.NotOnCall += new Spokes.NotOnCallEventHandler(m_spokes_NotOnCall); m_spokes.MuteChanged += new Spokes.MuteChangedEventHandler(m_spokes_MuteChanged); m_spokes.CallRequested += new Spokes.CallRequestedEventHandler(m_spokes_CallRequested); // Device attach/detach: m_spokes.Attached += new Spokes.AttachedEventHandler(m_spokes_Attached); m_spokes.Detached += new Spokes.DetachedEventHandler(m_spokes_Detached); m_spokes.CapabilitiesChanged += new Spokes.CapabilitiesChangedEventHandler(m_spokes_CapabilitiesChanged); // Headset connect/disconnect (QD): m_spokes.Connected += new Spokes.ConnectedEventHandler(m_spokes_Connected); m_spokes.Disconnected += new Spokes.DisconnectedEventHandler(m_spokes_Disconnected); // Multiline: m_spokes.MultiLineStateChanged += new Spokes.MultiLineStateChangedEventHandler(m_spokes_MultiLineStateChanged); // Button presses m_spokes.ButtonPress += new Spokes.ButtonPressEventHandler(m_spokes_ButtonPress); m_spokes.BaseButtonPress += new Spokes.BaseButtonPressEventHandler(m_spokes_BaseButtonPress); // Raw Data Received (custom message responses) m_spokes.RawDataReceived += new Spokes.RawDataReceivedEventHandler(m_spokes_RawDataReceived); // Connect to Plantronics SDK m_IsConnected = m_spokes.Connect(AppName); } catch (Exception e) { throw new Exception("Failed to connect to Plantronics SDK. See inner exception.", e); } }