Jump to content

Phaser and SignalR


markh
 Share

Recommended Posts

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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...