The following procedures walk you through the individual steps of implementing messaging extensions.
To create an ApplicationMessageFactory object
-
Create the ApplicationMessageFactory object constructor.
This object serializes and deserializes your messaging extension.
_myMessageFactory = function _myMessageFactory(_user) {
_myMessageFactory.constructBase(this, [ _user ]);
}
-
Create the serialize and deserialize functions.
In this example, the serialize method returns a string value, but the return value varies depending on the implementation. The value returned by serialize is what ultimately gets sent.
_myMessageFactory.prototype = {
deserialize: function deserialize(sender, id, content) {
if (id == _myApplicationMessage.Id)
{
return new _myApplicationMessage(content);
}
else
{
return null;
}
},
serialize: function serialize(message) {
return (message).get_myString();
}
}
To create an ApplicationMessage object
-
Create the ApplicationMessage object constructor.
In this example, a custom string value is added.
_myApplicationMessage = function _myApplicationMessage(str) {
_myApplicationMessage.constructBase(this);
this.myString = str;
}
-
Add methods to the ApplicationMessage object.
The get_id() method is always required. In this example, an additional method called get_myString() has been added to handle the custom string value for this class.
_myApplicationMessage.prototype = {
myString: null,
get_id: function get_id() {
return _myApplicationMessage.Id;
},
get_myString: function get_myString() {
return this.myString;
}
}
-
Assign a value to the Id property for the object.
_myApplicationMessage.Id = 'msgid';
To assign the ApplicationMessageFactory to the user and register ApplicationMessage
To send a custom message type
To intercept an incoming custom message type