The Caller ID JDriver is a library which allows your Java application to receive notifications of incoming telephone calls. The software is designed to work with the CTI Comet USB Caller ID hardware on Win XP, Win Vista, Win 7 and Win 8 platforms via the driver supplied with the hardware which creates a virtual COM port on the computer.
This library, Caller ID JDriver, uses the open source RXTX JAVA Communication library to read from the COM port created by the hardware driver. The library then processes the data stream from the hardware and notifies registered listeners of any incoming calls along with details of the call, such as time, telephone number etc. The library uses the standard Java event notification mechanism to make interfacing Java applications to the CTI hardware a simple task.
The library also contains a Simulator class which can be used to simulate incoming calls thus allowing the testing of your system without having to be connected to the hardware or a telephone line.
The library provides debugging output via a Log4J logger. All the classes in this library log to a logger named "CallerID".
Single CTI Comet Device
Interfacing to a single CTI Comet device is as simple as:
CTICallerID callerID = new CTICallerID(); callerID.addCallerIDListener(new ICallerIDListener() { public void incomingCall(CallerIDEvent event) { // Handle incoming calls } public void callerIDException(Exception e) { // Handle any exceptions caught by the driver } });
The event object passed to the incomingCall object can be queried to see if the telelphone number is known, what the telephone is and the date and time of the call. Further details of the call are available by calling the getSource() method and casting the returned object to type CallerIDMessage which allows access to additional information such as the call type and the reason for no telephone number.
Multiple CTI Comet Devices
Interfacing to multiple CTI Comet devices is also possible. The CTICallerID class has a class method, findCometPorts(), which uses the findcomet.exe
class supplied by Crucible Technologies to find all the com ports with CTI Comet devices. The returned array can be
iterated over to create a CTICallerID object for each port. For example:
String[] ports = findCometPorts(); CTICallerID[] devices = new CTICallerID[ports.length]; for ( int i = 0; i < ports.length; i++ ) { devices[i] = new CTICallerID(ports[i]); }
Simulating Incoming Calls for Testing Purposes
For testing your system you may wish to use the call simulator provided in the library. This can be used as follows:
// create an array of phone numbers to call where 'null' is number withheld String[] nums = new String[] {null, "01482571234", "01482576666", "01482571111", "01482570000", "01482575555", "01482578888"}; CallSimulator sim = new CallSimulator(nums); callerID = new CTICallerID(sim); callerID.addCallerIDListener(new ICallerIDListener() { public void incomingCall(CallerIDEvent event) { // Handle incoming calls } public void callerIDException(Exception e) { // Handle any exceptions caught by the driver } }); // call a random number from the supplied list sim.callRandomNumber();