Send node to the WhatsApp server.

@param ProtocolNode $node
@param bool         $encrypt
166309
public function sendNode($node, $encrypt = true)
    {
        $this->timeout = time();
        $this->debugPrint($node->nodeString('tx  ')."\n");
        $this->sendData($this->writer->write($node, $encrypt));
    }
210387
public function enterNode(Node $node)
    {
        parent::enterNode($node);

        if (self::isConditional($node)) {
            $this->conditionalScopes++;
        } elseif ($node instanceof Function_) {
            $name = $this->getFullyQualifiedName($node->name);

            // @todo add an "else" here which adds a runtime check for instances where we can't tell
            // whether a function is being redefined by static analysis alone.
            if ($this->conditionalScopes === 0) {
                if (\function_exists($name) ||
                    isset($this->currentScope[\strtolower($name)])) {
                    $msg = \sprintf('Cannot redeclare %s()', $name);
                    throw new FatalErrorException($msg, 0, E_ERROR, null, $node->getLine());
                }
            }

            $this->currentScope[\strtolower($name)] = 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);
        }
    }
547220
public function enterNode(Node $node)
    {
        if ($this->atLeastPhp55) {
            return;
        }

        if (!$node instanceof Empty_) {
            return;
        }

        if (!$node->expr instanceof Variable) {
            $msg = \sprintf('syntax error, unexpected %s', $this->getUnexpectedThing($node->expr));

            throw new ParseErrorException($msg, $node->expr->getLine());
        }
    }
1317447
public function encrypt(bool $encrypt)
    {
        \stream_set_blocking($this->socket, true);
        $result = \stream_socket_enable_crypto($this->socket, $encrypt, $this->options['ssl_crypto_type']);
        \stream_set_blocking($this->socket, false);

        if ($result === false) {
            throw new ConnectionException(sprintf(
                'Unable to %s encryption on TCP connection. %s',
                $encrypt ? 'enable' : 'disable',
                $this->errorMessage
            ));
        }
        $this->isEncrypted = $encrypt;

        return $this;
    }
706021
public function encrypt($encrypt, $key)
    {
        $inputParams = [
            'encrypt' => $encrypt,
            'key'     => $key,
        ];
        $this->debug->info(__FUNCTION__, 'Input Params: ' . json_encode($inputParams));
        $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), MCRYPT_RAND);
        $this->debug->debug(__FUNCTION__, 'IV Key: ' . json_encode($iv));
        $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, pack("H*", $key), $encrypt, MCRYPT_MODE_ECB, $iv));
        $this->debug->info(__FUNCTION__, 'encrypt Result: ' . json_encode($encrypted));

        return $encrypted;
    }
508976
public function enterNode(Node $node): void
    {
        $name = null;

        if ($node instanceof Name) {
            $name = $node->toString();
        }

        if ($name === null
            || (array_key_exists($name, $this->symbols)
                && $this->symbols[$name] === false
            )
        ) {
            return;
        }

        if (!$this->filter->__invoke($name)) {
            $this->symbols[$name] = false;
            return;
        }

        if (!array_key_exists($name, $this->symbols)) {
            $this->symbols[$name] = [];
        }

        $this->symbols[$name][] = $node;
    }
708490
function Node(config) {
    RED.nodes.createNode(this,config);
    var node = this,
      message = '';

    this.on('input', function (msg) {
      node.status({});

      payloadCheck(msg)
      .then(function(){
        return wordcountCheck(msg, config);
      })
      .then(function(){
        return credentialsCheck(node);
      })
      .then(function(){
        return setEndPoint(config);
      })
      .then(function(){
        return prepareParams(msg, config);
      })
      .then(function(params){

        node.status({fill:'blue', shape:'dot', text:'requesting'});
        return executeService(msg, params);
      })
      .then(function(){
        node.status({});
        node.send(msg);
      })
      .catch(function(err){
        payloadutils.reportError(node, msg, err);
        node.send(msg);
      });
    });
  }
901978
protected function readPayload($encrypt)
	{
		if (!$encrypt && isset($_GET['jfpayload'])) {
			ob_start();
			$payload = json_decode(trim(base64_decode($_GET['jfpayload'])));
			ob_end_clean();
		} else if ($encrypt && isset($_POST['jfpayload'])) {
			$payload = Api::decrypt($this->key , $_POST['jfpayload']);
		}
		if (isset($payload) && is_array($payload)) {
			$this->payload = $payload;
			return true;
		}
		return false;
	}
1055770
public function send( $headers = false ) 
	{
		if ( $headers && headers_sent() && !CLI ) 
		{
			throw new CCException( "CCResponse::send - cannot send header, header has already been send." );
		}

		if ( $headers ) 
		{
			// status header
			header( CCIn::server( 'SERVER_PROTOCOL' ).' '.$this->_status.' '.CCResponse::$messages[$this->_status] );

			// check if content type is already set
			if ( !isset( $this->_header['Content-Type'] ) ) 
			{
				$this->header( 'Content-Type', 'text/html; charset='.ClanCats::$config->get( 'charset', 'utf-8' ) );
			}

			$this->header( 'X-Powered-By', 'ClanCatsFramework version: '.ClanCats::VERSION );

			// set headers
			foreach( $this->_header as $key => $content ) 
			{
				header( $key.': '.$content );
			}
		}

		// profiler
		CCProfiler::check( 'CCResponse - sending response' );

		// print the body
		echo CCEvent::pass( 'response.output', $this->body() );
	}
