public function encode(string $data, int $type = Protocol::TYPE_TEXT, bool $masked = false)
    {
        $this->frames = [];

        $frame = $this->getFrame();
        array_push($this->frames, $frame);

        $frame->encode($data, $type, $masked);

        return $this;
    }