3 Replies Latest reply on May 11, 2010 7:33 PM by kglad

    sending values to server

    SOMEONEINTHEWORLD

      Hello,

       

      I have a client in flash sending values to server.  At first time i am sending the value 150.  The server responds to returns some data.  On receiving that data the client should again send some value to server.  Where should i have to write mySocket.send to do it.  i tried doing it inside the function,

      XMLSocket.prototype.onData = function(msg) { its not working.  Please help me out

       

      mySocket = new XMLSocket();
      mySocket.connect("127.0.0.1", 1234);
      System.security.loadPolicyFile("http://localhost/sockets/flash_policy.php");

       

      mySocket.onConnect = function(success) {
          if (success) {
              msgArea.htmlText += "<b>Server connection established!</b>";
              mySocket.send("hello"+"\n");
          } else {
              msgArea.htmlText += "<b>Server connection failed!</b>";
          }
      };
      mySocket.onClose = function() {
          msgArea.htmlText += "<b>Server connection lost</b>";
      };
      XMLSocket.prototype.onData = function(msg) {
          trace(msg);
          //arr = msg.split("&");
          //msgArea.htmlText += arr[1];   
      };

       

      //--- Handle button click --------------------------------------
      function msgGO() {
          if (inputMsg.htmlText != "") {
              mySocket.send(inputMsg.htmlText+"\n");
              inputMsg.htmlText = "";
          }
      }
      pushMsg.onRelease = function() {
          msgGO();
      };

        • 1. Re: sending values to server
          kglad Adobe Community Professional & MVP

          use a setTimeout() function (with a delay of, at least, 500ms) in your onData() method so you don't stuff your connection.

          • 2. Re: sending values to server
            SOMEONEINTHEWORLD Level 1

            Thanks.

             

             

            I should have been more clearly specified what i really wanted.

             

            first time, i send 150 value to the server.

             

            The server would send 151

             

            Then i should send 152.

             

            this pattern goes on till 192

             

            so, should i have to put the socket.send(152) ///values goes on till 192

             

            should i have to write,

            XMLSocket.prototype.onData = function(msg) {

                if(msg == 151)
                setTimeout(mySockt.send, 250, "152");

                elseif(msg == 153)

                setTimeout(mySockt.send, 250, "154");

             

            etc..

             

             

            or in the,

            if i do it, i won't be able to compare the server data - whether i received corret data or not that is 151 etc

            mySocket.onConnect = function(success) {

             

            }

            • 3. Re: sending values to server
              kglad Adobe Community Professional & MVP

              mySockt looks like a typo.

               

              and you should call a function that applies the send method to your socket.