User:RossyMiles/Flatline

From OniGalore
< User:RossyMiles
Revision as of 02:09, 16 July 2009 by RossyMiles (talk | contribs) (a work in progress ^_^)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Flatline is the most recent proposed multiplayer mod for Oni. This document is a work in progress.

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.

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.

NetPlatform_*

bool NetPlatform_Initalize()
This function is called when the network functionality is required. On Windows, it makes a call to WSAStartup.

bool NetPlatform_Shutdown()
For every call to NetPlatform_Initalize, there has to be a corresponsing call to NetPlatform_Shutdown. On Windows, this function calls WSACleanup.

NetUDPSocket_*

int NetUDPSocket_Create(uint16_t port)
Creates a new, non-blocking, UDP socket and binds it to the port specified. If the specified port is 0, the socket is automatically bound to an unused port.

bool NetUDPSocket_Close(int socket)
Destroys a UDP socket created with NetUDPSocket_Create.

bool NetUDPSocket_Send(int socket, sockaddr_in/sockaddr_in6 address, const char* data, uint16_t datalen)
Sends a packet of data to the specified address using the specified socket.

bool NetUDPSocket_Recieve(int socket, char* data, uint16_t* datalen, sockaddr_in*/sockaddr_in6* address)
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.