send string data
@param $data
@param string $type
@param bool $masked
@throws \Exception
@return bool
327858
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);
    }
941217
function send($op,$data='') {
		$server=$this->server;
		$mask=WS::Finale | $op & WS::OpCode;
		$len=strlen($data);
		$buf='';
		if ($len>0xffff)
			$buf=pack('CCNN',$mask,0x7f,$len);
		else
		if ($len>0x7d)
			$buf=pack('CCn',$mask,0x7e,$len);
		else
			$buf=pack('CC',$mask,$len);
		$buf.=$data;
		if (is_bool($server->write($this->socket,$buf)))
			return FALSE;
		if (!in_array($op,[WS::Pong,WS::Close]) &&
			isset($this->events['send']) &&
			is_callable($func=$this->events['send']))
			$func($this,$op,$data);
		return $data;
	}
243541
private function send($method, $uri, $data, $type = 'json')
    {
        // Make the Request to Watson.
        $response = $this->request($method, $uri, [$type => $data]);
        // Request Failed.
        if ($response->getStatusCode() != 200) {
            // Throw Watson Bridge Exception.
            $this->failedRequest($response);
        }

        // We return response.
        return $response;
    }
1049238
public function writeString($data, $type = null)
    {
        if (!isset($type)) {
            $type = $this->_guessType($data);
        }
        return $this->_encodeValue($data, $this->_parseTypeString($type));
    }
82478
public function sendFrame($data, $type = null, $cb = null)
    {
        $this->realConn->sendFrame('a' . $this->toJson([$data]), $type, $cb);
        return true;
    }
103548
function _send_sftp_packet($type, $data)
    {
        $packet = $this->request_id !== false ?
            pack('NCNa*', strlen($data) + 5, $type, $this->request_id, $data) :
            pack('NCa*',  strlen($data) + 1, $type, $data);

        $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838
        $result = $this->_send_channel_packet(self::CHANNEL, $packet);
        $stop = strtok(microtime(), ' ') + strtok('');

        if (defined('NET_SFTP_LOGGING')) {
            $packet_type = '-> ' . $this->packet_types[$type] .
                           ' (' . round($stop - $start, 4) . 's)';
            if (NET_SFTP_LOGGING == self::LOG_REALTIME) {
                echo "<pre>\r\n" . $this->_format_log(array($data), array($packet_type)) . "\r\n</pre>\r\n";
                flush();
                ob_flush();
            } else {
                $this->packet_type_log[] = $packet_type;
                if (NET_SFTP_LOGGING == self::LOG_COMPLEX) {
                    $this->packet_log[] = $data;
                }
            }
        }

        return $result;
    }
1346852
public function sendFrame($payload, $type = Pool::TYPE_TEXT, $isMasked = true)
    {
        $payloadLength = mb_orig_strlen($payload);
        if ($payloadLength > $this->pool->maxAllowedPacket) {
            Daemon::$process->log('max-allowed-packet (' . $this->pool->config->maxallowedpacket->getHumanValue() . ') exceed, aborting connection');
            return;
        }

        $firstByte = '';
        switch ($type) {
            case Pool::TYPE_TEXT:
                $firstByte = 129;
                break;
            case Pool::TYPE_CLOSE:
                $firstByte = 136;
                break;
            case Pool::TYPE_PING:
                $firstByte = 137;
                break;
            case Pool::TYPE_PONG:
                $firstByte = 138;
                break;
        }

        $hdrPacket = chr($firstByte);

        $isMaskedInt = $isMasked ? 128 : 0;
        if ($payloadLength <= 125) {
            $hdrPacket .= chr($payloadLength + $isMaskedInt);
        } elseif ($payloadLength <= 65535) {
            $hdrPacket .= chr(126 + $isMaskedInt) . // 126 + 128
                chr($payloadLength >> 8) .
                chr($payloadLength & 0xFF);
        } else {
            $hdrPacket .= chr(127 + $isMaskedInt) . // 127 + 128
                chr($payloadLength >> 56) .
                chr($payloadLength >> 48) .
                chr($payloadLength >> 40) .
                chr($payloadLength >> 32) .
                chr($payloadLength >> 24) .
                chr($payloadLength >> 16) .
                chr($payloadLength >> 8) .
                chr($payloadLength & 0xFF);
        }
        $this->write($hdrPacket);
        if ($isMasked) {
            $this->write($mask = chr(mt_rand(0, 0xFF)) .
                chr(mt_rand(0, 0xFF)) .
                chr(mt_rand(0, 0xFF)) .
                chr(mt_rand(0, 0xFF)));
            $this->write(static::mask($mask, $payload));
        } else {
            $this->write($payload);
        }
    }
620811
public function sendFrame($data, $type = 0x00, $cb = null)
    {
        if ($this->finished) {
            return false;
        }
        $this->framesBuffer[] = $data;
        if ($cb !== null) {
            $this->onWrite->push($cb);
        }
        $this->flush();
        return true;
    }
1303782
protected function response($data,$type='',$code=200) {
        $this->sendHttpStatus($code);
        exit($this->encodeData($data,strtolower($type)));
    }
48233
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;
    }
228556
public function pack(string $type, array $data): string
    {
        $data = [
            'pipeType' => $type,
            'message'  => $data,
        ];

        return JsonHelper::encode($data, JSON_UNESCAPED_UNICODE);
    }
1362028
protected function logToFile($data, $type = '')
    {
        $this->logger->log(
            // Log as error if we get a GatewayErrorMessage
            is_subclass_of($type, GatewayErrorMessage::class) ? 'error' : 'info',
            // Log title
            sprintf('%s (%s)', $type, $this->payment->Gateway),
            // Log context (just output the data)
            Logging::prepareForLogging($data)
        );
    }
1174552
protected function send($data)
    {
        try {
            $result = $this->client->send($data);

            if ($result === false) {
                $errorCode = $this->client->errCode;

                throw new TransportException('Send data failed, cause: '.socket_strerror($errorCode).'.',
                    TransportException::CONNECTION);
            }
        }  catch (TransportException $e) {
            throw $e;
        } catch (Throwable $e) {
            if ($this->causedByConnectionProblem($e)) {
                throw new TransportException($e->getMessage(), TransportException::CONNECTION, $e);
            }

            throw new TransportException($e->getMessage(), 0, $e);
        }

        return $result;
    }
310506
public function send($content = null, $type = null) 
    {
        if (!is_null($content)) {
            $this->setContents(is_array($content) ? $content : array($content));
        }
        if (!is_null($type)) {
            $this->setContentType($type);
        }
        return parent::send();
    }
157838
public function sendTemplateMessageByType($touser, $type, $data, $url = null) {
		return isset($this->templates[$type]) && $this->sendTemplateMessage($touser, $this->templates[$type], $data, $url);
	}
392781
public function sendJson($data)
	{
		if ($data === null) {
			$this->terminate();
		}else{
			$this->sendResponse(new JsonResponse($data));
		}
	}
947948
function send(&$data)
    {
        if (
        	is_callable($this->send_callback)
			&& false === call_user_func_array($this->send_callback, array(&$data))
		) {
            // if send_callback returns false, end native send
            return;
        }

        if (!$this->server) {
            return;
        }

        if ($this->transport) {
            return call_user_func($this->transport, $this, $data);
        }

        $message = $this->encode($data);

        $headers = array(
            'User-Agent' => $this->getUserAgent(),
            'X-Sentry-Auth' => $this->getAuthHeader(),
            'Content-Type' => 'application/octet-stream'
        );

        $this->send_remote($this->server, $message, $headers);
    }