1298389
public void send(String nodeID, byte[] packet) {
		if (nodeID == null) {
			logger.warn("Unable to send (missing nodeID)!");
			return;
		}
		if (packet == null || packet.length < 6) {
			logger.warn("Cannot send empty packet to node " + nodeID + "!");
			return;
		}
		SendBuffer buffer = null;
		try {

			// Get or create buffer
			boolean newBuffer = false;
			synchronized (buffers) {
				buffer = buffers.get(nodeID);
				if (buffer == null) {

					// Create new connection
					RemoteAddress address = transporter.getAddress(nodeID);
					if (address == null) {
						logger.warn("Unknown node ID (" + nodeID + ")!");
						return;
					}
					buffer = new SendBuffer(nodeID, address.host, address.port, debug);
					append(nodeID, buffer, packet);
					buffers.put(nodeID, buffer);
					newBuffer = true;
				} else {

					// Try to append to buffer
					if (!buffer.append(packet)) {

						// Buffer is closed
						RemoteAddress address = transporter.getAddress(nodeID);
						buffer = new SendBuffer(nodeID, address.host, address.port, debug);
						append(nodeID, buffer, packet);
						buffers.put(nodeID, buffer);
						newBuffer = true;
					}
				}
			}
			if (newBuffer) {

				// Close older connections
				if (maxConnections > 0) {
					cleanup();
				}

				// Add to opened buffers
				opened.add(buffer);

			} else if (buffer.key != null) {

				// Mark as writable
				buffer.key.interestOps(SelectionKey.OP_WRITE);
			}

			// Wake up selector
			if (selector != null) {
				selector.wakeup();
			}

		} catch (Throwable cause) {
			synchronized (buffers) {
				buffers.remove(nodeID);
			}
			LinkedList<byte[]> packets;
			if (buffer != null) {
				packets = buffer.getUnsentPackets();
			} else {
				packets = new LinkedList<>();
			}
			if (packets.isEmpty() && packet != null) {
				packets.addLast(packet);
			}
			transporter.unableToSend(nodeID, packets, cause);
		}
	}
703329
function configure(newSubtle, newWebCrypto, newNodeCrypto) {
    subtle = newSubtle;
    webCrypto = newWebCrypto;
    nodeCrypto = newNodeCrypto;
}
1357614
function SayNode(config) {
		RED.nodes.createNode(this, config);
		var node = this;
		this.on('input', function (msg) {
			say.speak(
				this.name || msg.payload,
				this.voice,
				1,
				function(err) {
					if (err) {
				    return node.error(err);
				  }
				node.send(msg);
			});
		});
	}
374861
final protected function _post($node, array $data, $jsonEncode = true)
    {
        if (!is_array($data)) {
            $this->setError('参数必须为一个数组');

            return false;
        }

        $module  = $this->module;
        $apitype = $this->apitype;

        if ($this->module != $this->className) {
            $this->module = $this->className;
        }

        return Api::_post($module, $node, $data, $jsonEncode, $apitype);
    }
167236
public function setIsEncrypt($isEncrypt)
    {
        if (is_bool($isEncrypt)) {
            $this->_isEncrypt = $isEncrypt;
        } else {
            $this->_isEncrypt = "true" === $isEncrypt;
        }
    }
65042
public function send($protocol = null)
    {
        // Clean up any open buffers
        if (ob_get_length() > 0) {
            ob_end_clean();
        }

        // Send the status code and headers
        if (!headers_sent())
            $this->sendStatus($protocol)->sendHeaders();

        // Send the body
        echo $this->_body;

        // Kill the script
        exit;

    }
1274559
public function decrypt($encrypted)
    {
        if (!$encrypted || !is_string($encrypted)) {
            throw new CryptoException(sprintf(self::ERR_CANNOT_DECRYPT, gettype($encrypted)));
        }

        // Sanity check size of payload is larger than MAC + NONCE
        if (ByteString::strlen($encrypted) < self::NONCE_SIZE_BYTES + $this->sodiumCryptoBytes()) {
            throw new CryptoException(self::ERR_SIZE);
        }

        // Split into nonce, mac, and encrypted payload
        $nonce = ByteString::substr($encrypted, 0, self::NONCE_SIZE_BYTES);
        $mac = ByteString::substr($encrypted, self::NONCE_SIZE_BYTES, $this->sodiumCryptoBytes());
        $encrypted = ByteString::substr($encrypted, self::NONCE_SIZE_BYTES + $this->sodiumCryptoBytes());

        // Verify MAC
        try {
            $isVerified = $this->sodiumCryptoAuthVerify($mac, $nonce . $encrypted, $this->authSecret->getValue());
        } catch (Exception $ex) {
            throw new CryptoException(sprintf(self::ERR_DECODE_UNEXPECTED, $ex->getMessage()), $ex->getCode(), $ex);
        }

        if (!$isVerified) {
            throw new CryptoException(self::ERR_DECODE);
        }

        // Decrypt authenticated payload
        try {
            $unencrypted = $this->sodiumSecretBoxOpen($encrypted, $nonce, $this->cryptoSecret->getValue());
        } catch (Exception $ex) {
            throw new CryptoException(sprintf(self::ERR_DECRYPT, $ex->getMessage()), $ex->getCode(), $ex);
        }

        return $unencrypted;
    }