Example #1
0
        /// <summary>
        /// Allows your softphone application to inform Plantronics device about an outgoing call. Note: will automatically open audio/rf link to wireless device.
        /// </summary>
        /// <param name="callid">A unique numeric identifier for the call that your application and Spokes will use to identify it as.</param>
        /// <param name="contactname">Optional caller's contact name that will display on Plantronics display devices, e.g. Calisto P800 and P240 devices.</param>
        /// <returns>Boolean indicating if command was issued successfully or not.</returns>
        public bool OutgoingCall(int callid, string contactname = "")
        {
            bool success = false;
            try
            {
                if (m_comSession != null)
                {
                    ContactCOM contact = new ContactCOM();
                    contact.SetName(contactname);
                    CallCOM call = new CallCOM();
                    call.SetId(callid);

                    m_comSession.GetCallCommand().OutgoingCall(call, contact, CallAudioRoute.AudioRoute_ToHeadset);
                    ConnectAudioLinkToDevice(true);
                    success = true;
                }
            }
            catch (Exception) { success = false; }
            return success;
        }
Example #2
0
        //Responsible for processing messages that have arrived via a websocket connection
        private static void HandleMessage(String message)
        {
            if (m_activeDevice == null)
            {
                Console.WriteLine("no active device, ignoring message");
                return;
            }

            PlantronicsMessage m = PlantronicsMessage.ParseMessageFromJSON(message);
            if (m.Type == PlantronicsMessage.MESSAGE_TYPE_SETTING)
            {
                if (m.Id == PlantronicsMessage.SETTING_HEADSET_INFO)
                {
                    PlantronicsMessage response = new PlantronicsMessage(PlantronicsMessage.MESSAGE_TYPE_SETTING, PlantronicsMessage.SETTING_HEADSET_INFO);
                    Device device = new Device();
                    device.InternalName = m_activeDevice.InternalName;
                    device.ManufacturerName = m_activeDevice.ManufacturerName;
                    device.ProductName = m_activeDevice.ProductName;
                    device.VendorId = String.Format("0x{0:X}", m_activeDevice.VendorID);
                    device.ProductId = String.Format("0x{0:X}", m_activeDevice.ProductID);
                    device.VersionNumber = m_activeDevice.VersionNumber;

                    //TODO fixup CAB - make this eventually come from Spokes or a dictionary lookup
                    device.NumberOfChannels = 1;
                    device.SampleRate = 16000;

                    response.AddToPayload("device", device);
                    BroadcastMessage(response);
                }

            }
            else if (m.Type == PlantronicsMessage.MESSAGE_TYPE_COMMAND)
            {
                if (m.Id == PlantronicsMessage.COMMAND_RING_ON)
                {
                    Console.WriteLine("Ringing headset");
                    Object o = null;
                    if (!m.Payload.TryGetValue("offer", out o))
                    {
                        Console.WriteLine("Unable to get caller id from the message skipping headset ring operation");
                        return;
                    }
                    offer = o as Hashtable;
                    ContactCOM contact = new ContactCOM() { Name = offer["from"] as String };
                    callId = (int)(double)m.Payload["callId"];
                    CallCOM call = new CallCOM() { Id = callId };
                    m_comSession.CallCommand.IncomingCall(call, contact, RingTone.RingTone_Unknown, AudioRoute.AudioRoute_ToHeadset);

                }
                else if (m.Id == PlantronicsMessage.COMMAND_HANG_UP)
                {
                    CallCOM call = new CallCOM() { Id = callId };
                    m_comSession.CallCommand.TerminateCall(call);

                }
                else if (m.Id == PlantronicsMessage.COMMAND_RING_OFF)
                {
                    Console.WriteLine("Turning ring off headset");
                    m_activeDevice.HostCommand.Ring(false);

                }
                else if (m.Id == PlantronicsMessage.COMMAND_MUTE_ON)
                {
                    Console.WriteLine("Muting headset");
                    m_activeDevice.DeviceListener.Mute = true;

                }
                else if (m.Id == PlantronicsMessage.COMMAND_MUTE_OFF)
                {
                    Console.WriteLine("Unmuting headset");
                    m_activeDevice.DeviceListener.Mute = false;

                }
            }
            else if (m.Type == PlantronicsMessage.MESSAGE_TYPE_EVENT)
            {
                Console.WriteLine("Event message received");
            }
        }
