Module Net


module Net: sig  end
High-level networking. This module provides a protocol for data exchange and synchronization.

val process : bool -> bool
process tick_time Do what i mean. should be called every mainloop rotation in client and server.
Returns true if a new frame should happen. Whie we are the server or when not connected it is equal to tick_time whilst on a client it is true only if a new packet with messages has been received. It means that all events which happened have been received and processed and it is time for a new frame to happen.

tick_time : should be true if it is time for a new frame
val init : (int -> bool -> bool -> unit) -> unit
init pl_change_fun adds 'connect' and 'server' to console.

pl_change_fun : is the function called on each instance of the program when a new player comes or a player leaves. It informs the game that a player has connected or leaved. The game receives the number of player, is the player a local one and if the player is a new one.
val add_broadcast : 'a Serialize.t -> (int -> 'a -> unit) -> int -> 'a -> unit
add_broadcast serialize client_recv adds an automatically broadcasted message.
Returns function used to send such this message. When any of the connected instances of the program calls the this function, client_recv will be called on all of them, including the one that send it and the server.

Most game actions should be added with this function Here and in all following functions the int param is the number of the player who sent the original message.

val add_client_to_server : 'a Serialize.t -> (int -> 'a -> unit) -> int -> 'a -> unit
val add_server_to_client : 'a Serialize.t -> ('a -> unit) -> int list -> 'a -> unit
val add_server_broadcast : 'a Serialize.t -> ('a -> unit) -> 'a -> unit
val check_privileged : unit -> bool
check_privileged ()
Returns true if we are privileged. At the time of writing this only the server is privileged.
val add_var : string -> 'a Parser.t -> 'a -> 'a Pervasives.ref * (string -> unit)
add_var name converter is used to add a net changeable variable. This is a variable just like added by Parser.add_variable, but it can be changed via console only on privileged clients. Every console change to such a variable is broadcasted to all other clients and to the server.
val get_local_players : unit -> int list
get_local_players ()
Returns the list of local player numbers
val add_synchronizer : (int -> unit) -> unit
add_synchronizer fnctn adds a function called on the server whenever a new player connects. It is used to synchronize the new player with the current world state