I am working on a plugin that should handle communication to and from a server. My code works in a regular html file but I am having problems getting it to work in a plugin. The errors I get are all related to some kind of ‘undefined’ objects. I have changed self to this and vice versa and moved things around but it will not work. I hope that some of you experienced plugin-developers or javascript developers can see the problem:
instanceProto.onCreate = function()
{
this.groupNo = "";
// Declare a proxy to reference the hub.
this.connection = $.hubConnection('http://myserver.com/');
this.myHubProxy = this.connection.createHubProxy('myGameHub');
this.myHubProxy.on('PrivateGameCreated', function (groupNoString) {
self.groupNo = groupNoString;
this.runtime.trigger(cr.plugins_.MyGame.prototype.cnds.PrivateGameCreated, self);
});
...
};
Cnds.prototype.PrivateGameCreated = function ()
{
return groupNo;
};
Acts.prototype.StartPrivateGame = function ()
{
this.connection.start().done(function ()
{
this.myHubProxy.invoke('createPrivateGame');
});
};[/code:2hfbp2t5]