/
WebSocketPeer.hx
115 lines (90 loc) · 4.67 KB
/
WebSocketPeer.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Automatically generated Godot externs: DO NOT EDIT
// MIT licensed, see LICENSE.md
package godot;
import cs.system.*;
/**
This class represents a specific WebSocket connection, allowing you to do lower level operations with it.
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.
**/
@:libType
@:csNative
@:native("Godot.WebSocketPeer")
@:autoBuild(godot.Godot.buildUserClass())
extern class WebSocketPeer extends godot.PacketPeer {
@:native("new")
public function new():Void;
/**
Gets the current selected write mode. See `godot.WebSocketPeer_WriteMode`.
**/
@:native("GetWriteMode")
public function getWriteMode():godot.WebSocketPeer_WriteMode;
/**
Sets the socket to use the given `godot.WebSocketPeer_WriteMode`.
**/
@:native("SetWriteMode")
public function setWriteMode(mode:godot.WebSocketPeer_WriteMode):Void;
/**
Returns `true` if this peer is currently connected.
**/
@:native("IsConnectedToHost")
public function isConnectedToHost():Bool;
/**
Returns `true` if the last received packet was sent as a text payload. See `godot.WebSocketPeer_WriteMode`.
**/
@:native("WasStringPacket")
public function wasStringPacket():Bool;
#if doc_gen
/**
Closes this WebSocket connection. `code` is the status code for the closure (see RFC 6455 section 7.4 for a list of valid status codes). `reason` is the human readable reason for closing the connection (can be any UTF-8 string that's smaller than 123 bytes).
Note: To achieve a clean close, you will need to keep polling until either `WebSocketClient.connection_closed` or `WebSocketServer.client_disconnected` is received.
Note: The HTML5 export might not support all status codes. Please refer to browser-specific documentation for more details.
**/
@:native("Close")
public function close(?code:Int, ?reason:std.String):Void;
#else
/**
Closes this WebSocket connection. `code` is the status code for the closure (see RFC 6455 section 7.4 for a list of valid status codes). `reason` is the human readable reason for closing the connection (can be any UTF-8 string that's smaller than 123 bytes).
Note: To achieve a clean close, you will need to keep polling until either `WebSocketClient.connection_closed` or `WebSocketServer.client_disconnected` is received.
Note: The HTML5 export might not support all status codes. Please refer to browser-specific documentation for more details.
**/
@:native("Close")
public overload function close():Void;
/**
Closes this WebSocket connection. `code` is the status code for the closure (see RFC 6455 section 7.4 for a list of valid status codes). `reason` is the human readable reason for closing the connection (can be any UTF-8 string that's smaller than 123 bytes).
Note: To achieve a clean close, you will need to keep polling until either `WebSocketClient.connection_closed` or `WebSocketServer.client_disconnected` is received.
Note: The HTML5 export might not support all status codes. Please refer to browser-specific documentation for more details.
**/
@:native("Close")
public overload function close(code:Int):Void;
/**
Closes this WebSocket connection. `code` is the status code for the closure (see RFC 6455 section 7.4 for a list of valid status codes). `reason` is the human readable reason for closing the connection (can be any UTF-8 string that's smaller than 123 bytes).
Note: To achieve a clean close, you will need to keep polling until either `WebSocketClient.connection_closed` or `WebSocketServer.client_disconnected` is received.
Note: The HTML5 export might not support all status codes. Please refer to browser-specific documentation for more details.
**/
@:native("Close")
public overload function close(code:Int, reason:std.String):Void;
#end
/**
Returns the IP address of the connected peer.
Note: Not available in the HTML5 export.
**/
@:native("GetConnectedHost")
public function getConnectedHost():std.String;
/**
Returns the remote port of the connected peer.
Note: Not available in the HTML5 export.
**/
@:native("GetConnectedPort")
public function getConnectedPort():cs.types.UInt16;
/**
Disable Nagle's algorithm on the underling TCP socket (default). See `godot.StreamPeerTCP.setNoDelay` for more information.
Note: Not available in the HTML5 export.
**/
@:native("SetNoDelay")
public function setNoDelay(enabled:Bool):Void;
/**
Returns the current amount of data in the outbound websocket buffer. Note: HTML5 exports use WebSocket.bufferedAmount, while other platforms use an internal buffer.
**/
@:native("GetCurrentOutboundBufferedAmount")
public function getCurrentOutboundBufferedAmount():Int;
}