-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Bindings to the low-level netcode.io library. -- -- Bindings to the low-level netcode.io library, which come in two -- flavors: c-level bindings and a high-level interface to the library. -- For the low level interface, refer to the Bindings.Netcode.IO module. -- For the high-level interface, which is a bit closer to idiomatic -- Haskell, refer to the Netcode.IO module. @package netcode-io @version 0.0.3 -- | This module contains the low-level bindings that represent the direct -- interface between Haskell and the C library netcode.io. -- -- The bindings here are meant for advanced usage, as they are not -- particularly idiomatic Haskell, and largely represent the types that -- we get from the bindings-DSL library. For high level bindings -- (recommended), please refer to the Netcode.IO module. module Bindings.Netcode.IO c'NETCODE_CONNECT_TOKEN_BYTES :: Num a => a c'NETCODE_KEY_BYTES :: Num a => a c'NETCODE_MAC_BYTES :: Num a => a c'NETCODE_USER_DATA_BYTES :: Num a => a c'NETCODE_MAX_SERVERS_PER_CONNECT :: Num a => a c'NETCODE_CLIENT_STATE_CONNECT_TOKEN_EXPIRED :: Num a => a c'NETCODE_CLIENT_STATE_INVALID_CONNECT_TOKEN :: Num a => a c'NETCODE_CLIENT_STATE_CONNECTION_TIMED_OUT :: Num a => a c'NETCODE_CLIENT_STATE_CONNECTION_RESPONSE_TIMED_OUT :: Num a => a c'NETCODE_CLIENT_STATE_CONNECTION_REQUEST_TIMED_OUT :: Num a => a c'NETCODE_CLIENT_STATE_CONNECTION_DENIED :: Num a => a c'NETCODE_CLIENT_STATE_DISCONNECTED :: Num a => a c'NETCODE_CLIENT_STATE_SENDING_CONNECTION_REQUEST :: Num a => a c'NETCODE_CLIENT_STATE_SENDING_CONNECTION_RESPONSE :: Num a => a c'NETCODE_CLIENT_STATE_CONNECTED :: Num a => a c'NETCODE_MAX_CLIENTS :: Num a => a c'NETCODE_MAX_PACKET_SIZE :: Num a => a c'NETCODE_LOG_LEVEL_NONE :: Num a => a c'NETCODE_LOG_LEVEL_ERROR :: Num a => a c'NETCODE_LOG_LEVEL_INFO :: Num a => a c'NETCODE_LOG_LEVEL_DEBUG :: Num a => a c'NETCODE_OK :: Num a => a c'NETCODE_ERROR :: Num a => a c'NETCODE_ADDRESS_NONE :: Num a => a c'NETCODE_ADDRESS_IPV4 :: Num a => a c'NETCODE_ADDRESS_IPV6 :: Num a => a c'netcode_init :: IO CInt c'netcode_term :: IO () p'netcode_init :: FunPtr (IO CInt) p'netcode_term :: FunPtr (IO ()) data C'netcode_address_t C'netcode_address_t :: [Word8] -> [Word16] -> Word16 -> Word8 -> C'netcode_address_t [c'netcode_address_t'data'ipv4] :: C'netcode_address_t -> [Word8] [c'netcode_address_t'data'ipv6] :: C'netcode_address_t -> [Word16] [c'netcode_address_t'port] :: C'netcode_address_t -> Word16 [c'netcode_address_t'type] :: C'netcode_address_t -> Word8 c'netcode_parse_address :: CString -> Ptr C'netcode_address_t -> IO CInt c'netcode_address_to_string :: Ptr C'netcode_address_t -> CString -> IO CString p'netcode_parse_address :: FunPtr (CString -> Ptr C'netcode_address_t -> IO CInt) c'netcode_address_equal :: Ptr C'netcode_address_t -> Ptr C'netcode_address_t -> IO CInt p'netcode_address_to_string :: FunPtr (Ptr C'netcode_address_t -> CString -> IO CString) data C'netcode_network_simulator_t C'netcode_network_simulator_t :: C'netcode_network_simulator_t p'netcode_address_equal :: FunPtr (Ptr C'netcode_address_t -> Ptr C'netcode_address_t -> IO CInt) data C'netcode_client_t C'netcode_client_t :: C'netcode_client_t p'netcode_address_t'data'ipv4 :: Ptr C'netcode_address_t -> Ptr Word8 data C'netcode_server_t C'netcode_server_t :: C'netcode_server_t p'netcode_address_t'data'ipv6 :: Ptr C'netcode_address_t -> Ptr Word16 type C'allocate_function_t = FunPtr (Ptr () -> Word64 -> IO (Ptr ())) type C'free_function_t = FunPtr (Ptr () -> Ptr () -> IO ()) p'netcode_address_t'port :: Ptr C'netcode_address_t -> Ptr Word16 mk'allocate_function_t :: (Ptr () -> Word64 -> IO (Ptr ())) -> IO C'allocate_function_t type C'state_change_callback_t = FunPtr (Ptr () -> CInt -> CInt -> IO ()) mk'free_function_t :: (Ptr () -> Ptr () -> IO ()) -> IO C'free_function_t p'netcode_address_t'type :: Ptr C'netcode_address_t -> Ptr Word8 type C'connect_disconnect_callback_t = FunPtr (Ptr () -> CInt -> CInt -> IO ()) mK'allocate_function_t :: C'allocate_function_t -> Ptr () -> Word64 -> IO (Ptr ()) mk'state_change_callback_t :: (Ptr () -> CInt -> CInt -> IO ()) -> IO C'state_change_callback_t type C'send_loopback_packet_callback_t = FunPtr (Ptr () -> CInt -> Ptr Word8 -> CInt -> Word64 -> IO ()) mK'free_function_t :: C'free_function_t -> Ptr () -> Ptr () -> IO () mk'connect_disconnect_callback_t :: (Ptr () -> CInt -> CInt -> IO ()) -> IO C'connect_disconnect_callback_t type C'send_packet_override_t = FunPtr (Ptr () -> Ptr C'netcode_address_t -> Ptr Word8 -> CInt -> IO ()) mK'state_change_callback_t :: C'state_change_callback_t -> Ptr () -> CInt -> CInt -> IO () mk'send_loopback_packet_callback_t :: (Ptr () -> CInt -> Ptr Word8 -> CInt -> Word64 -> IO ()) -> IO C'send_loopback_packet_callback_t type C'receive_packet_override_t = FunPtr (Ptr () -> Ptr C'netcode_address_t -> Ptr Word8 -> CInt -> IO CInt) mK'connect_disconnect_callback_t :: C'connect_disconnect_callback_t -> Ptr () -> CInt -> CInt -> IO () mk'send_packet_override_t :: (Ptr () -> Ptr C'netcode_address_t -> Ptr Word8 -> CInt -> IO ()) -> IO C'send_packet_override_t mK'send_loopback_packet_callback_t :: C'send_loopback_packet_callback_t -> Ptr () -> CInt -> Ptr Word8 -> CInt -> Word64 -> IO () mk'receive_packet_override_t :: (Ptr () -> Ptr C'netcode_address_t -> Ptr Word8 -> CInt -> IO CInt) -> IO C'receive_packet_override_t mK'send_packet_override_t :: C'send_packet_override_t -> Ptr () -> Ptr C'netcode_address_t -> Ptr Word8 -> CInt -> IO () mK'receive_packet_override_t :: C'receive_packet_override_t -> Ptr () -> Ptr C'netcode_address_t -> Ptr Word8 -> CInt -> IO CInt data C'netcode_client_config_t C'netcode_client_config_t :: Ptr () -> C'allocate_function_t -> C'free_function_t -> Ptr C'netcode_network_simulator_t -> Ptr () -> C'state_change_callback_t -> C'send_loopback_packet_callback_t -> CInt -> C'send_packet_override_t -> C'receive_packet_override_t -> C'netcode_client_config_t [c'netcode_client_config_t'allocator_context] :: C'netcode_client_config_t -> Ptr () [c'netcode_client_config_t'allocate_function] :: C'netcode_client_config_t -> C'allocate_function_t [c'netcode_client_config_t'free_function] :: C'netcode_client_config_t -> C'free_function_t [c'netcode_client_config_t'network_simulator] :: C'netcode_client_config_t -> Ptr C'netcode_network_simulator_t [c'netcode_client_config_t'callback_context] :: C'netcode_client_config_t -> Ptr () [c'netcode_client_config_t'state_change_callback] :: C'netcode_client_config_t -> C'state_change_callback_t [c'netcode_client_config_t'send_loopback_packet_callback] :: C'netcode_client_config_t -> C'send_loopback_packet_callback_t [c'netcode_client_config_t'override_send_and_receive] :: C'netcode_client_config_t -> CInt [c'netcode_client_config_t'send_packet_override] :: C'netcode_client_config_t -> C'send_packet_override_t [c'netcode_client_config_t'receive_packet_override] :: C'netcode_client_config_t -> C'receive_packet_override_t c'netcode_default_client_config :: Ptr C'netcode_client_config_t -> IO () c'netcode_client_create :: CString -> Ptr C'netcode_client_config_t -> CDouble -> IO (Ptr C'netcode_client_t) c'netcode_client_destroy :: Ptr C'netcode_client_t -> IO () p'netcode_default_client_config :: FunPtr (Ptr C'netcode_client_config_t -> IO ()) c'netcode_client_connect :: Ptr C'netcode_client_t -> Ptr Word8 -> IO () p'netcode_client_create :: FunPtr (CString -> Ptr C'netcode_client_config_t -> CDouble -> IO (Ptr C'netcode_client_t)) p'netcode_client_destroy :: FunPtr (Ptr C'netcode_client_t -> IO ()) c'netcode_client_update :: Ptr C'netcode_client_t -> CDouble -> IO () c'netcode_client_next_packet_sequence :: Ptr C'netcode_client_t -> IO Word64 p'netcode_client_connect :: FunPtr (Ptr C'netcode_client_t -> Ptr Word8 -> IO ()) p'netcode_client_update :: FunPtr (Ptr C'netcode_client_t -> CDouble -> IO ()) c'netcode_client_send_packet :: Ptr C'netcode_client_t -> Ptr Word8 -> CInt -> IO () p'netcode_client_next_packet_sequence :: FunPtr (Ptr C'netcode_client_t -> IO Word64) c'netcode_client_receive_packet :: Ptr C'netcode_client_t -> Ptr CInt -> Ptr Word64 -> IO (Ptr Word8) c'netcode_client_free_packet :: Ptr C'netcode_client_t -> Ptr () -> IO () p'netcode_client_send_packet :: FunPtr (Ptr C'netcode_client_t -> Ptr Word8 -> CInt -> IO ()) c'netcode_client_disconnect :: Ptr C'netcode_client_t -> IO () p'netcode_client_receive_packet :: FunPtr (Ptr C'netcode_client_t -> Ptr CInt -> Ptr Word64 -> IO (Ptr Word8)) c'netcode_client_state :: Ptr C'netcode_client_t -> IO CInt p'netcode_client_free_packet :: FunPtr (Ptr C'netcode_client_t -> Ptr () -> IO ()) p'netcode_client_config_t'allocator_context :: Ptr C'netcode_client_config_t -> Ptr (Ptr ()) c'netcode_client_index :: Ptr C'netcode_client_t -> IO CInt p'netcode_client_disconnect :: FunPtr (Ptr C'netcode_client_t -> IO ()) c'netcode_client_max_clients :: Ptr C'netcode_client_t -> IO CInt p'netcode_client_state :: FunPtr (Ptr C'netcode_client_t -> IO CInt) p'netcode_client_config_t'allocate_function :: Ptr C'netcode_client_config_t -> Ptr C'allocate_function_t p'netcode_client_index :: FunPtr (Ptr C'netcode_client_t -> IO CInt) c'netcode_client_connect_loopback :: Ptr C'netcode_client_t -> CInt -> CInt -> IO () c'netcode_client_disconnect_loopback :: Ptr C'netcode_client_t -> IO () p'netcode_client_max_clients :: FunPtr (Ptr C'netcode_client_t -> IO CInt) p'netcode_client_config_t'free_function :: Ptr C'netcode_client_config_t -> Ptr C'free_function_t p'netcode_client_connect_loopback :: FunPtr (Ptr C'netcode_client_t -> CInt -> CInt -> IO ()) c'netcode_client_process_packet :: Ptr C'netcode_client_t -> Ptr C'netcode_address_t -> Ptr Word8 -> CInt -> IO () c'netcode_client_loopback :: Ptr C'netcode_client_t -> IO CInt p'netcode_client_disconnect_loopback :: FunPtr (Ptr C'netcode_client_t -> IO ()) p'netcode_client_config_t'network_simulator :: Ptr C'netcode_client_config_t -> Ptr (Ptr C'netcode_network_simulator_t) c'netcode_client_process_loopback_packet :: Ptr C'netcode_client_t -> Ptr Word8 -> CInt -> Word64 -> IO () p'netcode_client_process_packet :: FunPtr (Ptr C'netcode_client_t -> Ptr C'netcode_address_t -> Ptr Word8 -> CInt -> IO ()) c'netcode_client_get_port :: Ptr C'netcode_client_t -> IO Word16 p'netcode_client_loopback :: FunPtr (Ptr C'netcode_client_t -> IO CInt) p'netcode_client_config_t'callback_context :: Ptr C'netcode_client_config_t -> Ptr (Ptr ()) c'netcode_client_server_address :: Ptr C'netcode_client_t -> IO (Ptr C'netcode_address_t) p'netcode_client_process_loopback_packet :: FunPtr (Ptr C'netcode_client_t -> Ptr Word8 -> CInt -> Word64 -> IO ()) p'netcode_client_get_port :: FunPtr (Ptr C'netcode_client_t -> IO Word16) c'netcode_generate_connect_token :: CInt -> Ptr CString -> Ptr CString -> CInt -> CInt -> Word64 -> Word64 -> Ptr Word8 -> Ptr Word8 -> Ptr Word8 -> IO CInt p'netcode_client_config_t'state_change_callback :: Ptr C'netcode_client_config_t -> Ptr C'state_change_callback_t p'netcode_client_server_address :: FunPtr (Ptr C'netcode_client_t -> IO (Ptr C'netcode_address_t)) p'netcode_generate_connect_token :: FunPtr (CInt -> Ptr CString -> Ptr CString -> CInt -> CInt -> Word64 -> Word64 -> Ptr Word8 -> Ptr Word8 -> Ptr Word8 -> IO CInt) p'netcode_client_config_t'send_loopback_packet_callback :: Ptr C'netcode_client_config_t -> Ptr C'send_loopback_packet_callback_t p'netcode_client_config_t'override_send_and_receive :: Ptr C'netcode_client_config_t -> Ptr CInt p'netcode_client_config_t'send_packet_override :: Ptr C'netcode_client_config_t -> Ptr C'send_packet_override_t p'netcode_client_config_t'receive_packet_override :: Ptr C'netcode_client_config_t -> Ptr C'receive_packet_override_t data C'netcode_server_config_t C'netcode_server_config_t :: Word64 -> [Word8] -> Ptr () -> C'allocate_function_t -> C'free_function_t -> Ptr C'netcode_network_simulator_t -> Ptr () -> C'connect_disconnect_callback_t -> C'send_loopback_packet_callback_t -> CInt -> C'send_packet_override_t -> C'receive_packet_override_t -> C'netcode_server_config_t [c'netcode_server_config_t'protocol_id] :: C'netcode_server_config_t -> Word64 [c'netcode_server_config_t'private_key] :: C'netcode_server_config_t -> [Word8] [c'netcode_server_config_t'allocator_context] :: C'netcode_server_config_t -> Ptr () [c'netcode_server_config_t'allocate_function] :: C'netcode_server_config_t -> C'allocate_function_t [c'netcode_server_config_t'free_function] :: C'netcode_server_config_t -> C'free_function_t [c'netcode_server_config_t'network_simulator] :: C'netcode_server_config_t -> Ptr C'netcode_network_simulator_t [c'netcode_server_config_t'callback_context] :: C'netcode_server_config_t -> Ptr () [c'netcode_server_config_t'connect_disconnect_callback] :: C'netcode_server_config_t -> C'connect_disconnect_callback_t [c'netcode_server_config_t'send_loopback_packet_callback] :: C'netcode_server_config_t -> C'send_loopback_packet_callback_t [c'netcode_server_config_t'override_send_and_receive] :: C'netcode_server_config_t -> CInt [c'netcode_server_config_t'send_packet_override] :: C'netcode_server_config_t -> C'send_packet_override_t [c'netcode_server_config_t'receive_packet_override] :: C'netcode_server_config_t -> C'receive_packet_override_t c'netcode_default_server_config :: Ptr C'netcode_server_config_t -> IO () c'netcode_server_create :: CString -> Ptr C'netcode_server_config_t -> CDouble -> IO (Ptr C'netcode_server_t) c'netcode_server_destroy :: Ptr C'netcode_server_t -> IO () p'netcode_default_server_config :: FunPtr (Ptr C'netcode_server_config_t -> IO ()) c'netcode_server_start :: Ptr C'netcode_server_t -> CInt -> IO () p'netcode_server_create :: FunPtr (CString -> Ptr C'netcode_server_config_t -> CDouble -> IO (Ptr C'netcode_server_t)) c'netcode_server_stop :: Ptr C'netcode_server_t -> IO () p'netcode_server_destroy :: FunPtr (Ptr C'netcode_server_t -> IO ()) c'netcode_server_running :: Ptr C'netcode_server_t -> IO CInt p'netcode_server_start :: FunPtr (Ptr C'netcode_server_t -> CInt -> IO ()) c'netcode_server_max_clients :: Ptr C'netcode_server_t -> IO CInt p'netcode_server_stop :: FunPtr (Ptr C'netcode_server_t -> IO ()) c'netcode_server_update :: Ptr C'netcode_server_t -> CDouble -> IO () p'netcode_server_running :: FunPtr (Ptr C'netcode_server_t -> IO CInt) c'netcode_server_client_connected :: Ptr C'netcode_server_t -> CInt -> IO CInt p'netcode_server_max_clients :: FunPtr (Ptr C'netcode_server_t -> IO CInt) c'netcode_server_client_id :: Ptr C'netcode_server_t -> CInt -> IO Word64 p'netcode_server_update :: FunPtr (Ptr C'netcode_server_t -> CDouble -> IO ()) p'netcode_server_client_connected :: FunPtr (Ptr C'netcode_server_t -> CInt -> IO CInt) c'netcode_server_client_address :: Ptr C'netcode_server_t -> CInt -> IO (Ptr C'netcode_address_t) c'netcode_server_disconnect_client :: Ptr C'netcode_server_t -> CInt -> IO () p'netcode_server_client_id :: FunPtr (Ptr C'netcode_server_t -> CInt -> IO Word64) c'netcode_server_disconnect_all_clients :: Ptr C'netcode_server_t -> IO () p'netcode_server_client_address :: FunPtr (Ptr C'netcode_server_t -> CInt -> IO (Ptr C'netcode_address_t)) p'netcode_server_config_t'protocol_id :: Ptr C'netcode_server_config_t -> Ptr Word64 c'netcode_server_next_packet_sequence :: Ptr C'netcode_server_t -> CInt -> IO Word64 p'netcode_server_disconnect_client :: FunPtr (Ptr C'netcode_server_t -> CInt -> IO ()) p'netcode_server_disconnect_all_clients :: FunPtr (Ptr C'netcode_server_t -> IO ()) c'netcode_server_send_packet :: Ptr C'netcode_server_t -> CInt -> Ptr Word8 -> CInt -> IO () p'netcode_server_config_t'private_key :: Ptr C'netcode_server_config_t -> Ptr Word8 p'netcode_server_next_packet_sequence :: FunPtr (Ptr C'netcode_server_t -> CInt -> IO Word64) c'netcode_server_receive_packet :: Ptr C'netcode_server_t -> CInt -> Ptr CInt -> Ptr Word64 -> IO (Ptr Word8) c'netcode_server_free_packet :: Ptr C'netcode_server_t -> Ptr () -> IO () p'netcode_server_send_packet :: FunPtr (Ptr C'netcode_server_t -> CInt -> Ptr Word8 -> CInt -> IO ()) p'netcode_server_config_t'allocator_context :: Ptr C'netcode_server_config_t -> Ptr (Ptr ()) c'netcode_server_num_connected_clients :: Ptr C'netcode_server_t -> IO CInt p'netcode_server_receive_packet :: FunPtr (Ptr C'netcode_server_t -> CInt -> Ptr CInt -> Ptr Word64 -> IO (Ptr Word8)) c'netcode_server_client_user_data :: Ptr C'netcode_server_t -> CInt -> IO (Ptr ()) p'netcode_server_free_packet :: FunPtr (Ptr C'netcode_server_t -> Ptr () -> IO ()) p'netcode_server_config_t'allocate_function :: Ptr C'netcode_server_config_t -> Ptr C'allocate_function_t p'netcode_server_num_connected_clients :: FunPtr (Ptr C'netcode_server_t -> IO CInt) c'netcode_server_process_packet :: Ptr C'netcode_server_t -> Ptr C'netcode_address_t -> Ptr Word8 -> CInt -> IO () p'netcode_server_client_user_data :: FunPtr (Ptr C'netcode_server_t -> CInt -> IO (Ptr ())) c'netcode_server_connect_loopback_client :: Ptr C'netcode_server_t -> CInt -> Word64 -> Ptr Word8 -> IO () p'netcode_server_config_t'free_function :: Ptr C'netcode_server_config_t -> Ptr C'free_function_t c'netcode_server_disconnect_loopback_client :: Ptr C'netcode_server_t -> CInt -> IO () p'netcode_server_process_packet :: FunPtr (Ptr C'netcode_server_t -> Ptr C'netcode_address_t -> Ptr Word8 -> CInt -> IO ()) c'netcode_server_client_loopback :: Ptr C'netcode_server_t -> CInt -> IO CInt p'netcode_server_connect_loopback_client :: FunPtr (Ptr C'netcode_server_t -> CInt -> Word64 -> Ptr Word8 -> IO ()) p'netcode_server_config_t'network_simulator :: Ptr C'netcode_server_config_t -> Ptr (Ptr C'netcode_network_simulator_t) p'netcode_server_disconnect_loopback_client :: FunPtr (Ptr C'netcode_server_t -> CInt -> IO ()) c'netcode_server_process_loopback_packet :: Ptr C'netcode_server_t -> CInt -> Ptr Word8 -> CInt -> Word64 -> IO () c'netcode_server_get_port :: Ptr C'netcode_server_t -> IO Word16 p'netcode_server_client_loopback :: FunPtr (Ptr C'netcode_server_t -> CInt -> IO CInt) p'netcode_server_config_t'callback_context :: Ptr C'netcode_server_config_t -> Ptr (Ptr ()) p'netcode_server_process_loopback_packet :: FunPtr (Ptr C'netcode_server_t -> CInt -> Ptr Word8 -> CInt -> Word64 -> IO ()) c'netcode_log_level :: CInt -> IO () p'netcode_server_get_port :: FunPtr (Ptr C'netcode_server_t -> IO Word16) p'netcode_server_config_t'connect_disconnect_callback :: Ptr C'netcode_server_config_t -> Ptr C'connect_disconnect_callback_t type C'netcode_assert_function_ty = FunPtr (CString -> CString -> CString -> CInt -> IO ()) p'netcode_log_level :: FunPtr (CInt -> IO ()) p'netcode_server_config_t'send_loopback_packet_callback :: Ptr C'netcode_server_config_t -> Ptr C'send_loopback_packet_callback_t c'netcode_set_assert_function :: C'netcode_assert_function_ty -> IO () mk'netcode_assert_function_ty :: (CString -> CString -> CString -> CInt -> IO ()) -> IO C'netcode_assert_function_ty p'netcode_server_config_t'override_send_and_receive :: Ptr C'netcode_server_config_t -> Ptr CInt p'netcode_set_assert_function :: FunPtr (C'netcode_assert_function_ty -> IO ()) mK'netcode_assert_function_ty :: C'netcode_assert_function_ty -> CString -> CString -> CString -> CInt -> IO () p'netcode_server_config_t'send_packet_override :: Ptr C'netcode_server_config_t -> Ptr C'send_packet_override_t c'netcode_random_bytes :: Ptr Word8 -> CInt -> IO () c'netcode_sleep :: CDouble -> IO () p'netcode_server_config_t'receive_packet_override :: Ptr C'netcode_server_config_t -> Ptr C'receive_packet_override_t c'netcode_time :: IO CDouble p'netcode_random_bytes :: FunPtr (Ptr Word8 -> CInt -> IO ()) p'netcode_sleep :: FunPtr (CDouble -> IO ()) -- | For testing only. p'netcode_time :: FunPtr (IO CDouble) c'netcode_test :: IO () p'netcode_test :: FunPtr (IO ()) instance GHC.Show.Show Bindings.Netcode.IO.C'netcode_address_t instance GHC.Classes.Eq Bindings.Netcode.IO.C'netcode_address_t instance GHC.Show.Show Bindings.Netcode.IO.C'netcode_client_config_t instance GHC.Classes.Eq Bindings.Netcode.IO.C'netcode_client_config_t instance GHC.Show.Show Bindings.Netcode.IO.C'netcode_server_config_t instance GHC.Classes.Eq Bindings.Netcode.IO.C'netcode_server_config_t instance Foreign.Storable.Storable Bindings.Netcode.IO.C'netcode_server_config_t instance Foreign.Storable.Storable Bindings.Netcode.IO.C'netcode_client_config_t instance Foreign.Storable.Storable Bindings.Netcode.IO.C'netcode_address_t -- | This module contains the high-level bindings on top of the module -- Bindings.Netcode.IO. These provide a cleaner interface to the -- netcode.io C library and are the recommended interface for -- application developers. -- -- These bindings have some limitations. Namely, they are not as -- performant as the "close to the metal" bindings provided in -- Bindings.Netcode.IO. In the event that you need more -- performance, that module is available for use. -- -- The general architecture of a netcode.io application is -- outlined in the C library documentation. The jist is that we -- need three main entities: -- --
-- >>> parseAddress "123.231.132.213" >>= addressValues -- [123, 231, 132, 213] ---- -- The length of the list is either 4 or 8 depending on the address mode. -- If the address mode is unknown, addressValues returns the empty -- list. addressValues :: Address -> IO [Word16] -- | Returns an address with the given values interpreted using the given -- mode. For IPv4 addresses, only the bottom 8 bits of each 16-bit word -- will be used. The list will be zero padded to contain enough values to -- fill the address as needed. constructAddress :: AddressMode -> Word16 -> [Word16] -> IO Address -- | Takes a String and parses it to create an Address. The -- string should be formatted as either a valid IPv4 or IPv6 address. It -- does not, however, support dual address modes. parseAddress :: String -> IO Address -- | Returns a string that represents the given Address. addressToString :: Address -> IO String -- | Returns True if two addresses are equal by examining their memory -- contents. addressEqual :: Address -> Address -> IO Bool -- | Override that sends a packet to the given address. This can be used by -- both clients and servers. This is invoked after netcode.io -- processes and encrypts the packet. type SendPacketOverride = Address " 'Address' to send the packet to" -> Ptr Word8 " A pointer to the memory that holds the packet data" -> CInt " The size of the packet" -> IO () -- | Override that receives a packet from the given address. This can be -- used by both clients and servers. This is invoked before -- netcode.io processes and decrypts the packet data. -- -- Implementations of this callback are meant to fill the memory at the -- given pointer with the data from a packet received from the -- Address. The maximum size of the buffer pointed to is also -- passed and the implementation is expected to return the actual size of -- the packet. In the event that there is no packet (or equivalently, no -- packet data), then the implementation should return zero. type ReceivePacketOverride = Address " Address from which to receive a packet" -> Ptr Word8 " Pointer to the buffer where to write packet data" -> CInt " Maximum size of destination buffer in bytes" -> IO CInt " Return value: should be size of packet data" -- | A packet is a basic unit of data that is transferred between client -- and server. Sequence numbers indicate the order in which the packets -- were sent, and this library contains no guarantee that they will be -- received in a monotonically increasing order. data Packet Packet :: Word64 -> Int -> ForeignPtr Word8 -> Packet -- | The sequence number for this packet. [packetSequenceNumber] :: Packet -> Word64 -- | The size, in bytes, of the data stored at packetDataPtr [packetSize] :: Packet -> Int -- | A pointer to the bytes that are contained in this packet. This can be -- cast to any pointer type for the purposes of deseralizing, but this -- pointer must outlive the amount of time that this library has been -- initialized. [packetDataPtr] :: Packet -> ForeignPtr Word8 -- | The maximum size, in bytes, of a packet. In other words, this is the -- maximum value that packetSize can take. maximumPacketSize :: Num a => a -- | A client-specific callback that gets invoked each time the underlying -- state of the client changes. type ClientStateChangeCallback = ClientState " Old state" -> ClientState " New state" -> IO () -- | A ClientConfig is a type that specifies the behavior of a -- Client. Client configs are pretty spartan: the only options -- available at this time are setting callbacks. data ClientConfig -- | A ClientConfig with no callback overrides. defaultClientConfig :: ClientConfig -- | Creates a config that removes the existing -- ClientStateChangeCallback and instead uses the given callback. setClientStateChangeCallback :: ClientStateChangeCallback -> ClientConfig -> ClientConfig -- | Clears the ClientStateChangeCallback for the given config. clearClientStateChangeCallback :: ClientConfig -> ClientConfig -- | Removes the existing send and receive overrides for the given config, -- if set, and instead uses the ones given. setClientSendReceiveOverrides :: SendPacketOverride -> ReceivePacketOverride -> ClientConfig -> ClientConfig -- | Changes the config to use the default send and receive packet -- functions. clearClientSendReceiveOverrides :: ClientConfig -> ClientConfig -- | A client object. This is an opaque type meant to be used in -- conjunction with this library. -- -- A Client is generally meant to connect to one of potentially -- many servers through a ConnectToken. The main loop of the -- application that manages the lifetime of the client is expected to -- maintain a running timer with a resolution of at least seconds. This -- main loop is also expected to call updateClient on a regular -- basis to allow the library to process incoming packets and send -- outgoing packets. data Client -- | Creates a client at the given address using the provided config. -- Throws an IOException on failure. -- -- Note, the address used here can be either formatted as an IPv4 address -- or an IPv6 address, similar to the arguments passed to -- parseAddress. In the common case, you will likely want to use -- INADDR_ANY to bind to the underlying socket, which is represented by -- the address "0.0.0.0" -- -- The time passed to this create function should be a measurement in -- seconds, such that when connecting in the future using -- updateClient, the same resolution timer is being passed. That -- allows the library to properly timeout in cases where connections are -- taking too long to establish. createClient :: String -> ClientConfig -> Double -> IO Client -- | Destroys the client and frees all of the Haskell-side function -- pointers that were registered as callbacks. destroyClient :: Client -> IO () -- | Generates a random 64-bit client ID to be used with -- generateConnectToken generateClientID :: IO Word64 -- | Begin the process to connect the client to a server stored in the -- given ConnectToken. This does not connect the client -- immediately, but rather resets the client object and sets the state to -- ClientState'SendingConnectionRequest. The client will attempt -- to connect on the next call to updateClient. connectClient :: Client -> ConnectToken -> IO () -- | Disconnects the client from anything it might be connected to. disconnectClient :: Client -> IO () -- | Main processing call for clients with the current time in seconds (in -- the same domain as the time passed to createClient). This -- flushes packet queues at the appropriate rate and updates connection -- statuses among other things. It is expected to be called in the main -- loop of the application. updateClient :: Client -> Double -> IO () -- | Enqueues a packet to be sent during the next call to -- updateClient. sendPacketFromClient :: Client -> Int -> Ptr Word8 -> IO () -- | Dequeues a received packet from the Server. This function -- returns a Just until the queue is empty, upon which it will -- return Nothing. receivePacketFromServer :: Client -> IO (Maybe Packet) -- | Returns the sequence number of the next packet that the Client -- will send. nextClientPacketSequence :: Client -> IO Word64 -- | Returns the port assigned to this Client. getClientPort :: Client -> IO Word16 -- | Performs an action with the address of the server to which the given -- Client is connected to. This is meant to minimize the chances -- that the Address value will be used in a manner that outlives -- the given Client. Callers should avoid storing the -- Address value or returning it as a result of this function. -- -- In the event that the client is not connected to a server, the address -- passed to the action will be 0.0.0.0. withClientServerAddress :: Client -> (Address -> IO a) -> IO a -- | The possible connection states of a Client. The default state -- is ClientState'Disconnected. data ClientState ClientState'ConnectTokenExpired :: ClientState ClientState'InvalidConnectToken :: ClientState ClientState'ConnectionTimedOut :: ClientState ClientState'ConnectionResponseTimedOut :: ClientState ClientState'ConnectionRequestTimedOut :: ClientState ClientState'ConnectionDenied :: ClientState ClientState'Disconnected :: ClientState ClientState'SendingConnectionRequest :: ClientState ClientState'SendingConnectionResponse :: ClientState ClientState'Connected :: ClientState -- | Returns the current state of the Client. getClientState :: Client -> IO ClientState -- | Returns true if the Client is in a state considered to be -- disconnected, as opposed to connected or connecting. isClientDisconnected :: Client -> IO Bool -- | A ConnectToken represents an encrypted set of data fields that -- describe both the client requesting to make a connection and the -- available servers to which that connection can be made. It is -- generated solely via the data ConnectToken -- | Returns the maximum number of servers that can be stored in a -- ConnectToken. maximumServersPerConnect :: Num a => a -- | Gives the maximum size, in bytes, of user data stored in a -- ConnectToken. maximumUserDataSize :: Num a => a -- | Returns the number of bytes expected in the private key used to -- generate a ConnectToken privateKeySize :: Num a => a -- | Creates a connect token for the given client (by clientID) with the -- list of associated addresses. User data may be at most -- maximumUserDataSize values, otherwise is truncated or -- zero-padded to fill. The list of public and internal servers must not -- be empty and may contain at most maximumServersPerConnect -- values, otherwise is truncated. Throws an IOException on failure. generateConnectToken :: [(String, String)] -> Int -> Int -> Word64 -> Word64 -> [Word8] -> [Word8] -> IO ConnectToken -- | A server-specific callback that gets invoked each time a client either -- connects to, or disconnects from, the server. type ServerConnectDisconnectCallback = Int " Client index connected" -> Bool " True if the client connected" -> IO () -- | A ServerConfig is a type that specifies the behavior of a -- Server and contains associated metadata. -- -- At a minimum, the connection protocol ID and the private key for the -- application should be set for each server (via setProtocolID -- and setPrivateKey, respectively). data ServerConfig -- | The default ServerConfig contains no callbacks or overrides, -- and contains empty values for the required fields needed to properly -- have a server respond to a connecting Client. defaultServerConfig :: ServerConfig -- | Sets the connection protocol ID used by this Server. This is a -- unique ID that must match the protocol ID used in -- generateConnectToken setProtocolID :: Word64 -> ServerConfig -> ServerConfig -- | Sets the private key used by this Server. This key must match -- the private key used in generateConnectToken setPrivateKey :: [Word8] -> ServerConfig -> ServerConfig -- | Replaces the existing ServerConnectDisconnectCallback with the -- given one and frees any associated memory that may be allocated for -- the the existing callback. setServerConnectDisconnectCallback :: ServerConnectDisconnectCallback -> ServerConfig -> ServerConfig -- | Removes the existing ServerConnectDisconnectCallback and frees -- any associated memory that may be allocated for the the existing -- callback. clearServerConnectDisconnectCallback :: ServerConfig -> ServerConfig -- | Removes the existing send and receive overrides for the given config, -- if set, and instead uses the ones given. setServerSendReceiveOverrides :: SendPacketOverride -> ReceivePacketOverride -> ServerConfig -> ServerConfig -- | Changes the config to use the default send and receive packet -- functions. clearServerSendReceiveOverrides :: ServerConfig -> ServerConfig -- | A server object. This is an opaque type meant to be used in -- conjunction with this library. -- -- A server is generally meant to represent and endpoint for one or more -- Clients to connect to. The server application is similar to -- that of the client in that it is expected to have a running timer with -- a resolution of at least seconds. The main loop of the server -- application is meant to call updateServer to allow the library -- to process incoming packets and send outgoing packets to the clients. data Server -- | Creates a server at the given address using the provided config. -- Throws an IOException on failure. -- -- Note, the address used here can be either formatted as an IPv4 address -- or an IPv6 address, similar to the arguments passed to -- parseAddress. In the common case, you will likely want to use -- INADDR_ANY to bind to the underlying socket, which is represented by -- the address "0.0.0.0" -- -- The time passed to this create function should be a measurement in -- seconds, such that when connecting in the future using -- updateServer, the same resolution timer is being passed. That -- allows the library to properly timeout in cases where connections are -- taking too long to establish. createServer :: String -> ServerConfig -> Double -> IO Server -- | Destroys the server object and frees the associated Haskell-side -- callbacks and overrides destroyServer :: Server -> IO () -- | Starts the server and specifies the maximum number of clients that can -- connect. Emits a warning when the maximum number of clients is more -- than maxNumClients. startServer :: Server -> Int -> IO () -- | Returns the maximum number of clients that a server can support. maxNumClients :: Num a => a -- | Stops the server. stopServer :: Server -> IO () -- | Main processing call for a Server with the current time in -- seconds (in the same domain as the time passed to -- createServer). This flushes packet queues at the appropriate -- rate and updates connection statuses among other things. It is -- expected to be called in the main loop of the application. updateServer :: Server -> Double -> IO () -- | Returns True if the client at the given client index is -- connected to the server. Returns False if not connected, if -- the server is not running, or if the client index is out of bounds. clientConnectedAtIndex :: Server -> Int -> IO Bool -- | Returns the client ID of the client at the given client index. Returns -- 0 if not connected, the server is not running, or if the -- client index is out of bounds. clientIdAtIndex :: Server -> Int -> IO Word64 -- | Performs an action with the address of the client to which the given -- Server is connected to. This is meant to minimize the chances -- that the Address value will be used in a manner that outlives -- the given Server or the connection lifetime of the client. -- Callers should avoid storing the Address value or returning it -- as a result of this function. -- -- In the event that the client index is out of bounds, or the client is -- not connected at that slot, the address passed to the action will be -- 0.0.0.0. withClientAddressAtIndex :: Server -> Int -> (Address -> IO a) -> IO a -- | Performs an action with the user data of the client to which the given -- Server is connected to. This is meant to minimize the chances -- that the memory buffer will be used in a manner that outlives the -- given Server or the connection lifetime of the client. Callers -- should avoid storing the Ptr value or returning it as a -- result of this function. -- -- In the event that the client index is out of bounds, or the client is -- not connected at that slot, the given action will receive -- nullPtr. withClientUserDataAtIndex :: Server -> Int -> (Ptr () -> IO a) -> IO a -- | Returns the user data for the client connected at the given client -- index. -- -- In the event that the client index is out of bounds, or the client is -- not connected at that slot, the result will be the empty list. clientUserDataAtIndex :: Server -> Int -> IO [Word8] -- | Returns the maximum number of clients that can connect to this server, -- or zero if the server has not been started yet (via a call to -- startServer). maxClientsForServer :: Server -> IO Int -- | Returns the number of currently connected clients. numConnectedClients :: Server -> IO Int -- | Returns True if the server has been started, and is ready to accept -- incoming connections from clients. isServerRunning :: Server -> IO Bool -- | Returns true if the number of connected clients matches the maximum -- number of possibly connected clients. isServerFull :: Server -> IO Bool -- | Returns the port assigned to the server's IP address. getServerPort :: Server -> IO Word16 -- | Enqueues a packet to be sent to the client at the given index during -- the next call to updateServer. sendPacketFromServer :: Server -> Int -> Int -> Ptr Word8 -> IO () -- | Enqueues a packet with the given size and data to all connected -- clients. broadcastPacketFromServer :: Server -> Int -> Ptr Word8 -> IO () -- | Disconnects the client at the given index from the server. disconnectClientFromServer :: Server -> Int -> IO () -- | Disconnects all clients from the server. disconnectAllClientsFromServer :: Server -> IO () -- | Dequeues a received packet from the Client at the given client -- index. This function returns a Just until the queue is empty, -- upon which it will return a Nothing. receivePacketFromClient :: Server -> Int -> IO (Maybe Packet) -- | Returns the next sequence number of a packet destined for the client -- at the given client index. nextServerPacketSequence :: Server -> Int -> IO Word64 -- | Sleep the current thread. This is usually only used in example -- programs. It's probably safer to use the built-in threadDelay. sleep :: Double -> IO () -- | Specifies the logging behavior of netcode.io. Note, this -- logging behavior is called from C calls to printf and -- therefore might interfere with the Haskell runtime (such as -- putStrLn). data LogLevel LogLevel'None :: LogLevel LogLevel'Info :: LogLevel LogLevel'Error :: LogLevel LogLevel'Debug :: LogLevel -- | Set the netcode.io LogLevel. The default is -- LogLevel'None. logLevel :: LogLevel -> IO () instance Data.Data.Data Netcode.IO.LogLevel instance GHC.Generics.Generic Netcode.IO.LogLevel instance GHC.Enum.Enum Netcode.IO.LogLevel instance GHC.Enum.Bounded Netcode.IO.LogLevel instance GHC.Read.Read Netcode.IO.LogLevel instance GHC.Show.Show Netcode.IO.LogLevel instance GHC.Classes.Ord Netcode.IO.LogLevel instance GHC.Classes.Eq Netcode.IO.LogLevel