private void OnPltEvent(PltEventArgs e) { if (PltEvent != null) { PltEvent(this, e); } }
private void OnPltEvent(PltEventArgs e) { if (PltEvent != null) PltEvent(this, e); }
/// <summary> /// 5. Handle events received from Plantronics /// /// This event handler method is called by PLTLayer whenever a /// Plantronics event occurs, e.g. device events, call state events etc. /// /// By examining the "e.EventType" and "e.MyParams" parameters, your /// app can see what the event was and additional information about the event. /// For example, in the case of EventType SerialNumber, you get 2 MyParams /// strings, the first is the Serial Number (also known as Genes id), the second /// contains whether it is a Base or Headset serial. /// </summary> /// <param name="sender">The object that has sent us the event, in this case /// the PLTLayer object.</param> /// <param name="e">The arguments for this event, containing the EventType /// and for some EventTypes a list of useful parameters (as strings) that /// are specific to the EventType.</param> static void plt_PltEvent(object sender, PltEventArgs e) { // Example processing of incoming events/parameters to inform my app // what is happening with Plantronics: switch (e.EventType) { // BASIC SOFTPHONE CALL CONTROL EVENTS: // case PltEventType.CallAnswered: Console.WriteLine("> Plantronics answered a Softphone Call:\r\n" + "Call Id: " + e.MyParams[0] + "\r\n" + "Call Source: " + e.MyParams[1]); // is the call in my app? if (e.MyParams[1] == MY_APP_NAME) { Console.WriteLine("\r\nTHIS CALL ID: " + e.MyParams[0] + " IS IN MY APP!: " + MY_APP_NAME); // TODO: here you would answer the call in your app } break; case PltEventType.CallEnded: Console.WriteLine("> Plantronics ended a Softphone Call:\r\n" + "Call Id: " + e.MyParams[0] + "\r\n" + "Call Source: " + e.MyParams[1]); // is the call in my app? if (e.MyParams[1] == MY_APP_NAME) { Console.WriteLine("\r\nTHIS CALL ID: " + e.MyParams[0] + " IS IN MY APP!: " + MY_APP_NAME); // TODO: here you would end the call in your app } break; case PltEventType.Muted: Console.WriteLine("> Plantronics was muted"); // TODO: syncronise with your app's mute feature break; case PltEventType.UnMuted: Console.WriteLine("> Plantronics was un-muted"); // TODO: syncronise with your app's mute feature break; // ADVANCED SOFTPHONE CALL CONTROL EVENTS: // case PltEventType.OnCall: Console.WriteLine("> Plantronics went on Softphone Call:\r\n" + "Call Id: " + e.MyParams[0] + "\r\n" + "Call Source: " + e.MyParams[1] + "\r\n" + "Is Incoming?: " + e.MyParams[2] + "\r\n" + "Call State: " + e.MyParams[3]); // is the call in my app? if (e.MyParams[1] == MY_APP_NAME) { Console.WriteLine("\r\nTHIS CALL ID: " + e.MyParams[0] + " IS IN MY APP!: " + MY_APP_NAME); // OnCall event is for information only. // you should use CallAnswered event to answer the call in your app } else { // TODO: optional syncronise with your app's agent availability feature } break; case PltEventType.NotOnCall: Console.WriteLine("> Plantronics ended a Softphone Call:\r\n" + "Call Id: " + e.MyParams[0] + "\r\n" + "Call Source: " + e.MyParams[1]); // is the call in my app? if (e.MyParams[1] == MY_APP_NAME) { Console.WriteLine("\r\nTHIS CALL ID: " + e.MyParams[0] + "WAS IN MY APP!: " + MY_APP_NAME); // NotOnCall event is for information only. // you should use CallEnded event to end the call in your app } else { // TODO: optional syncronise with your app's agent availability feature } break; case PltEventType.CallSwitched: Console.WriteLine("> Plantronics switched a Softphone Call"); // this event is for information only, the callid of activated call will // be available via a CallAnswered event break; case PltEventType.CallRequested: Console.WriteLine("> Plantronics dialpad device requested (dialed) a Softphone Call to this contact:\r\n" + "Email: " + e.MyParams[0] + "\r\n" + "FriendlyName: " + e.MyParams[1] + "\r\n" + "HomePhone: " + e.MyParams[2] + "\r\n" + "Id: " + e.MyParams[3] + "\r\n" + "MobilePhone: " + e.MyParams[4] + "\r\n" + "Name: " + e.MyParams[5] + "\r\n" + "Phone: " + e.MyParams[6] + "\r\n" + "SipUri: " + e.MyParams[7] + "\r\n" + "WorkPhone: " + e.MyParams[8]); // TODO: optional: here you would dial an outgoing call in your app break; // PLANTRONICS MULTI-LINE DEVICE EVENTS (e.g. Savi 700 Series): // case PltEventType.MultiLineStateChanged: Console.WriteLine("> Plantronics multiline state changed: \r\n" + " PC Line: Active?: " + e.MyParams[0] + ", Held?: " + e.MyParams[1] + "\r\n" + " Mobile Line: Active?: " + e.MyParams[2] + ", Held?: " + e.MyParams[3] + "\r\n" + "Deskphone Line: Active?: " + e.MyParams[4] + ", Held?: " + e.MyParams[5]); // TODO: optional syncronise with your app's agent availability feature break; // PLANTRONICS "GENES ID" FEATURE EVENTS (DEVICE SERIAL NUMBERS): // case PltEventType.SerialNumber: if (e.MyParams[0] != "") { Console.WriteLine("> Plantronics Genes ID (Serial Number) was received:\r\n" + "Serial Number: " + e.MyParams[0] + "\r\n" + "Serial Type: " + e.MyParams[1]); } // TODO: optional syncronise with your app's agent tracking system // (e.g. asset tracking or used to apply user personalised settings, i.e. on shared workstation) break; // PLANTRONICS "CONTEXTUAL INTELLIGENCE FEATURE EVENTS: // case PltEventType.PutOn: Console.WriteLine("> Plantronics was put on"); // TODO: optional syncronise with your app's agent availability feature break; case PltEventType.TakenOff: Console.WriteLine("> Plantronics was taken off"); // TODO: optional syncronise with your app's agent availability feature break; case PltEventType.Near: Console.WriteLine("> Plantronics in wireless range: NEAR"); // TODO: optional syncronise with your app's agent availability feature break; case PltEventType.Far: Console.WriteLine("***************************************************************************"); Console.WriteLine("> Plantronics in wireless range: FAR"); Console.WriteLine("***************************************************************************"); // TODO: optional syncronise with your app's agent availability feature break; case PltEventType.InRange: Console.WriteLine("> Plantronics came into wireless range"); // TODO: optional syncronise with your app's agent availability feature break; case PltEventType.OutOfRange: Console.WriteLine("> Plantronics went out of wireless range"); // TODO: optional syncronise with your app's agent availability feature break; case PltEventType.Docked: Console.WriteLine("> Plantronics was docked"); // TODO: optional syncronise with your app's agent availability feature break; case PltEventType.UnDocked: Console.WriteLine("> Plantronics was un-docked"); // TODO: optional syncronise with your app's agent availability feature break; case PltEventType.Connected: Console.WriteLine("> Plantronics was connected to QD connector " + (Convert.ToBoolean(e.MyParams[1]) ? "(initially)" : "")); // TODO: optional syncronise with your app's agent availability feature break; case PltEventType.Disconnected: Console.WriteLine("> Plantronics was disconnected from QD connector " + (Convert.ToBoolean(e.MyParams[1]) ? "(initially)" : "")); // TODO: optional syncronise with your app's agent availability feature break; case PltEventType.LineActive: Console.WriteLine("> Plantronics wireless link went ACTIVE."); // TODO: optional your app can know Plantronics line went active (especially for wireless products) break; case PltEventType.LineInactive: Console.WriteLine("> Plantronics wireless link went in-active."); // TODO: optional your app can know Plantronics line went active (especially for wireless products) break; // PLANTRONICS DEVICE INFORMATION EVENTS: // case PltEventType.Attached: m_deviceAttached = true; Console.WriteLine("\r\n> Plantronics was attached: Product Name: " + e.MyParams[0] + ", Product Id: " + Int32.Parse(e.MyParams[1]).ToString("X")+"\r\n"); // TODO: optional: switch your app to headset audio mode when Plantronics attached break; case PltEventType.Detached: m_deviceAttached = false; Console.WriteLine("> Plantronics was detached"); // TODO: optional: switch your app to non-headset audio mode when Plantronics detached break; case PltEventType.CapabilitiesChanged: m_deviceCapabilities = e.MyParams; // Optional: uncomment for debugging purposes // Console.WriteLine(" [device features: " // + "docking: " + e.MyParams[0] + ", " // + "mob callid: " + e.MyParams[1] + ", " // + "mob state: " + e.MyParams[2] + "\r\n" // + " multiline: " + e.MyParams[3] + ", " // + "proximit: " + e.MyParams[4] + ", " // + "wearstate: " + e.MyParams[5] + ", " // + "wireless: " + e.MyParams[6] + "]"); // TODO: optional: use this information to know what features/events to expect from // Plantronics device in your app break; // MOBILE CALL CONTROL EVENTS (e.g. Voyager Legend, Voyager Edge, Calisto 620): // case PltEventType.OnMobileCall: Console.WriteLine("> Plantronics went on Mobile Call:\r\n" + "Is Incoming?: " + e.MyParams[0] + "\r\n" + "Call State: " + e.MyParams[1]); // TODO: optional syncronise with your app's agent availability feature break; case PltEventType.MobileCallerId: Console.WriteLine("> Plantronics reported Mobile Caller Id (remote party phone number):\r\n" + "Mobile Caller Id?: " + e.MyParams[0]); // TODO: optional syncronise with your app's contacts database / CRM system break; case PltEventType.NotOnMobileCall: Console.WriteLine("> Plantronics ended a Mobile Call"); // TODO: optional syncronise with your app's agent availability feature break; // OTHER DEVICE EVENTS: // case PltEventType.BaseButtonPressed: Console.WriteLine("> Plantronics base button pressed: button id: " + e.MyParams[0]); // BaseButtonPressed event is for information only // Note: some devices will generate button events internally even when no // physical button is pressed. break; case PltEventType.ButtonPressed: Console.WriteLine("> Plantronics button pressed: button id: " + e.MyParams[0]); // ButtonPressed event is for information only // Note: some devices will generate button events internally even when no // physical button is pressed. break; // for debugging: //case PltEventType.RawDataReceived: // Console.WriteLine("\r\n" + DateTime.Now + "r:" + e.MyParams[0]); // break; } // Example debug output to show ALL events/parameters (commented out) //Console.WriteLine("\r\nPltEvent received: " + e.EventType.ToString()); //if (e.MyParams != null && e.MyParams.Count() > 0) //{ // Console.WriteLine("Params: "); // int i = 0; // foreach (string param in e.MyParams) // { // Console.Write((++i).ToString() + " "); // Console.WriteLine(param); // } //} }