public function onReceive($server, $fd, $from_id, $data)
    {
        //$this->log("Connection[{$fd}] received ".strlen($data)." bytes.");
        //未连接
        if (!isset($this->connections[$fd]))
        {
            return parent::onReceive($server, $fd, $from_id, $data);
        }

        while (strlen($data) > 0 and isset($this->connections[$fd]))
        {
            //新的请求
            if (!isset($this->frame_list[$fd]))
            {
                $frame = $this->parseFrame($data);
                if ($frame === false)
                {
                    $this->log("Error Frame");
                    $this->close($fd);
                    break;
                }
                //数据完整
                if ($frame['finish'])
                {
                    $this->log("NewFrame finish. Opcode=".$frame['opcode']."|Length={$frame['length']}");
                    $this->opcodeSwitch($fd, $frame);
                }
                //数据不完整加入到缓存中
                else
                {
                    $this->frame_list[$fd] = $frame;
                }
            }
            else
            {
                $frame = &$this->frame_list[$fd];
                $frame['data'] .= $data;

                //$this->log("wait length = ".$ws['length'].'. data_length='.strlen($ws['data']));

                //数据已完整，进行处理
                if (strlen($frame['data']) >= $frame['length'])
                {
                    $frame['fin'] = 1;
                    $frame['finish'] = true;
                    $frame['data'] = substr($frame['data'], 0, $frame['length']);
                    $frame['message'] = $this->parseMessage($frame);
                    $this->opcodeSwitch($fd, $frame);
                    $data = substr($frame['data'], $frame['length']);
                }
                //数据不足，跳出循环，继续等待数据
                else
                {
                    break;
                }
            }
        }
        return true;
    }