Example #3
0
        //Responsible for processing messages that have arrived via a websocket connection
        private static void HandleMessage(String message)
        {
            if (m_activeDevice == null)
            {
                Console.WriteLine("no active device, ignoring message");
                return;
            }

            PlantronicsMessage m = PlantronicsMessage.ParseMessageFromJSON(message);

            if (m.Type == PlantronicsMessage.MESSAGE_TYPE_SETTING)
            {
                if (m.Id == PlantronicsMessage.SETTING_HEADSET_INFO)
                {
                    PlantronicsMessage response = new PlantronicsMessage(PlantronicsMessage.MESSAGE_TYPE_SETTING, PlantronicsMessage.SETTING_HEADSET_INFO);
                    Device             device   = new Device();
                    device.InternalName     = m_activeDevice.InternalName;
                    device.ManufacturerName = m_activeDevice.ManufacturerName;
                    device.ProductName      = m_activeDevice.ProductName;
                    device.VendorId         = String.Format("0x{0:X}", m_activeDevice.VendorID);
                    device.ProductId        = String.Format("0x{0:X}", m_activeDevice.ProductID);
                    device.VersionNumber    = m_activeDevice.VersionNumber;

                    //TODO fixup CAB - make this eventually come from Spokes or a dictionary lookup
                    device.NumberOfChannels = 1;
                    device.SampleRate       = 16000;

                    response.AddToPayload("device", device);
                    BroadcastMessage(response);
                }
            }
            else if (m.Type == PlantronicsMessage.MESSAGE_TYPE_COMMAND)
            {
                if (m.Id == PlantronicsMessage.COMMAND_RING_ON)
                {
                    Console.WriteLine("Ringing headset");
                    Object o = null;
                    if (!m.Payload.TryGetValue("offer", out o))
                    {
                        Console.WriteLine("Unable to get caller id from the message skipping headset ring operation");
                        return;
                    }
                    offer = o as Hashtable;
                    ContactCOM contact = new ContactCOM()
                    {
                        Name = offer["from"] as String
                    };
                    callId = (int)(double)m.Payload["callId"];
                    CallCOM call = new CallCOM()
                    {
                        Id = callId
                    };
                    m_comSession.CallCommand.IncomingCall(call, contact, RingTone.RingTone_Unknown, AudioRoute.AudioRoute_ToHeadset);
                }
                else if (m.Id == PlantronicsMessage.COMMAND_HANG_UP)
                {
                    CallCOM call = new CallCOM()
                    {
                        Id = callId
                    };
                    m_comSession.CallCommand.TerminateCall(call);
                }
                else if (m.Id == PlantronicsMessage.COMMAND_RING_OFF)
                {
                    Console.WriteLine("Turning ring off headset");
                    m_activeDevice.HostCommand.Ring(false);
                }
                else if (m.Id == PlantronicsMessage.COMMAND_MUTE_ON)
                {
                    Console.WriteLine("Muting headset");
                    m_activeDevice.DeviceListener.Mute = true;
                }
                else if (m.Id == PlantronicsMessage.COMMAND_MUTE_OFF)
                {
                    Console.WriteLine("Unmuting headset");
                    m_activeDevice.DeviceListener.Mute = false;
                }
            }
            else if (m.Type == PlantronicsMessage.MESSAGE_TYPE_EVENT)
            {
                Console.WriteLine("Event message received");
            }
        }
Example #4
0
 /// <summary>
 /// Allows your softphone application to inform Plantronics device about an outgoing call. Note: will automatically open audio/rf link to wireless device.
 /// </summary>
 /// <param name="callid">A unique numeric identifier for the call that your application and Spokes will use to identify it as.</param>
 /// <param name="contactname">Optional caller's contact name that will display on Plantronics display devices, e.g. Calisto P800 and P240 devices.</param>
 /// <returns>Boolean indicating if command was issued successfully or not.</returns>
 public bool OutgoingCall(int callid, string contactname = "")
 {
     bool success = false;
     try
     {
         if (m_comSession != null)
         {
             ContactCOM contact = new ContactCOM() { Name = contactname };
             CallCOM call = new CallCOM() { Id = callid };
             m_comSession.CallCommand.OutgoingCall(call, contact, AudioRoute.AudioRoute_ToHeadset);
             ConnectAudioLinkToDevice(true);
             success = true;
         }
     }
     catch (Exception) { success = false; }
     return success;
 }