Sends a handshake message reply
@param string Received data (no use in this class)
@return boolean OK?
484573
public function sendHandshakeReply($extraHeaders = '')
    {
        if (!isset($this->server['HTTP_SEC_WEBSOCKET_ORIGIN'])) {
            $this->server['HTTP_SEC_WEBSOCKET_ORIGIN'] = '';
        }

        $this->write(
            "HTTP/1.1 101 Web Socket Protocol Handshake\r\n"
            . "Upgrade: WebSocket\r\n"
            . "Connection: Upgrade\r\n"
            . "Sec-WebSocket-Origin: " . $this->server['HTTP_ORIGIN'] . "\r\n"
            . "Sec-WebSocket-Location: ws://" . $this->server['HTTP_HOST'] . $this->server['REQUEST_URI'] . "\r\n"
        );
        if ($this->pool->config->expose->value) {
            $this->writeln('X-Powered-By: phpDaemon/' . Daemon::$version);
        }
        if (isset($this->server['HTTP_SEC_WEBSOCKET_PROTOCOL'])) {
            $this->writeln("Sec-WebSocket-Protocol: " . $this->server['HTTP_SEC_WEBSOCKET_PROTOCOL']);
        }
        $this->writeln($extraHeaders);
        return true;
    }
1086402
public function send(string $data, int $type = Protocol::TYPE_TEXT): bool
    {
        if (!$this->handshaked) {
            throw new HandshakeException('Connection is not handshaked');
        }

        $payload = $this->protocol->getPayload();
        if (!is_scalar($data) && !$data instanceof Payload) {
            $data = json_encode($data);
        }

        // Servers don't send masked payloads
        $payload->encode($data, $type, false);

        if (!$payload->sendToSocket($this->socket)) {
            $this->logger->warning('Could not send payload to client');
            throw new ConnectionException('Could not send data to connection: ' . $this->socket->getLastError());
        }

        return true;
    }
383539
public function sendCommand(string $service, $message, bool $reply = true)
    {
        if (false == $message instanceof Message) {
            $message = $this->context->createMessage($message);
        }
        $message->setProperty(Config::PROCESSOR, $reply ? 'service.request.processor' : 'service.command.processor');

        $queue = $this->context->createQueue($service);

        $deleteReplyQueue = false;
        $replyTo = $message->getReplyTo();

        if ($reply) {
            if (false == $replyTo) {
                $message->setReplyTo($replyTo = $this->rpcFactory->createReplyTo());
                $deleteReplyQueue = true;
            }

            if (false == $message->getCorrelationId()) {
                $message->setCorrelationId(UUID::generate());
            }
        }

        $this->context->createProducer()->send($queue, $message);

        if ($reply) {
            $promise = $this->rpcFactory->createPromise($replyTo, $message->getCorrelationId(), $this->timeout);
            $promise->setDeleteReplyQueue($deleteReplyQueue);

            return $promise;
        }

        return false;
    }
490655
public function send($msg): bool
    {
        // JSON encode message if supplied in array or object form
        if (is_array($msg) || is_object($msg)) {
            $msg = json_encode($msg);
        }

        // Ensure message is a string
        $msg = (string) $msg;

        // Check the message fits within the buffer
        if (strlen($msg) > $this->buffer) {
            throw new SocketCommunicationException('Tried to send data larger than buffer size of '.$this->buffer.' bytes. Recreate channel with a larger buffer to send this data');
        }

        // Pad the message to the buffer size
        $msg = str_pad($msg, $this->buffer, ' ');

        // Write the message to the socket
        return socket_write($this->socket, $msg, $this->buffer);
    }
672261
public function send($msg)
    {
        // Check queue and send messages
        if ($this->queue && is_resource($this->queue) && msg_stat_queue($this->queue)) {
            return msg_send($this->queue, 1, array(
                'from' => $this->isMaster() ? $this->ppid : $this->pid,
                'to'   => $this->isMaster() ? $this->pid : $this->ppid,
                'body' => $msg
            ), true, false, $error);
        }
        return false;
    }
