Advertisement
fruffl

understand signals

Jan 26th, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1.     class bar extends \ILLI\Net\Message {}
  2.     class foo extends \ILLI\Net\Message {}
  3.     class bob extends \ILLI\Net\Message {}
  4.    
  5.     $bar = new bar;
  6.     $foo = new foo;
  7.     $bob = new bob;
  8.  
  9. /*
  10. array(7) {
  11.   ["scheme"]=>
  12.   string(3) "tcp"
  13.   ["host"]=>
  14.   string(9) "localhost"
  15.   ["port"]=>
  16.   NULL
  17.   ["username"]=>
  18.   NULL
  19.   ["password"]=>
  20.   NULL
  21.   ["path"]=>
  22.   NULL
  23.   ["body"]=>
  24.   array(0) {
  25.   }
  26. }
  27. */
  28.    
  29.         $foo->registerSignal('username', bar::T_SIGNAL_EMIT_EVENT_INIT, 500, [$bar, 'propertySet']);    // foo::$username -> bar::$username
  30.         $foo->registerSignal('propertySet', bar::T_SIGNAL_EMIT_EVENT_INIT, 500, [$bob, 'propertySet']); // foo::*-> bob::*
  31.        
  32.         $foo->propertySet('scheme', 'http');
  33.         $foo->propertySet('host',   'localfrost');
  34.         $foo->propertySet('username',   'fruffl');
  35.         $foo->propertySet('password',   '12345');
  36.    
  37.     var_dump($foo->to('array'));
  38.     var_dump($bar->to('array'));
  39.     var_dump($bob->to('array'));
  40.  
  41.  
  42. /*
  43. array(7) {
  44.   ["scheme"]=>
  45.   string(4) "http"
  46.   ["host"]=>
  47.   string(10) "localfrost"
  48.   ["port"]=>
  49.   NULL
  50.   ["username"]=>
  51.   string(6) "fruffl"
  52.   ["password"]=>
  53.   string(5) "12345"
  54.   ["path"]=>
  55.   NULL
  56.   ["body"]=>
  57.   array(0) {
  58.   }
  59. }
  60. array(7) {
  61.   ["scheme"]=>
  62.   string(3) "tcp"
  63.   ["host"]=>
  64.   string(9) "localhost"
  65.   ["port"]=>
  66.   NULL
  67.   ["username"]=>
  68.   string(6) "fruffl"
  69.   ["password"]=>
  70.   NULL
  71.   ["path"]=>
  72.   NULL
  73.   ["body"]=>
  74.   array(0) {
  75.   }
  76. }
  77. array(7) {
  78.   ["scheme"]=>
  79.   string(4) "http"
  80.   ["host"]=>
  81.   string(10) "localfrost"
  82.   ["port"]=>
  83.   NULL
  84.   ["username"]=>
  85.   string(6) "fruffl"
  86.   ["password"]=>
  87.   string(5) "12345"
  88.   ["path"]=>
  89.   NULL
  90.   ["body"]=>
  91.   array(0) {
  92.   }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement