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