Debian Codegraph @

doc/classes/StreamPeer.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="StreamPeer" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 Abstract base class for interacting with streams.
5 </brief_description>
6 <description>
7 StreamPeer is an abstract base class mostly used for stream-based protocols (such as TCP). It provides an API for sending and receiving data through streams as raw data or strings.
8 [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] 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.
9 </description>
10 <tutorials>
11 </tutorials>
12 <methods>
13 <method name="get_8">
14 <return type="int" />
15 <description>
16 Gets a signed byte from the stream.
17 </description>
18 </method>
19 <method name="get_16">
20 <return type="int" />
21 <description>
22 Gets a signed 16-bit value from the stream.
23 </description>
24 </method>
25 <method name="get_32">
26 <return type="int" />
27 <description>
28 Gets a signed 32-bit value from the stream.
29 </description>
30 </method>
31 <method name="get_64">
32 <return type="int" />
33 <description>
34 Gets a signed 64-bit value from the stream.
35 </description>
36 </method>
37 <method name="get_available_bytes" qualifiers="const">
38 <return type="int" />
39 <description>
40 Returns the number of bytes this [StreamPeer] has available.
41 </description>
42 </method>
43 <method name="get_data">
44 <return type="Array" />
45 <param index="0" name="bytes" type="int" />
46 <description>
47 Returns a chunk data with the received bytes, as an [Array] containing two elements: an [enum Error] constant and a [PackedByteArray]. [param bytes] is the number of bytes to be received. If not enough bytes are available, the function will block until the desired amount is received.
48 </description>
49 </method>
50 <method name="get_double">
51 <return type="float" />
52 <description>
53 Gets a double-precision float from the stream.
54 </description>
55 </method>
56 <method name="get_float">
57 <return type="float" />
58 <description>
59 Gets a single-precision float from the stream.
60 </description>
61 </method>
62 <method name="get_half">
63 <return type="float" />
64 <description>
65 Gets a half-precision float from the stream.
66 </description>
67 </method>
68 <method name="get_partial_data">
69 <return type="Array" />
70 <param index="0" name="bytes" type="int" />
71 <description>
72 Returns a chunk data with the received bytes, as an [Array] containing two elements: an [enum Error] constant and a [PackedByteArray]. [param bytes] is the number of bytes to be received. If not enough bytes are available, the function will return how many were actually received.
73 </description>
74 </method>
75 <method name="get_string">
76 <return type="String" />
77 <param index="0" name="bytes" type="int" default="-1" />
78 <description>
79 Gets an ASCII string with byte-length [param bytes] from the stream. If [param bytes] is negative (default) the length will be read from the stream using the reverse process of [method put_string].
80 </description>
81 </method>
82 <method name="get_u8">
83 <return type="int" />
84 <description>
85 Gets an unsigned byte from the stream.
86 </description>
87 </method>
88 <method name="get_u16">
89 <return type="int" />
90 <description>
91 Gets an unsigned 16-bit value from the stream.
92 </description>
93 </method>
94 <method name="get_u32">
95 <return type="int" />
96 <description>
97 Gets an unsigned 32-bit value from the stream.
98 </description>
99 </method>
100 <method name="get_u64">
101 <return type="int" />
102 <description>
103 Gets an unsigned 64-bit value from the stream.
104 </description>
105 </method>
106 <method name="get_utf8_string">
107 <return type="String" />
108 <param index="0" name="bytes" type="int" default="-1" />
109 <description>
110 Gets a UTF-8 string with byte-length [param bytes] from the stream (this decodes the string sent as UTF-8). If [param bytes] is negative (default) the length will be read from the stream using the reverse process of [method put_utf8_string].
111 </description>
112 </method>
113 <method name="get_var">
114 <return type="Variant" />
115 <param index="0" name="allow_objects" type="bool" default="false" />
116 <description>
117 Gets a Variant from the stream. If [param allow_objects] is [code]true[/code], decoding objects is allowed.
118 Internally, this uses the same decoding mechanism as the [method @GlobalScope.bytes_to_var] method.
119 [b]Warning:[/b] Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.
120 </description>
121 </method>
122 <method name="put_8">
123 <return type="void" />
124 <param index="0" name="value" type="int" />
125 <description>
126 Puts a signed byte into the stream.
127 </description>
128 </method>
129 <method name="put_16">
130 <return type="void" />
131 <param index="0" name="value" type="int" />
132 <description>
133 Puts a signed 16-bit value into the stream.
134 </description>
135 </method>
136 <method name="put_32">
137 <return type="void" />
138 <param index="0" name="value" type="int" />
139 <description>
140 Puts a signed 32-bit value into the stream.
141 </description>
142 </method>
143 <method name="put_64">
144 <return type="void" />
145 <param index="0" name="value" type="int" />
146 <description>
147 Puts a signed 64-bit value into the stream.
148 </description>
149 </method>
150 <method name="put_data">
151 <return type="int" enum="Error" />
152 <param index="0" name="data" type="PackedByteArray" />
153 <description>
154 Sends a chunk of data through the connection, blocking if necessary until the data is done sending. This function returns an [enum Error] code.
155 </description>
156 </method>
157 <method name="put_double">
158 <return type="void" />
159 <param index="0" name="value" type="float" />
160 <description>
161 Puts a double-precision float into the stream.
162 </description>
163 </method>
164 <method name="put_float">
165 <return type="void" />
166 <param index="0" name="value" type="float" />
167 <description>
168 Puts a single-precision float into the stream.
169 </description>
170 </method>
171 <method name="put_half">
172 <return type="void" />
173 <param index="0" name="value" type="float" />
174 <description>
175 Puts a half-precision float into the stream.
176 </description>
177 </method>
178 <method name="put_partial_data">
179 <return type="Array" />
180 <param index="0" name="data" type="PackedByteArray" />
181 <description>
182 Sends a chunk of data through the connection. If all the data could not be sent at once, only part of it will. This function returns two values, an [enum Error] code and an integer, describing how much data was actually sent.
183 </description>
184 </method>
185 <method name="put_string">
186 <return type="void" />
187 <param index="0" name="value" type="String" />
188 <description>
189 Puts a zero-terminated ASCII string into the stream prepended by a 32-bit unsigned integer representing its size.
190 [b]Note:[/b] To put an ASCII string without prepending its size, you can use [method put_data]:
191 [codeblocks]
192 [gdscript]
193 put_data("Hello world".to_ascii_buffer())
194 [/gdscript]
195 [csharp]
196 PutData("Hello World".ToAsciiBuffer());
197 [/csharp]
198 [/codeblocks]
199 </description>
200 </method>
201 <method name="put_u8">
202 <return type="void" />
203 <param index="0" name="value" type="int" />
204 <description>
205 Puts an unsigned byte into the stream.
206 </description>
207 </method>
208 <method name="put_u16">
209 <return type="void" />
210 <param index="0" name="value" type="int" />
211 <description>
212 Puts an unsigned 16-bit value into the stream.
213 </description>
214 </method>
215 <method name="put_u32">
216 <return type="void" />
217 <param index="0" name="value" type="int" />
218 <description>
219 Puts an unsigned 32-bit value into the stream.
220 </description>
221 </method>
222 <method name="put_u64">
223 <return type="void" />
224 <param index="0" name="value" type="int" />
225 <description>
226 Puts an unsigned 64-bit value into the stream.
227 </description>
228 </method>
229 <method name="put_utf8_string">
230 <return type="void" />
231 <param index="0" name="value" type="String" />
232 <description>
233 Puts a zero-terminated UTF-8 string into the stream prepended by a 32 bits unsigned integer representing its size.
234 [b]Note:[/b] To put a UTF-8 string without prepending its size, you can use [method put_data]:
235 [codeblocks]
236 [gdscript]
237 put_data("Hello world".to_utf8_buffer())
238 [/gdscript]
239 [csharp]
240 PutData("Hello World".ToUtf8Buffer());
241 [/csharp]
242 [/codeblocks]
243 </description>
244 </method>
245 <method name="put_var">
246 <return type="void" />
247 <param index="0" name="value" type="Variant" />
248 <param index="1" name="full_objects" type="bool" default="false" />
249 <description>
250 Puts a Variant into the stream. If [param full_objects] is [code]true[/code] encoding objects is allowed (and can potentially include code).
251 Internally, this uses the same encoding mechanism as the [method @GlobalScope.var_to_bytes] method.
252 </description>
253 </method>
254 </methods>
255 <members>
256 <member name="big_endian" type="bool" setter="set_big_endian" getter="is_big_endian_enabled" default="false">
257 If [code]true[/code], this [StreamPeer] will using big-endian format for encoding and decoding.
258 </member>
259 </members>
260 </class>