Have anyone any experience with ENet?
It is a mess everything is Byte Pointers. What am I supposed to do with them? I want the data as a string or a array of bytes.
If anyone can or have worked this out it would be greatly appriciated. Or do I have to use GNet to use ENet. I guess the ENet module isn't meant to be used by others. Atleast it is great that the source is open, to bad it is encrypted ;)
ENet_initialize()
Global EventList:TList = CreateList()
'Host a Server:
Global Host:Byte Ptr
Host = ENet_host_create( enet_address_create( HostIp(IP$),port ), peerCount, incBandwidth, outBandwidth)
'IP$ is the IP in the String form, ex IP$ = "127.0.0.1"
'Port is the port number you want To host on, this is what others connect To, ex port = 8000
'peerCount is maximum number of players allowed.
'IncBandwidth is the maximum Incoming bandwidth ENet is allowed To use.
'OutBandwidth is the maximum Outgoing bandwidth ENet is allowed To use.
While Not KeyDown( Key_Escape )
Local Event:ENetEvent = New ENetEvent
Local Timeout = 0
'Checks for new events
ENet_host_service( Host,Event,timeout )
'Now you can put the Event in a list Or so.
Select Event.Event
Case ENET_EVENT_TYPE_CONNECT
Case ENET_EVENT_TYPE_RECEIVE
Event.packet
Event.peer
Event.channelID
Case ENET_EVENT_TYPE_DISCONNECT
EndSelect
Wend
|