RaydiumWikiNi

ApiNetworkDetails

PagePrincipale :: DerniersChangements :: ParametresUtilisateur :: Vous êtes ec2-3-94-21-209.compute-1.amazonaws.com

28.2 Details


28.2.1 void raydium_network_write(struct sockaddr *to, int from, char type,char *buff)


Obviously, this function will send data.

If you're a client, you don't need to determine to field, as the only destination is the server, so you can use NULL, for example. If you're a server, you can use raydium_network_client_addr[] array.

As a client, from argument is generally your own uid (raydium_network_uid), but you can use any other player number if needed. As a server, from field is useless, since you are the only machine able to send data to clients.

As you may expect, type field is used to determine packet's type. You can use any (8 bits) value greater or equal to RAYDIUM_NETWORK_PACKET_BASE.

Finally, buff is a pointer to data's buffer. This buffer must be RAYDIUM_NETWORK_PACKET_SIZE long, and can be cleared or re-used after this call.

28.2.2 void raydium_network_broadcast(char type,char *buff)


Sends data over network.

Obviously, from network point of vue, only a server can broadcast (to his clients).

When a client needs to broadcast (from the game point of vue) some informations (his own position, for example), he must send this information to server, and the server will broadcast it.

This function uses the same arguments as previous one, except to and from, not needed here.

28.2.3 char raydium_network_read(int *id, char *type, char *buff)


Reads next packet from network (FIFO) stack.

This function uses the same arguments as previous ones, and returns data availability: RAYDIUM_NETWORK_DATA_OK, RAYDIUM_NETWORK_DATA_NONE or RAYDIUM_NETWORK_DATA_ERROR.

28.2.4 char raydium_network_read_flushed(int *id, char *type, char *buff)


Reads last packet from network stack.

All previous packets will be ignored, only the newest packet will be read (if any).

As you may miss some some important informations, you can use netcalls (see below) if you want to capture packets with a particular type, even with flushed reading.

28.2.5 char raydium_network_netcall_add(void *ptr, int type)


You can add a netcall (ptr) for a particular packet type.

In most cases, with multiplayer games, there is a main data stream (players state, for example: position, rotation, ...) and some random events: broadcast message, horn, player death, ...

With Raydium, you can read the main data stream with raydium_network_read_flushed(), and configure network callbacks (netcalls) on random events (using packet type).

Netcalls signature is: void(int type, char *buff)

As you may configure the same callback function for multiples packet types, this type is passed to your function, with the temporary buff buffer. You can extract from field from packet if needed.

28.2.6 char raydium_network_set_socket_block(int block)


By default, Raydium uses non-blocking network sockets: if you tried to read from a socket, you will receive a ...?DATA_NONE or ...?DATA_OK answer. You can change this behaviour with this function, using argument block as a boolean. With block != 0, raydium_network_read() will wait until data some data is ready.

28.2.7 char raydium_network_server_create(void)


Will transform you application into a server, accepting new clients instantaneously.

28.2.8 char raydium_network_client_connect_to(char *server)


This function will try to connect your application to server (hostname or ip address).

WARNING: For now, this call could be endless ! (server failure while connecting).

This function will succed returning 1 or 0 otherwise.

You are connected instantaneously, and you must start sending data before server timeout (defined by RAYDIUM_NETWORK_TIMEOUT). You player number can be found with raydium_network_uid variable, as said before.


Missing:
int raydium_network_propag_find (int type);
void raydium_network_propag_recv (int type, char *buff);
void raydium_network_propag_refresh_id (int i);
void raydium_network_propag_refresh (int type);
void raydium_network_propag_refresh_all (void);
int raydium_network_propag_add (int type, void *data, int size);
void raydium_network_queue_element_init (raydium_network_Tcp * e);
unsigned short raydium_network_queue_tcpid_gen (void);
void raydium_network_queue_tcpid_known_add (int tcpid, int player);
char raydium_network_queue_tcpid_known (unsigned short tcpid, unsigned short player);
char raydium_network_queue_is_tcpid (int type);
void raydium_network_queue_element_add (char *packet, struct sockaddr *to);
unsigned long *raydium_network_internal_find_delay_addr (int player);
void raydium_network_queue_check_time (void);
void raydium_network_queue_ack_send (unsigned short tcpid, struct sockaddr *to);
void raydium_network_queue_ack_recv (int type, char *buff);
void raydium_network_player_name (char *str);
void raydium_network_netcall_exec (int type, char *buff);
char raydium_network_timeout_check (void);
char raydium_network_init (void);
char raydium_server_accept_new (struct sockaddr *from, char *name);
void raydium_network_close (void);
void raydium_network_internal_server_delays_dump (void);
void raydium_network_internal_dump (void);

Return to RaydiumApiReference index.