StreamPeerTLS

继承: StreamPeer < RefCounted < Object

A stream peer that handles TLS connections.

描述

A stream peer that handles TLS connections. This object can be used to connect to a TLS server or accept a single TLS client connection.

Note: When exporting to Android, make sure to enable the INTERNET permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.

方法

Erroraccept_stream ( stream: StreamPeer, server_options: TLSOptions )
Errorconnect_to_stream ( stream: StreamPeer, common_name: String, client_options: TLSOptions = null )
voiddisconnect_from_stream ( )
Statusget_status ( ) const1
StreamPeerget_stream ( ) const1
voidpoll ( )

枚举

enum Status:

Status STATUS_DISCONNECTED = 0

A status representing a StreamPeerTLS that is disconnected.

Status STATUS_HANDSHAKING = 1

A status representing a StreamPeerTLS during handshaking.

Status STATUS_CONNECTED = 2

A status representing a StreamPeerTLS that is connected to a host.

Status STATUS_ERROR = 3

A status representing a StreamPeerTLS in error state.

Status STATUS_ERROR_HOSTNAME_MISMATCH = 4

An error status that shows a mismatch in the TLS certificate domain presented by the host and the domain requested for validation.


方法说明

Error accept_stream ( stream: StreamPeer, server_options: TLSOptions )

Accepts a peer connection as a server using the given server_options. See TLSOptions.server.


Error connect_to_stream ( stream: StreamPeer, common_name: String, client_options: TLSOptions = null )

Connects to a peer using an underlying StreamPeer stream and verifying the remote certificate is correctly signed for the given common_name. You can pass the optional client_options parameter to customize the trusted certification authorities, or disable the common name verification. See TLSOptions.client and TLSOptions.client_unsafe.


void disconnect_from_stream ( )

Disconnects from host.


Status get_status ( ) const1

Returns the status of the connection. See Status for values.


StreamPeer get_stream ( ) const1

Returns the underlying StreamPeer connection, used in accept_stream or connect_to_stream.


void poll ( )

Poll the connection to check for incoming bytes. Call this right before StreamPeer.get_available_bytes for it to work properly.

2

本方法通常需要用户覆盖才能生效。

1

本方法无副作用,不会修改该实例的任何成员变量。

3

本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。

4

本方法用于构造某个类型。

5

调用本方法无需实例,可直接使用类名进行调用。

6

本方法描述的是使用本类型作为左操作数的有效运算符。

7

这个值是由下列位标志构成位掩码的整数。

8

无返回值。