alaabataineh / php-rtmp-client

Automatically exported from code.google.com/p/php-rtmp-client
1 stars 0 forks source link

Does not parse multiple arguments coming back from server #12

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If the server invokes a method on the client, it does not parse multiple 
arguments. Here is a quick fix for that issue:

Index: RtmpMessage.class.php
===================================================================
--- RtmpMessage.class.php       (revision 26)
+++ RtmpMessage.class.php       (working copy)
@@ -96,15 +96,20 @@
                $this->commandName = $deserializer->readAMFData();
                $this->transactionId = $deserializer->readAMFData();
                $this->commandObject = $deserializer->readAMFData();
+               $args = array();
                try
                {
-                       $this->arguments = $deserializer->readAMFData();
+                       for($i=0; $i<100; $i++)
+                        $args[] = $deserializer->readAMFData();
                }
                catch(Exception $e)
                {
                        //if not exists InputStream throw exeception
-                       $this->arguments = null;
+                       //$this->arguments = null;
                }
+
+               $this->arguments = $args;
+
                if(($this->commandName == "_error") || (is_array($this->arguments) && !empty($this->arguments) && isset($this->arguments['level']) && ($this->arguments['level']=='error')))
                        $this->_isError = true;
        }

Original issue reported on code.google.com by dro...@gmail.com on 25 Mar 2011 at 11:16

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
yeah i noticed that too.

I used a while rather than a for loop though, this way you don't have to 
hardcode a max number of arguments :

- for($i=0; $i<100; $i++)
+ while($arg = $deserializer->readAMFData())

- $args[] = $deserializer->readAMFData();
+ $args[] = $arg;

Also, it "fixes" the invokes but breaks the response to calls.

You could tweak it with :

if($this->commandName == "_result")
  $this->arguments = $args[0];
else
  $this->arguments = $args;

But it stays a tweak

Original comment by contact....@gmail.com on 2 May 2012 at 11:26