4 Replies Latest reply on Oct 18, 2010 11:36 AM by M Kaufman

    Extreme lag on client when posting




      I'm trying to create a realtime multiplayer game by using Flash Player 10.1's new P2P capabilities. However, I'm having some problems.


      To make it realtime I need to send updates of player positions very often. Right now I do something like this every frame:



      var user_info:ByteArray = new ByteArray ();

      user_info.writeByte (USER_POSITION); //type

      user_info.writeUnsignedInt (player_id); //id

      user_info.writeShort (int(player.x)); //x

      user_info.writeShort (int(player.y)); //y

      user_info.writeUnsignedInt (Connect.getMsgSeq ()); //unique msg id


      group.post (user_info);



      Now, the problem I'm having is that when I have this code running every frame my application lags a lot, even if no one else is connected to the group. If I simply comment out the line "group.post (user_info);" then the lag disappears (but then it doesn't send anything of course).


      Surely there should be a way to send a simple message like that without slowing down my application. Have I missed something?


      I'm thankful for any help or insight.