1 module godot.c.net;
2 
3 import godot.c.core;
4 
5 import core.stdc.stdint;
6 
7 @nogc nothrow:
8 extern(C):
9 
10 // Use these to populate version in your plugin
11 enum GODOT_NET_API_MAJOR = 3;
12 enum GODOT_NET_API_MINOR = 1;
13 
14 struct godot_net_stream_peer
15 {
16 
17 	godot_gdnative_api_version ver; /* version of our API */
18 	godot_object data; /* User reference */
19 
20 	/* This is StreamPeer */
21 	godot_error function(void* user, ubyte* p_buffer, int p_bytes) get_data;
22 	godot_error function(void* user, ubyte* p_buffer, int p_bytes, int* r_received) get_partial_data;
23 	godot_error function(void* user, const ubyte* p_data, int p_bytes) put_data;
24 	godot_error function(void* user, const ubyte* p_data, int p_bytes, int* r_sent) put_partial_data;
25 
26 	int function(const void* user) get_available_bytes;
27 
28 	void* next; /* For extension? */
29 }
30 
31 struct godot_net_packet_peer
32 {
33 	godot_gdnative_api_version ver; /* version of our API */
34 
35 	godot_object data; /* User reference */
36 
37 	/* This is PacketPeer */
38 	godot_error function(void*, const ubyte**, int*) get_packet;
39 	godot_error function(void*, const ubyte*, int) put_packet;
40 	godot_int function(const void*) get_available_packet_count;
41 	godot_int function(const void*) get_max_packet_size;
42 
43 	void* next; /* For extension? */
44 }
45 
46 struct godot_net_multiplayer_peer
47 {
48 	godot_gdnative_api_version ver; /* version of our API */
49 
50 	godot_object data; /* User reference */
51 
52 	/* This is PacketPeer */
53 	godot_error function(void*, const ubyte**, int*) get_packet;
54 	godot_error function(void*, const ubyte*, int) put_packet;
55 	godot_int function(const void*) get_available_packet_count;
56 	godot_int function(const void*) get_max_packet_size;
57 
58 	/* This is NetworkedMultiplayerPeer */
59 	void function(void*, godot_int) set_transfer_mode;
60 	godot_int function(const void*) get_transfer_mode;
61 	// 0 = broadcast, 1 = server, <0 = all but abs(value)
62 	void function(void*, godot_int) set_target_peer;
63 	godot_int function(const void*) get_packet_peer;
64 	godot_bool function(const void*) is_server;
65 	void function(void*) poll;
66 	// Must be > 0, 1 is for server
67 	int function(const void*) get_unique_id;
68 	void function(void*, godot_bool) set_refuse_new_connections;
69 	godot_bool function(const void*) is_refusing_new_connections;
70 	godot_int function(const void*) get_connection_status;
71 
72 	void* next; /* For extension? Or maybe not... */
73 }
74 
75 struct godot_net_webrtc_library
76 {
77 	godot_gdnative_api_version version_; /* version of our API */
78 
79 	/* Called when the library is unset as default interface via godot_net_set_webrtc_library */
80 	void* function() unregistered;
81 
82 	/* Used by WebRTCPeerConnection create when GDNative is the default implementation. */
83 	/* Takes a pointer to WebRTCPeerConnectionGDNative, should bind and return OK, failure if binding was unsuccessful. */
84 	godot_error* function(godot_object *) create_peer_connection;
85 
86 	void* next; /* For extension */
87 }
88 
89 /* WebRTCPeerConnection interface */
90 struct godot_net_webrtc_peer_connection
91 {
92 	godot_gdnative_api_version version_; /* version of our API */
93 
94 	godot_object *data; /* User reference */
95 
96 	/* This is WebRTCPeerConnection */
97 	godot_int function(const void *) get_connection_state;
98 
99 	godot_error function(void *, const godot_dictionary *) initialize;
100 	godot_object* function(void *, const char *p_channel_name, const godot_dictionary *) create_data_channel;
101 	godot_error function(void *) create_offer;
102 	godot_error function(void *) create_answer; /* unused for now, should be done automatically on set_local_description */
103 	godot_error function(void *, const char *, const char *) set_remote_description;
104 	godot_error function(void *, const char *, const char *) set_local_description;
105 	godot_error function(void *, const char *, int, const char *) add_ice_candidate;
106 	godot_error function(void *) poll;
107 	void function(void *) close;
108 
109 	void* next; /* For extension? */
110 }
111 
112 /* WebRTCDataChannel interface */
113 struct godot_net_webrtc_data_channel
114 {
115 	godot_gdnative_api_version version_; /* version of our API */
116 
117 	godot_object *data; /* User reference */
118 
119 	/* This is PacketPeer */
120 	godot_error function(void *, const uint8_t **, int *) get_packet;
121 	godot_error function(void *, const uint8_t *, int) put_packet;
122 	godot_int function(const void *) get_available_packet_count;
123 	godot_int function(const void *) get_max_packet_size;
124 
125 	/* This is WebRTCDataChannel */
126 	void function(void *, godot_int) set_write_mode;
127 	godot_int function(const void *) get_write_mode;
128 	bool function(const void *) was_string_packet;
129 
130 	godot_int function(const void *) get_ready_state;
131 	const char* function(const void *) get_label;
132 	bool function(const void *) is_ordered;
133 	int function(const void *) get_id;
134 	int function(const void *) get_max_packet_life_time;
135 	int function(const void *) get_max_retransmits;
136 	const char* function(const void *) get_protocol;
137 	bool function(const void *) is_negotiated;
138 
139 	godot_error function(void *) poll;
140 	void function(void *) close;
141 
142 	void* next; /* For extension? */
143 }
144 
145 struct godot_net_webrtc_peer
146 {
147 	godot_gdnative_api_version ver; /* version of our API */
148 
149 	godot_object data; /* User reference */
150 
151 	/* This is PacketPeer */
152 	godot_error function(void*, const ubyte**, int*) get_packet;
153 	godot_error function(void*, const ubyte*, int) put_packet;
154 	godot_int function(const void*) get_available_packet_count;
155 	godot_int function(const void*) get_max_packet_size;
156 
157 	/* This is WebRTCPeer */
158 	void function(void*, godot_int) set_write_mode;
159 	godot_int function(const void*) get_write_mode;
160 	bool function(const void*) was_string_packet;
161 	godot_int function(const void*) get_connection_state;
162 
163 	godot_error function(void*) create_offer;
164 	godot_error function(void*, const char*, const char*) set_remote_description;
165 	godot_error function(void*, const char*, const char*) set_local_description;
166 	godot_error function(void*, const char*, int, const char*) add_ice_candidate;
167 	godot_error function(void*) poll;
168 
169 	void* next; /* For extension? */
170 }
171