623357
public void sendMessage(byte[] msgdata, boolean isActivity)
			throws SshException {

		synchronized (kexqueue) {

			if (currentState == PERFORMING_KEYEXCHANGE
					&& !isTransportMessage(msgdata[0])) {
				kexqueue.addElement(msgdata);
				return;
			}

			if (Log.isDebugEnabled()) {
				if (verbose) {
					Log.debug(this,
							"Sending transport protocol message");
				}
			}

			try {
				outgoingMessage.reset();

				int padding = 4;

				// Compress the payload if necersary
				if (outgoingCompression != null && isOutgoingCompressing) {
					msgdata = outgoingCompression.compress(msgdata, 0,
							msgdata.length);
				}

				// Determine the padding length
				padding += ((outgoingCipherLength - ((msgdata.length + 5 + padding) % outgoingCipherLength)) % outgoingCipherLength);

				// Write the packet length field
				outgoingMessage.writeInt(msgdata.length + 1 + padding);

				// Write the padding length
				outgoingMessage.write(padding);

				// Write the message payload
				outgoingMessage.write(msgdata, 0, msgdata.length);

				// Create some random data for the padding
				ComponentManager
						.getInstance()
						.getRND()
						.nextBytes(outgoingMessage.array(),
								outgoingMessage.size(), padding);
				outgoingMessage.move(padding);

				// Generate the MAC
				if (outgoingMac != null) {
					outgoingMac.generate(outgoingSequence,
							outgoingMessage.array(), 0, outgoingMessage.size(),
							outgoingMessage.array(), outgoingMessage.size());

				}

				// Perfrom encrpytion
				if (encryption != null) {
					encryption.transform(outgoingMessage.array(), 0,
							outgoingMessage.array(), 0, outgoingMessage.size());
				}

				outgoingMessage.move(outgoingMacLength);
				outgoingBytes += outgoingMessage.size();

				// Send!
				transportOut.write(outgoingMessage.array(), 0,
						outgoingMessage.size());
				transportOut.flush();

				if (isActivity)
					lastActivity = System.currentTimeMillis();

				if (Log.isDebugEnabled()) {
					if (verbose) {
						Log.debug(
								this,
								"Sent "
										+ outgoingMessage.size()
										+ " bytes of transport data outgoingSequence="
										+ outgoingSequence
										+ " totalBytesSinceKEX="
										+ numOutgoingBytesSinceKEX);
					}
				}

				outgoingSequence++;
				numOutgoingBytesSinceKEX += msgdata.length;
				numOutgoingPacketsSinceKEX++;

				if (outgoingSequence >= 4294967296L) {
					outgoingSequence = 0;
				}

				if (!transportContext.isKeyReExchangeDisabled()) {
					if (numOutgoingBytesSinceKEX >= MAX_NUM_BYTES_BEFORE_REKEY
							|| numOutgoingPacketsSinceKEX >= MAX_NUM_PACKETS_BEFORE_REKEY) {

						if (Log.isDebugEnabled()) {
							Log.debug(this,
									"Requesting key re-exchange");
						}
						sendKeyExchangeInit(false);
					}
				}
			} catch (IOException ex) {
				internalDisconnect();
				throw new SshException("Unexpected termination: "
						+ ex.getMessage(), SshException.UNEXPECTED_TERMINATION);
			}
		}

	}
718837
public function send(
        array $data,
        MembershipInterface $sender,
        MembershipInterface $receiver,
        MessageParticipantModelInterface $replyTo = null // TODO: Check if this should be Message instead
    ): PodiumResponse
    {
        $sending = $this->getMessenger();

        $sending->setSender($sender);
        $sending->setReceiver($receiver);
        $sending->setReplyTo($replyTo);

        if (!$sending->loadData($data)) {
            return PodiumResponse::error();
        }

        return $sending->send();
    }
240993
public function send($msg)
    {
        if (!$this->url) {
            return false;
        }
        $data = ["msgtype" => "text", "text" => ["content" => $msg], "at" => ["isAtAll" => true]];
        $curl = new LCurl(LCurl::POST_JSON, 3);
        $result = $curl->post(
            $this->url,
            $data
        );
        if (!$result || (int)Arrays::get($result, 'errcode') != 0) {
            return false;
        }
        return true;
    }
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);
    }
413033
public function send()
    {
        if (!static::isSent()) {
            static::call('send', $this);
            foreach ($this->headers as $header => $value) {
                $this->setHttpHeader($header, $value);
            }
            http_response_code($this->status);
            echo $this->body;
            static::$sent = true;
            return true;
        }
        return false;
    }
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;
	}
