Forum Multiplayer Cant get bounce server to work

Discussion and help relating to the PlayerIO Multiplayer API.

Cant get bounce server to work

Postby wolfheat_flash » April 8th, 2010, 2:45 am

in my handle Join function I declare 2 listeners, one for hello world and one for yesclick. I get the text to update for hello world but never for yesclick.

Code: Select all
      private function handleJoin(connection:Connection):void{
         trace("Sucessfully connected to the multiplayer server");
         tf_connect.text = "Connected";
         //gotoAndStop(2);
         
         //Handle init message
         //connection.addMessageHandler("init", function(m:Message, myid:int));
            //Set my id so we know who we are
            //myId = myid
            
         connection.send("Hello World");   
            
         connection.addMessageHandler("Hello World", function(m:Message){
            trace(m.type);   
            tf_pressed.text = Message(m).type.toString(); // DISPLAYS "Hello World"         
         });
         connection.addMessageHandler("yesclick", function(m:Message){
            //trace(Message(m).getInt(1));   
            tf_pressed.text = Message(m).type.toString(); // IS NEVER CALLED       
         });
            
      }

Then I call for the yesclick function when clicking on a button, but the handler never recieves it. ie. the text is never updated
wolfheat_flash
 
Posts: 5
Joined: April 8th, 2010, 2:34 am

Re: Cant get bounce server to work

Postby Benjaminsen » April 8th, 2010, 9:46 am

The code looks oki, where do you trigger yesclick from?

/Chris
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Cant get bounce server to work

Postby wolfheat_flash » April 8th, 2010, 4:35 pm

The code seems to work locally. I get the tf_local to update.

Code: Select all
   private function clicked(e:MouseEvent):void {
      if (e.target is Yes) {
         trace("YES");
         //var m:Message = connection.createMessage("yesClick");
         trace("message created");
         //trace("message type="+m.type);
         //connection.sendMessage(m);
         tf_local.text = "Yes clicked";
         connection.send("yesclick", int(Math.floor(Math.random() * 10)));
      }
   }
wolfheat_flash
 
Posts: 5
Joined: April 8th, 2010, 2:34 am

Re: Cant get bounce server to work

Postby wolfheat_flash » April 8th, 2010, 5:08 pm

Seems like I cant get the send to work outside handleJoin.

EDIT:
I think I fixed the problem. I changed this
public function handleJoin(connection:Connection):void {

to

public function handleJoin(new_connection:Connection):void {
connection = new_connection;
wolfheat_flash
 
Posts: 5
Joined: April 8th, 2010, 2:34 am


Return to Multiplayer