2018-05-08 14:40:08 +02:00
<?xml version="1.0" encoding="UTF-8" ?>
2021-04-26 13:14:51 +02:00
<class name= "WebSocketPeer" inherits= "PacketPeer" version= "3.4" >
2018-05-08 14:40:08 +02:00
<brief_description >
A class representing a specific WebSocket connection.
</brief_description>
<description >
2021-10-06 15:12:05 +02:00
This class represents a specific WebSocket connection, allowing you to do lower level operations with it.
2018-05-08 14:40:08 +02:00
You can choose to write to the socket in binary or text mode, and you can recognize the mode used for writing by the other peer.
</description>
<tutorials >
</tutorials>
<methods >
<method name= "close" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
<argument index= "0" name= "code" type= "int" default= "1000" />
<argument index= "1" name= "reason" type= "String" default= """" />
2018-05-08 14:40:08 +02:00
<description >
2019-06-22 01:04:47 +02:00
Closes this WebSocket connection. [code]code[/code] is the status code for the closure (see RFC 6455 section 7.4 for a list of valid status codes). [code]reason[/code] is the human readable reason for closing the connection (can be any UTF-8 string that's smaller than 123 bytes).
[b]Note:[/b] To achieve a clean close, you will need to keep polling until either [signal WebSocketClient.connection_closed] or [signal WebSocketServer.client_disconnected] is received.
[b]Note:[/b] The HTML5 export might not support all status codes. Please refer to browser-specific documentation for more details.
2018-05-08 14:40:08 +02:00
</description>
</method>
<method name= "get_connected_host" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "String" />
2018-05-08 14:40:08 +02:00
<description >
2019-06-22 01:04:47 +02:00
Returns the IP address of the connected peer.
[b]Note:[/b] Not available in the HTML5 export.
2018-05-08 14:40:08 +02:00
</description>
</method>
<method name= "get_connected_port" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "int" />
2018-05-08 14:40:08 +02:00
<description >
2019-06-22 01:04:47 +02:00
Returns the remote port of the connected peer.
[b]Note:[/b] Not available in the HTML5 export.
2018-05-08 14:40:08 +02:00
</description>
</method>
2021-07-29 22:11:27 +02:00
<method name= "get_current_outbound_buffered_amount" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "int" />
2021-07-29 22:11:27 +02:00
<description >
Returns the current amount of data in the outbound websocket buffer. [b]Note:[/b] HTML5 exports use WebSocket.bufferedAmount, while other platforms use an internal buffer.
</description>
</method>
2018-05-08 14:40:08 +02:00
<method name= "get_write_mode" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "int" enum= "WebSocketPeer.WriteMode" />
2018-05-08 14:40:08 +02:00
<description >
2019-06-22 01:04:47 +02:00
Gets the current selected write mode. See [enum WriteMode].
2018-05-08 14:40:08 +02:00
</description>
</method>
<method name= "is_connected_to_host" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "bool" />
2018-05-08 14:40:08 +02:00
<description >
Returns [code]true[/code] if this peer is currently connected.
</description>
</method>
2020-01-28 14:06:28 +01:00
<method name= "set_no_delay" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
<argument index= "0" name= "enabled" type= "bool" />
2020-01-28 14:06:28 +01:00
<description >
Disable Nagle's algorithm on the underling TCP socket (default). See [method StreamPeerTCP.set_no_delay] for more information.
[b]Note:[/b] Not available in the HTML5 export.
</description>
</method>
2018-05-08 14:40:08 +02:00
<method name= "set_write_mode" >
2021-07-30 15:28:05 +02:00
<return type= "void" />
<argument index= "0" name= "mode" type= "int" enum= "WebSocketPeer.WriteMode" />
2018-05-08 14:40:08 +02:00
<description >
Sets the socket to use the given [enum WriteMode].
</description>
</method>
<method name= "was_string_packet" qualifiers= "const" >
2021-07-30 15:28:05 +02:00
<return type= "bool" />
2018-05-08 14:40:08 +02:00
<description >
2020-01-23 11:14:14 +01:00
Returns [code]true[/code] if the last received packet was sent as a text payload. See [enum WriteMode].
2018-05-08 14:40:08 +02:00
</description>
</method>
</methods>
<constants >
<constant name= "WRITE_MODE_TEXT" value= "0" enum= "WriteMode" >
2019-06-22 01:04:47 +02:00
Specifies that WebSockets messages should be transferred as text payload (only valid UTF-8 is allowed).
2018-05-08 14:40:08 +02:00
</constant>
<constant name= "WRITE_MODE_BINARY" value= "1" enum= "WriteMode" >
2019-06-22 01:04:47 +02:00
Specifies that WebSockets messages should be transferred as binary payload (any byte combination is allowed).
2018-05-08 14:40:08 +02:00
</constant>
</constants>
</class>