285391
public function sendHandshakeReply($extraHeaders = '')
    {
        if (!isset($this->server['HTTP_SEC_WEBSOCKET_KEY']) || !isset($this->server['HTTP_SEC_WEBSOCKET_VERSION'])) {
            return false;
        }
        if ($this->server['HTTP_SEC_WEBSOCKET_VERSION'] !== '13' && $this->server['HTTP_SEC_WEBSOCKET_VERSION'] !== '8') {
            return false;
        }

        if (isset($this->server['HTTP_ORIGIN'])) {
            $this->server['HTTP_SEC_WEBSOCKET_ORIGIN'] = $this->server['HTTP_ORIGIN'];
        }
        if (!isset($this->server['HTTP_SEC_WEBSOCKET_ORIGIN'])) {
            $this->server['HTTP_SEC_WEBSOCKET_ORIGIN'] = '';
        }
        $this->write(
            "HTTP/1.1 101 Switching Protocols\r\n"
            . "Upgrade: WebSocket\r\n"
            . "Connection: Upgrade\r\n"
            . "Date: " . date('r') . "\r\n"
            . "Sec-WebSocket-Origin: " . $this->server['HTTP_SEC_WEBSOCKET_ORIGIN'] . "\r\n"
            . "Sec-WebSocket-Location: ws://" . $this->server['HTTP_HOST'] . $this->server['REQUEST_URI'] . "\r\n"
            . "Sec-WebSocket-Accept: "
            . base64_encode(
                sha1(
                    trim(
                        $this->server['HTTP_SEC_WEBSOCKET_KEY']
                    )
                    . "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
                    true
                )
            ) . "\r\n"
        );
        if (isset($this->server['HTTP_SEC_WEBSOCKET_PROTOCOL'])) {
            $this->writeln("Sec-WebSocket-Protocol: " . $this->server['HTTP_SEC_WEBSOCKET_PROTOCOL']);
        }

        if ($this->pool->config->expose->value) {
            $this->writeln('X-Powered-By: phpDaemon/' . Daemon::$version);
        }

        $this->writeln($extraHeaders);

        return true;
    }
760570
function _send($data)
    {
        switch ($this->mode) {
            case self::MODE_SSH2:
                $this->ssh->_send_channel_packet(SSH2::CHANNEL_EXEC, $data);
                break;
            case self::MODE_SSH1:
                $data = pack('CNa*', NET_SSH1_CMSG_STDIN_DATA, strlen($data), $data);
                $this->ssh->_send_binary_packet($data);
        }
    }
1094213
public static function sendHandshake($connection)
    {
        if (!empty($connection->handshakeStep)) {
            return;
        }
        // Get Host.
        $port = $connection->getRemotePort();
        $host = $port === 80 ? $connection->getRemoteHost() : $connection->getRemoteHost() . ':' . $port;
        // Handshake header.
        $header = 'GET ' . $connection->getRemoteURI() . " HTTP/1.1\r\n".
        "Host: $host\r\n".
        "Connection: Upgrade\r\n".
        "Upgrade: websocket\r\n".
        "Origin: ". (isset($connection->websocketOrigin) ? $connection->websocketOrigin : '*') ."\r\n".
        "Sec-WebSocket-Version: 13\r\n".
        "Sec-WebSocket-Key: ".base64_encode(sha1(uniqid(mt_rand(), true), true))."\r\n\r\n";
        $connection->send($header, true);
        $connection->handshakeStep               = 1;
        $connection->websocketCurrentFrameLength = 0;
        $connection->websocketDataBuffer         = '';
        $connection->tmpWebsocketData            = '';
    }
936283
public function sendAndReceive(Message $message): Response
    {
        /* @var AndroidMessage $message */
        $data = $message->getMessage();
        if ($this->dryRun) {
            $data['dry_run'] = true;
        }
        $response = new ConnectionResponseImpl();
        try {
            $requestData = json_encode($data);
            $request = new Request('POST', '', [], $requestData);
            $clientResponse = $this->client->send($request);
            $data = json_decode($clientResponse->getBody()->getContents(), true);

            $response->setResponse($data);
            $response->setSuccess($data['success'] > 0);
        } catch (RequestException $e) {
            $response->setErrorResponse($e);
        }

        return $response;
    }
1033974
public void sendHandshakeResponse(HandshakeResponse wsResponse) {
        log.debug("Writing handshake on session: {}", session.getId());
        // create write future
        handshakeWriteFuture = session.write(wsResponse);
        handshakeWriteFuture.addListener(new IoFutureListener<WriteFuture>() {

            @Override
            public void operationComplete(WriteFuture future) {
                IoSession sess = future.getSession();
                if (future.isWritten()) {
                    // handshake is finished
                    log.debug("Handshake write success! {}", sess.getId());
                    // set completed flag
                    sess.setAttribute(Constants.HANDSHAKE_COMPLETE);
                    // set connected state on ws connection
                    if (connected.compareAndSet(false, true)) {
                        try {
                            // send queued packets
                            queue.forEach(entry -> {
                                sess.write(entry);
                                queue.remove(entry);
                            });
                        } catch (Exception e) {
                            log.warn("Exception draining queued packets on session: {}", sess.getId(), e);
                        }
                    }
                } else {
                    log.warn("Handshake write failed from: {} to: {}", sess.getLocalAddress(), sess.getRemoteAddress());
                }
            }

        });
    }
554918
public function sendData($data)
    {
        $data['verify_success'] = $this->isSignMatch();
        $data['is_paid']        = $data['verify_success'] && ($this->getRequestParam('respCode') == '00');

        return $this->response = new LegacyCompletePurchaseResponse($this, $data);
    }