Command Line Client

This section explains how to implement the Example Entry/Exit Recipes in a command line client.

The following screenshot shows the command line application running. It reads an IP address and port number from the command line, and listens for connections at that IP/port combination.

The reader connects to the listening program and communicates the entry/exit protocol to it. The program only prints out a report for each protocol event it receives.

In this example, the program was started before the recipe 0/0 was defined. When the reader connected, it sent a session start event and then an entry event for the two tags in recipe 1/0. Then recipe 0/0 was created, and the reader 00:11:CE:01:0A:66 was added to it.

When a reader's set of recipes changes, it disconnects all its current devices and starts new sessions, and this is what we see in the trace; 0/0 initially has the same ranges as 1/0, so it has the same tags in it. After this, while 0/0 is being tuned, its angle ranges are changed and some tags leave and enter it again. These events are therefore raised in the program and printed out.

The code to implement this program has only a few lines (in Program.cs).

The main program:

  • Reads and parses the IP address and port number from the command line.
  • Creates a protocol object and adds event handlers to it.
  • Uses the protocol object to create a server, and then runs the server.

The event handlers just print a message when each protocol event occurs.