There are going to be several posts about the GPlus Adapter for Aspect WFM, but this one has saved me the most time so far.
In attempting to debug the RTA feed at a client site, in which I had no access to the Aspect RTA console, I came up with a little application to show me exactly what was being sent to the feed. Written in C#, it’s simply a small console application that accepts the RTA TCP messages, and displays the content.
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace AspectRTASimulator
{
class Program
{
static StreamWriter log = null;
static void Main(string[] args)
{
TcpListener server = null;
log = new StreamWriter(Properties.Settings.Default.LogFile + "RTASimulator.log",true);
log.WriteLine("Aspect RTA Simulator - © 2015, Jim Ezzell");
log.WriteLine("Starting RTA Server");
log.Flush();
try
{
// Set the TcpListener on port 13000.
Int32 port = Properties.Settings.Default.ListenPort;
IPAddress localAddr = IPAddress.Parse(Properties.Settings.Default.ListenIP);
// TcpListener server = new TcpListener(port);
server = new TcpListener(localAddr, port);
// Start listening for client requests.
server.Start();
// Buffer for reading data
Byte[] bytes = new Byte[1024];
String data = null;
// Enter the listening loop.
while (true)
{
Console.WriteLine("Waiting for a connection... ");
// Perform a blocking call to accept requests.
// You could also user server.AcceptSocket() here.
TcpClient client = server.AcceptTcpClient();
Console.WriteLine(client.Client.RemoteEndPoint.ToString());
Console.WriteLine("Connected!");
data = null;
// Get a stream object for reading and writing
NetworkStream stream = client.GetStream();
int i;
// Loop to receive all the data sent by the client.
while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
{
// Translate data bytes to a ASCII string.
data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
Console.WriteLine("Received: {0}", data);
// Process the data sent by the client.
data = data.ToUpper();
byte[] msg = System.Text.Encoding.ASCII.GetBytes(data);
// Send back a response.
stream.Write(msg, 0, msg.Length);
//Console.WriteLine("Sent: {0}", data);
}
// Shutdown and end connection
client.Close();
}
}
catch (SocketException e)
{
Console.WriteLine("SocketException: {0}", e);
}
finally
{
// Stop listening for new clients.
server.Stop();
}
log.Close();
Console.WriteLine("\nHit enter to continue...");
Console.Read();
}
}
}
Code language: C# (cs)
Settings are stored in the app.config file:
<userSettings>
<AspectRTASimulator.Properties.Settings>
<setting name="ListenPort" serializeAs="String">
<value>7001</value>
</setting>
<setting name="ListenIP" serializeAs="String">
<value>10.109.159.132</value>
</setting>
<setting name="LogFile" serializeAs="String">
<value>c:\logs\RTASimulator\</value>
</setting>
</AspectRTASimulator.Properties.Settings>
</userSettings>
Code language: HTML, XML (xml)
When it runs, it simply shows the messages, with no manipulation. This could easily be extended to a windows app that would show the messages in a better format.
When I ran it, I actually replaced the aspect.host address with the address of my local server. You can also setup a secondary feed in the GPlus adapter to allow both feeds to run simultaneously by creating a new rta:<stream> section in the application configuration in CME or GA.
As a side note, this was developed on my own time, and not as part of any customer/employer paid engagement.