User:RossyMiles/Flatline: Difference between revisions

m
+cat
No edit summary
m (+cat)
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
Flatline is the most recent proposed multiplayer mod for Oni. This document is a work in progress.
Flatline is the most recent proposed multiplayer mod for Oni. This document is a work in progress.
== Protocol Information ==
UDP port 2[[Seven|7777]] and it's surrounding ports are unallocated and are unlikely to be used by any other application.


== Flatline API ==
== Flatline API ==
Both the Flatline clients and dedicated servers will run inside Daodan inside an official build of Oni. This is because a copy of Oni is needed to fully simulate the scripting and physics in a game.
Both the Flatline clients and dedicated servers will run inside Daodan inside an official build of Oni. This is because a copy of Oni is needed to fully simulate the scripting and physics in a game.


Two sets of functions will be provided. The Net* functions will provide a basic, non-blocking UDP sockets library. The FLr* functions will be the rest of the code required.
Two sets of functions will be provided. The Net* functions will provide a basic, non-blocking UDP sockets library and a basic, single-threaded, blocking UDP server. The FLr* functions will be the rest of the code required.


=== NetPlatform_* ===
=== NetPlatform_* ===
Line 33: Line 36:
Destroys a UDP socket created with NetUDPSocket_Create.
Destroys a UDP socket created with NetUDPSocket_Create.


bool '''NetUDPSocket_Send('''int '''socket''', sockaddr_in/sockaddr_in6 '''address''', const char* '''data''', uint16_t '''datalen)'''<br>
bool '''NetUDPSocket_Send('''int '''socket''', sockaddr* '''address''', const char* '''data''', uint16_t '''datalen)'''<br>
Sends a packet of data to the specified address using the specified socket. To broadcast a message across a LAN (such as when checking for available games), send it to 255.255.255.255 (IPv4 only).
Sends a packet of data to the specified address using the specified socket. To broadcast a message across a LAN (such as when checking for available games), send it to 255.255.255.255 (IPv4 only).


bool '''NetUDPSocket_Recieve('''int '''socket''', char* '''data''', uint16_t* '''datalen''', sockaddr_in*/sockaddr_in6* '''address)'''<br>
bool '''NetUDPSocket_Recieve('''int '''socket''', sockaddr_storage* '''address''', char* '''data''', uint16_t* '''datalen)'''<br>
Recieves a single packet from the specified socket. Places the received data in '''data''', the length of the data returned in '''datalen''', and the address the packet was received from in '''address'''. If there are no packets in the buffer, the function returns immediately.
Recieves a single packet from the specified socket. Places the received data in '''data''', the length of the data returned in '''datalen''', and the address the packet was received from in '''address'''. If there are no packets in the buffer, the function returns false.


=== NetUDPServer_* ===
=== NetUDPServer_* ===
These functions provide a basic, single-threaded, blocking UDP server.
These functions provide a basic, single-threaded, blocking UDP server.


int '''NetUDPServer_Run('''uint16_t '''port''', bool (*'''packet_callback''')'''('''char* '''data''', uint16_t '''datalen''', int '''from))'''<br>
int '''NetUDPServer_Listen('''uint16_t '''port''', bool (*'''packet_callback''')'''('''char* '''data''', uint16_t '''datalen''', int '''from))'''<br>
Starts a new UDP server on the specified port which calls '''packet_callback''' when a packet is recieved. Does not return until the server has finished running ('''packet_callback''' returns false).
Starts a new UDP server on the specified port which calls '''packet_callback''' when a packet is recieved. Does not return until the server has finished running ('''packet_callback''' returns false).


bool '''NetUDPServer_Send('''sockaddr_in/sockaddr_in6 '''address''', const char* '''data''', uint16_t '''datalen)'''<br>
bool '''NetUDPServer_Send('''sockaddr* '''address''', const char* '''data''', uint16_t '''datalen)'''<br>
Sends a packet of data to the specified address using the server running on the current thread. This function should only be called from '''packet_callback''' or functions called by '''packet_callback'''.
Sends a packet of data to the specified address using the server running on the current thread. This function should only be called from '''packet_callback''' or functions called by '''packet_callback'''.
=== FLrServer_* ===
These functions control the Flatline server.
[[Category:Modding projects]]