markh Posted October 6, 2014 Share Posted October 6, 2014 I know this is probably simple, but I'm trying to use game state objects to manage what I want. I am using SignalR to keep every client up to date. I can successfully call the Hub Object (Server Side), but I can't figure out how to set up the client side code for the callback. Below is a snippet. obj.StartMenu = function(game) { this.points; this.updatepointsbutton; this.hub = $.connection.HubServer; $.connection.hub.start(); } obj.StartMenu.prototype = { preload: function(){ this.updatepointsbutton = this.load.spritesheet('button', '/Content/images/button_sprite_sheet.png', 193, 71); }, create: function () { this.updatepointsbutton = this.add.button(0, 50, 'button', this.updatePoints, this, 2, 1, 0);}, updatePoints: function () { this.hub.server.updatePoints(); //This works and calls the Hub }, ////THIS IS THE CODE I'm trying to invoke on the call back, but it doesn't work./// I get no errors though. this.hub.client.updatepointsforall = function (){ this.points++;}, }; Any Help is much appreciated.I think it is simple, just missing it. Thanks in Advance Link to comment Share on other sites More sharing options...
bulkan Posted October 7, 2014 Share Posted October 7, 2014 Is the following function not being called ?this.hub.client.updatepointsforall = function (){ this.points++;}As you're not getting any errors have you tried putting in a `console.log` or a breakpoint in Chrome Dev Tools to see if its being called. Link to comment Share on other sites More sharing options...
markh Posted October 7, 2014 Author Share Posted October 7, 2014 I have tried that and nothing in the console, etc If I move the code to a separate javascript file the callback works. It seems to have something to do with being in the obj.StartMenu.prototype block of code. Very intriguing. I may have to redesign the way it is all wired up, but the code was pretty clean (used a "template") so didn't want to if I didn't have to. Link to comment Share on other sites More sharing options...
Orbital Game Studios Posted October 7, 2014 Share Posted October 7, 2014 Just a thought, but have you looked at the code for the HTML5 game ShootR that is based on SignalR? https://github.com/ntaylormullen/shootr Link to comment Share on other sites More sharing options...
markh Posted October 7, 2014 Author Share Posted October 7, 2014 I haven't. It seems to be the way I am implementing Phaser code. I'm probably going to have to rewire it. Link to comment Share on other sites More sharing options...
Recommended Posts