public function send($data, $type = 'text', $masked = true)
    {
        if (empty($data))
        {
            throw new \Exception("data is empty");
        }
        if (!$this->handshake)
        {
            trigger_error("not complete handshake.");
            return false;
        }
        if ($this->haveSwooleEncoder)
        {
            switch($type)
            {
                case 'text':
                    $_type = WEBSOCKET_OPCODE_TEXT;
                    break;
                case 'binary':
                case 'bin':
                    $_type = WEBSOCKET_OPCODE_BINARY;
                    break;
                default:
                    return false;
            }
            $_send = \swoole_websocket_server::pack($data, $_type);
        }
        else
        {
            $_send =  $this->hybi10Encode($data, $type, $masked);
        }
        return $this->socket->send($_send);
    }
public function send($data, $type = 'text', $masked = true)
    {
        if (empty($data))
        {
            throw new \Exception("data is empty");
        }
        if (!$this->handshake)
        {
            trigger_error("not complete handshake.");
            return false;
        }
        if ($this->haveSwooleEncoder)
        {
            switch($type)
            {
                case 'text':
                    $_type = WEBSOCKET_OPCODE_TEXT;
                    break;
                case 'binary':
                case 'bin':
                    $_type = WEBSOCKET_OPCODE_BINARY;
                    break;
                default:
                    return false;
            }
            $_send = \swoole_websocket_server::pack($data, $_type);
        }
        else
        {
            $_send =  $this->hybi10Encode($data, $type, $masked);
        }
        return $this->socket->send($_send);
    }
public function send ( $ data , $ type = 'text' , $ masked = true ) { if ( empty ( $ data ) ) { throw new \ Exception ( "data is empty" ) ; } if ( ! $ this -> handshake ) { trigger_error ( "not complete handshake." ) ; return false ; } if ( $ this -> haveSwooleEncoder ) { switch ( $ type ) { case 'text' : $ _type = WEBSOCKET_OPCODE_TEXT ; break ; case 'binary' : case 'bin' : $ _type = WEBSOCKET_OPCODE_BINARY ; break ; default : return false ; } $ _send = \ swoole_websocket_server :: pack ( $ data , $ _type ) ; } else { $ _send = $ this -> hybi10Encode ( $ data , $ type , $ masked ) ; } return $ this -> socket -> send ( $ _send ) ; }
send string data
@param $data
@param string $type
@param bool $masked
@throws \Exception
@return bool
send string data