Monitoring presence, getting event error

I’m using the following code:

var app = require('app');
var util = require('util');
app.init();

var presenceReporter = { };
presenceReporter.bindListeners = function() {
		digium.event.observe({
			'eventName' : 'digium.phone.contact_presence',
			'callback' : this.reportPresence()
		});
};

presenceReporter.reportPresence = function(params) {
		//var msg = params.eventData;
		util.debug("Presence Changed: ");
		util.debug(JSON.stringify(params));
};
presenceReporter.init = function () {
	digium.app.exitAfterBackground = false;
	this.bindListeners();
};
presenceReporter.init();

This code works the first time it starts, then every other time the event is fired, I get the following error:
error executing handler for event digium.phone.contact_presence: TypeError: Property ‘0’ of object is not a function

I’m a C# developer so JS is new to me.

jfulfordtdn, At first glance, this looks OK to me.

I’ll set it up today and try it out and get back to you.

Now I feel silly that I had to set this up to see the error.

You need to make sure ‘callback’ is the function object, not the result from calling the function.

In your code, change the following block:

var presenceReporter = { };
presenceReporter.bindListeners = function() {
      digium.event.observe({
         'eventName' : 'digium.phone.contact_presence',
         'callback' : this.reportPresence()
      });
};

to this:

var presenceReporter = { };
presenceReporter.bindListeners = function() {
      digium.event.observe({
         'eventName' : 'digium.phone.contact_presence',
         'callback' : this.reportPresence
      });
};