2011-10-13 25 views
1

我的AS3客戶端程序在發送大量消息時未收到發送給它的所有數據。我知道它不是我的服務器導致這個問題,因爲所有的消息都收到併發送正確。我的as3客戶端並沒有收到所有的數據發送。事件SOCKET_DATA未收到AS3中的所有消息

private function socketData(event:ProgressEvent):void { 
     while(this.socket.bytesAvailable} 
      var str:String = this.socket.readUTFBytes(this.socket.bytesAvailable); 
      trace(str); 
     } 
    } 

有沒有人知道解決方案?

回答

1

問題解決了,我剛打開我的路由器上的端口。

2

今天下午我有同樣的問題。最後我想出了一個解決方案: 事實上,你必須讀取字節的消息字節像這樣:

private function socketData (evt:ProgressEvent):void { 
    var msg:String = ""; // create a buffer 
    while (socket.bytesAvailable) { // while there is byte to read 
     var byte:int = socket.readByte(); 
     if (byte==0) { // if we read the end byte 
      trace(msg); // treat your message 
      msg = ""; // free the buffer 
     } else { 
      msg += String.fromCharCode(byte); // else, we add the byte to our buffer 
     } 
    } 
} 

我希望這將幫助你:)

+0

我與OP有同樣的問題,這有幫助,但我仍然有數據到達削減它(似乎我只接收一半的數據在一個案件。) –