Esempio n. 1
0
 /**
  * test parsing the empty package from the corpus
  */
 public function testParse()
 {
     $buf = $this->getBuffer('empty_oscbundle');
     $this->_object->setDataString($buf);
     $this->_object->parse();
     $result = $this->_object->getResult();
     $this->assertEquals($result['address'], "/");
     $this->assertEquals($result['data'], array());
 }
Esempio n. 2
0
/**
 * load broken hexfloat lib
 * 
 * i plan on groking pack/unpack to the extent that i 
 * can do this right in Osc_Parse without needing this.
 */
require_once 'src/Osc/HexFloat.php';
// create a socket
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$r = socket_bind($socket, $ip, $port);
// loop until user interrupt
while (true) {
    // this is what gets each datagram
    if (socket_recvfrom($socket, $b, 9999, 0, $f, $p)) {
        // a parser gets instanciated for each datagram
        $osc = new Osc_Parse();
        $osc->setDebug($debug);
        // pass the datagram buffer
        $osc->setDataString($b);
        // start the parser
        $osc->parse();
        // make some output
        if ($debug) {
            var_dump($osc);
        }
        $r = $osc->getResult();
        $r["sourceip"] = $f;
        $r["sourceport"] = $p;
        var_dump($r);
    }
}