onReceive() public method

Read a frame.
public onReceive ( $server, $fd, $from_id, $data )
Ejemplo n.º 1
0
 public function onReceive($server, $fd, $from_id, $data)
 {
     $conn = $server->connection_info($fd, $from_id);
     if ($conn['from_port'] == 9906) {
         if (!empty($this->connections)) {
             foreach ($this->connections as $conn_fd => $v) {
                 $tmp = json_decode($data, true);
                 if ($tmp['module_id'] == $v['module_id'] and $tmp['interface_id'] == $v['interface_id']) {
                     $tmp['time'] = date("Y-m-d H:i:s", $tmp['time']);
                     $this->send($conn_fd, json_encode($tmp));
                 }
             }
         }
     } else {
         parent::onReceive($server, $fd, $from_id, $data);
     }
 }
Ejemplo n.º 2
0
 /**
  * 接收到数据时回调此函数,发生在worker进程中
  * @param $server swoole_server对象
  * @param $fd TCP客户端连接的文件描述符
  * @param $from_id TCP连接所在的Reactor线程ID
  * @param $data 收到的数据内容,可能是文本或者二进制内容
  */
 function onReceive($server, $fd, $from_id, $data)
 {
     return parent::onReceive($server, $fd, $from_id, $data);
 }