示例#1
0
 public function handle()
 {
     printf("Will bind on %s\n", $this->sock);
     $this->puller->bind($this->sock);
     $this->puller->filter(function (Event $event) {
         return $event->is("/keepalive");
     })->subscribeCallback([$this, 'handleKeepAlive']);
     $this->puller->filter(function (Event $event) {
         return $event->hasPrefix("/request");
     })->subscribeCallback([$this, 'handleRequest']);
 }
示例#2
0
 public function handle()
 {
     printf("Will bind on %s\n", $this->ip);
     $this->router->bind($this->ip);
     $this->router->filter(function (Event $event) {
         return $event->is("/request/foo");
     })->map(function (Event $event) {
         printf("[%s]Received /foo with id %s, send response in 3 seconds\n", date('H:i:s'), $event->getData('id'));
         return $event;
     })->delay(3000, $this->scheduler)->subscribeCallback([$this, 'handleFoo']);
     $this->router->filter(function (Event $event) {
         return $event->is("/request/bar");
     })->map(function (Event $event) {
         printf("[%s]Received /bar with id %s, send response in 7 seconds\n", date('H:i:s'), $event->getData('id'));
         return $event;
     })->delay(7000, $this->scheduler)->subscribeCallback([$this, 'handleBar']);
 }