Pigeon Agents Development REST API Functions - DatasmithSA/Pigeon-Voice-Training GitHub Wiki

Pigeon Voice Server provides a REST API for interacting with the server from a third party application. The PVWebClient is a web client utility class provided in the Pigeon Voice SDK allowing easy consumption of the REST API from a .NET application.

In order to use the PVWebClient in your application, you will need to reference the Pigeon.Voice.SDK.dll which can be found in the Pigeon Voice Server's installation directory: C:\Program Files (x86)\Datasmith\Pigeon Voice Server

  • Constructing a PVWebClient: the web client can be constructed by passing i the following parameters on the constructor:

    • URL: of the Pigeon Voice REST API.
    • Username & Password: of an authorised Windows user. The username and password is only necessary if the REST Service User Authentication setting is enabled on the server, which will enable Windows Authentication on the REST API. If this setting is disabled, the username and password may be omitted i.e. nulls can be passed in.
    • Timeout: the web request timeout when calling the Pigeon Voice REST API with the the PVWebClient.
        private static PVWebClient CreatePigeonVoiceWebClient()
        {
            return new PVWebClient(
                "http://127.0.0.1:80/PigeonVoice", 
                Environment.UserName, 
                "password", 30000);
        }

Although more features are in the development pipeline, the following functions are currently available through the REST API and and PVWebClient:

  • ConnectionTest: performing a connection test to ensure the Pigeon Voice Server is online and accessible. The function returns back the logged in user.
        private static void ConnectionTest()
        {
            string userName = (new PVWebClient(
                "http://127.0.0.1:80/PigeonVoice", 
                Environment.UserName, "" +
                "password", 30000)).ConnectionTest();

            Console.WriteLine("Logged in user: {0}", userName);
        }
  • GetConnectedDevices: returns a list of DeviceInfo objects representing devices that are currently connected to the Pigeon Voice Server. Each device DeviceInfo object provides, the OperatorId that is currently logged in on the device, the device ID (serial number), the last message that was received from the device, the date/time on the device as well as the server date/time of the last message request.
       private static void GetConnectedDevices()
        {
            List<DeviceInfo> connectedDevice = (new PVWebClient(
                "http://127.0.0.1:80/PigeonVoice", 
                Environment.UserName, "password", 30000)).GetConnectedDevices();

            Console.WriteLine("Devices Connected to Pigeon Voice Server");
            connectedDevice.ForEach(device =>
            {
                Console.WriteLine(device.DeviceId);
                Console.WriteLine(device.LastOperatorId);
                Console.WriteLine(device.LastRequestMessage);
                Console.WriteLine(device.LastClientDateTimeConnected);
                Console.WriteLine(device.LastServerDateTimeConnected);
            });
        }
  • GetAgentData: calls a Pigeon Web Agent with a set of input parameters and lists the list of records returned by the Agent. In the example below we're calling an example Web Agent described on this page.
        private static void GetAgentData()
        {
            string commandName = "WebCountAgent"; //Send the quantity picked to the Pigeon Server.
            DateTime clientDateTime = DateTime.Now;
            string deviceId = string.Format("{0}.{1}", Environment.UserDomainName, Environment.MachineName);
            string operatorId = Environment.UserName;
            string inputFieldsCsv = "5 4 X 3 2,39";  //Location = 54 x 3 2 and Quantity = 39
            PVWebResponse response = (new PVWebClient(
                "http://127.0.0.1:80/PigeonVoice", 
                Environment.UserName, 
                "27830529", 
                30000)).GetAgentData(
                commandName,
                clientDateTime,
                deviceId,
                operatorId,
                inputFieldsCsv);

            Console.WriteLine("Response received from the Pigeon Voice Server WebCountAgent");
            response.Records.ForEach(record => Console.WriteLine(record.ToString()));
        }
⚠️ **GitHub.com Fallback** ⚠️