tests: Trim .nim files trailing whitespace
via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} +
This commit is contained in:
parent
ac9c1cd6b9
commit
e80465dacf
372 changed files with 4486 additions and 4486 deletions
|
|
@ -1,52 +1,52 @@
|
|||
discard """Copyright (c) 2002-2012 Lee Salzman
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
"""
|
||||
|
||||
const Lib = "libenet.so.1(|.0.3)"
|
||||
|
||||
{.deadCodeElim: on.}
|
||||
const
|
||||
const
|
||||
ENET_VERSION_MAJOR* = 1
|
||||
ENET_VERSION_MINOR* = 3
|
||||
ENET_VERSION_PATCH* = 3
|
||||
template ENET_VERSION_CREATE(major, minor, patch: expr): expr =
|
||||
template ENET_VERSION_CREATE(major, minor, patch: expr): expr =
|
||||
(((major) shl 16) or ((minor) shl 8) or (patch))
|
||||
|
||||
const
|
||||
ENET_VERSION* = ENET_VERSION_CREATE(ENET_VERSION_MAJOR, ENET_VERSION_MINOR,
|
||||
const
|
||||
ENET_VERSION* = ENET_VERSION_CREATE(ENET_VERSION_MAJOR, ENET_VERSION_MINOR,
|
||||
ENET_VERSION_PATCH)
|
||||
type
|
||||
type
|
||||
TVersion* = cuint
|
||||
TSocketType*{.size: sizeof(cint).} = enum
|
||||
TSocketType*{.size: sizeof(cint).} = enum
|
||||
ENET_SOCKET_TYPE_STREAM = 1, ENET_SOCKET_TYPE_DATAGRAM = 2
|
||||
TSocketWait*{.size: sizeof(cint).} = enum
|
||||
ENET_SOCKET_WAIT_NONE = 0, ENET_SOCKET_WAIT_SEND = (1 shl 0),
|
||||
TSocketWait*{.size: sizeof(cint).} = enum
|
||||
ENET_SOCKET_WAIT_NONE = 0, ENET_SOCKET_WAIT_SEND = (1 shl 0),
|
||||
ENET_SOCKET_WAIT_RECEIVE = (1 shl 1)
|
||||
TSocketOption*{.size: sizeof(cint).} = enum
|
||||
ENET_SOCKOPT_NONBLOCK = 1, ENET_SOCKOPT_BROADCAST = 2,
|
||||
ENET_SOCKOPT_RCVBUF = 3, ENET_SOCKOPT_SNDBUF = 4,
|
||||
TSocketOption*{.size: sizeof(cint).} = enum
|
||||
ENET_SOCKOPT_NONBLOCK = 1, ENET_SOCKOPT_BROADCAST = 2,
|
||||
ENET_SOCKOPT_RCVBUF = 3, ENET_SOCKOPT_SNDBUF = 4,
|
||||
ENET_SOCKOPT_REUSEADDR = 5
|
||||
const
|
||||
const
|
||||
ENET_HOST_ANY* = 0
|
||||
ENET_HOST_BROADCAST* = 0xFFFFFFFF
|
||||
ENET_PORT_ANY* = 0
|
||||
|
||||
|
||||
ENET_PROTOCOL_MINIMUM_MTU* = 576
|
||||
ENET_PROTOCOL_MAXIMUM_MTU* = 4096
|
||||
ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS* = 32
|
||||
|
|
@ -57,29 +57,29 @@ const
|
|||
ENET_PROTOCOL_MAXIMUM_PEER_ID* = 0x00000FFF
|
||||
type
|
||||
PAddress* = ptr TAddress
|
||||
TAddress*{.pure, final.} = object
|
||||
TAddress*{.pure, final.} = object
|
||||
host*: cuint
|
||||
port*: cushort
|
||||
|
||||
TPacketFlag*{.size: sizeof(cint).} = enum
|
||||
FlagReliable = (1 shl 0),
|
||||
FlagUnsequenced = (1 shl 1),
|
||||
NoAllocate = (1 shl 2),
|
||||
|
||||
TPacketFlag*{.size: sizeof(cint).} = enum
|
||||
FlagReliable = (1 shl 0),
|
||||
FlagUnsequenced = (1 shl 1),
|
||||
NoAllocate = (1 shl 2),
|
||||
UnreliableFragment = (1 shl 3)
|
||||
|
||||
TENetListNode*{.pure, final.} = object
|
||||
|
||||
TENetListNode*{.pure, final.} = object
|
||||
next*: ptr T_ENetListNode
|
||||
previous*: ptr T_ENetListNode
|
||||
|
||||
PENetListIterator* = ptr TENetListNode
|
||||
TENetList*{.pure, final.} = object
|
||||
TENetList*{.pure, final.} = object
|
||||
sentinel*: TENetListNode
|
||||
|
||||
T_ENetPacket*{.pure, final.} = object
|
||||
|
||||
T_ENetPacket*{.pure, final.} = object
|
||||
TPacketFreeCallback* = proc (a2: ptr T_ENetPacket){.cdecl.}
|
||||
|
||||
|
||||
PPacket* = ptr TPacket
|
||||
TPacket*{.pure, final.} = object
|
||||
TPacket*{.pure, final.} = object
|
||||
referenceCount: csize
|
||||
flags*: cint
|
||||
data*: cstring#ptr cuchar
|
||||
|
|
@ -87,13 +87,13 @@ type
|
|||
freeCallback*: TPacketFreeCallback
|
||||
|
||||
PAcknowledgement* = ptr TAcknowledgement
|
||||
TAcknowledgement*{.pure, final.} = object
|
||||
TAcknowledgement*{.pure, final.} = object
|
||||
acknowledgementList*: TEnetListNode
|
||||
sentTime*: cuint
|
||||
command*: TEnetProtocol
|
||||
|
||||
POutgoingCommand* = ptr TOutgoingCommand
|
||||
TOutgoingCommand*{.pure, final.} = object
|
||||
TOutgoingCommand*{.pure, final.} = object
|
||||
outgoingCommandList*: TEnetListNode
|
||||
reliableSequenceNumber*: cushort
|
||||
unreliableSequenceNumber*: cushort
|
||||
|
|
@ -107,7 +107,7 @@ type
|
|||
packet*: PPacket
|
||||
|
||||
PIncomingCommand* = ptr TIncomingCommand
|
||||
TIncomingCommand*{.pure, final.} = object
|
||||
TIncomingCommand*{.pure, final.} = object
|
||||
incomingCommandList*: TEnetListNode
|
||||
reliableSequenceNumber*: cushort
|
||||
unreliableSequenceNumber*: cushort
|
||||
|
|
@ -117,52 +117,52 @@ type
|
|||
fragments*: ptr cuint
|
||||
packet*: ptr TPacket
|
||||
|
||||
TPeerState*{.size: sizeof(cint).} = enum
|
||||
ENET_PEER_STATE_DISCONNECTED = 0, ENET_PEER_STATE_CONNECTING = 1,
|
||||
ENET_PEER_STATE_ACKNOWLEDGING_CONNECT = 2,
|
||||
ENET_PEER_STATE_CONNECTION_PENDING = 3,
|
||||
ENET_PEER_STATE_CONNECTION_SUCCEEDED = 4, ENET_PEER_STATE_CONNECTED = 5,
|
||||
ENET_PEER_STATE_DISCONNECT_LATER = 6, ENET_PEER_STATE_DISCONNECTING = 7,
|
||||
TPeerState*{.size: sizeof(cint).} = enum
|
||||
ENET_PEER_STATE_DISCONNECTED = 0, ENET_PEER_STATE_CONNECTING = 1,
|
||||
ENET_PEER_STATE_ACKNOWLEDGING_CONNECT = 2,
|
||||
ENET_PEER_STATE_CONNECTION_PENDING = 3,
|
||||
ENET_PEER_STATE_CONNECTION_SUCCEEDED = 4, ENET_PEER_STATE_CONNECTED = 5,
|
||||
ENET_PEER_STATE_DISCONNECT_LATER = 6, ENET_PEER_STATE_DISCONNECTING = 7,
|
||||
ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT = 8, ENET_PEER_STATE_ZOMBIE = 9
|
||||
|
||||
TENetProtocolCommand*{.size: sizeof(cint).} = enum
|
||||
ENET_PROTOCOL_COMMAND_NONE = 0, ENET_PROTOCOL_COMMAND_ACKNOWLEDGE = 1,
|
||||
ENET_PROTOCOL_COMMAND_CONNECT = 2,
|
||||
ENET_PROTOCOL_COMMAND_VERIFY_CONNECT = 3,
|
||||
ENET_PROTOCOL_COMMAND_DISCONNECT = 4, ENET_PROTOCOL_COMMAND_PING = 5,
|
||||
ENET_PROTOCOL_COMMAND_SEND_RELIABLE = 6,
|
||||
ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE = 7,
|
||||
ENET_PROTOCOL_COMMAND_SEND_FRAGMENT = 8,
|
||||
ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED = 9,
|
||||
ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT = 10,
|
||||
ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11,
|
||||
ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT = 12,
|
||||
|
||||
TENetProtocolCommand*{.size: sizeof(cint).} = enum
|
||||
ENET_PROTOCOL_COMMAND_NONE = 0, ENET_PROTOCOL_COMMAND_ACKNOWLEDGE = 1,
|
||||
ENET_PROTOCOL_COMMAND_CONNECT = 2,
|
||||
ENET_PROTOCOL_COMMAND_VERIFY_CONNECT = 3,
|
||||
ENET_PROTOCOL_COMMAND_DISCONNECT = 4, ENET_PROTOCOL_COMMAND_PING = 5,
|
||||
ENET_PROTOCOL_COMMAND_SEND_RELIABLE = 6,
|
||||
ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE = 7,
|
||||
ENET_PROTOCOL_COMMAND_SEND_FRAGMENT = 8,
|
||||
ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED = 9,
|
||||
ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT = 10,
|
||||
ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE = 11,
|
||||
ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT = 12,
|
||||
ENET_PROTOCOL_COMMAND_COUNT = 13, ENET_PROTOCOL_COMMAND_MASK = 0x0000000F
|
||||
TENetProtocolFlag*{.size: sizeof(cint).} = enum
|
||||
TENetProtocolFlag*{.size: sizeof(cint).} = enum
|
||||
ENET_PROTOCOL_HEADER_SESSION_SHIFT = 12,
|
||||
ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 shl 6),
|
||||
ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 shl 7),
|
||||
ENET_PROTOCOL_HEADER_SESSION_MASK = (3 shl 12),
|
||||
ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 shl 14),
|
||||
ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = (1 shl 6),
|
||||
ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = (1 shl 7),
|
||||
ENET_PROTOCOL_HEADER_SESSION_MASK = (3 shl 12),
|
||||
ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = (1 shl 14),
|
||||
ENET_PROTOCOL_HEADER_FLAG_SENT_TIME = (1 shl 15),
|
||||
ENET_PROTOCOL_HEADER_FLAG_MASK = ENET_PROTOCOL_HEADER_FLAG_COMPRESSED.cint or
|
||||
ENET_PROTOCOL_HEADER_FLAG_SENT_TIME.cint
|
||||
|
||||
TENetProtocolHeader*{.pure, final.} = object
|
||||
|
||||
TENetProtocolHeader*{.pure, final.} = object
|
||||
peerID*: cushort
|
||||
sentTime*: cushort
|
||||
|
||||
TENetProtocolCommandHeader*{.pure, final.} = object
|
||||
TENetProtocolCommandHeader*{.pure, final.} = object
|
||||
command*: cuchar
|
||||
channelID*: cuchar
|
||||
reliableSequenceNumber*: cushort
|
||||
|
||||
TENetProtocolAcknowledge*{.pure, final.} = object
|
||||
TENetProtocolAcknowledge*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
receivedReliableSequenceNumber*: cushort
|
||||
receivedSentTime*: cushort
|
||||
|
||||
TENetProtocolConnect*{.pure, final.} = object
|
||||
TENetProtocolConnect*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
outgoingPeerID*: cushort
|
||||
incomingSessionID*: cuchar
|
||||
|
|
@ -178,7 +178,7 @@ type
|
|||
connectID*: cuint
|
||||
data*: cuint
|
||||
|
||||
TENetProtocolVerifyConnect*{.pure, final.} = object
|
||||
TENetProtocolVerifyConnect*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
outgoingPeerID*: cushort
|
||||
incomingSessionID*: cuchar
|
||||
|
|
@ -193,39 +193,39 @@ type
|
|||
packetThrottleDeceleration*: cuint
|
||||
connectID*: cuint
|
||||
|
||||
TENetProtocolBandwidthLimit*{.pure, final.} = object
|
||||
TENetProtocolBandwidthLimit*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
incomingBandwidth*: cuint
|
||||
outgoingBandwidth*: cuint
|
||||
|
||||
TENetProtocolThrottleConfigure*{.pure, final.} = object
|
||||
TENetProtocolThrottleConfigure*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
packetThrottleInterval*: cuint
|
||||
packetThrottleAcceleration*: cuint
|
||||
packetThrottleDeceleration*: cuint
|
||||
|
||||
TENetProtocolDisconnect*{.pure, final.} = object
|
||||
TENetProtocolDisconnect*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
data*: cuint
|
||||
|
||||
TENetProtocolPing*{.pure, final.} = object
|
||||
TENetProtocolPing*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
|
||||
TENetProtocolSendReliable*{.pure, final.} = object
|
||||
TENetProtocolSendReliable*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
dataLength*: cushort
|
||||
|
||||
TENetProtocolSendUnreliable*{.pure, final.} = object
|
||||
TENetProtocolSendUnreliable*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
unreliableSequenceNumber*: cushort
|
||||
dataLength*: cushort
|
||||
|
||||
TENetProtocolSendUnsequenced*{.pure, final.} = object
|
||||
TENetProtocolSendUnsequenced*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
unsequencedGroup*: cushort
|
||||
dataLength*: cushort
|
||||
|
||||
TENetProtocolSendFragment*{.pure, final.} = object
|
||||
TENetProtocolSendFragment*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
startSequenceNumber*: cushort
|
||||
dataLength*: cushort
|
||||
|
|
@ -233,12 +233,12 @@ type
|
|||
fragmentNumber*: cuint
|
||||
totalLength*: cuint
|
||||
fragmentOffset*: cuint
|
||||
|
||||
|
||||
## this is incomplete; need helper templates or something
|
||||
## ENetProtocol
|
||||
TENetProtocol*{.pure, final.} = object
|
||||
TENetProtocol*{.pure, final.} = object
|
||||
header*: TENetProtocolCommandHeader
|
||||
const
|
||||
const
|
||||
ENET_BUFFER_MAXIMUM* = (1 + 2 * ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS)
|
||||
ENET_HOST_RECEIVE_BUFFER_SIZE = 256 * 1024
|
||||
ENET_HOST_SEND_BUFFER_SIZE = 256 * 1024
|
||||
|
|
@ -270,39 +270,39 @@ when defined(Linux) or true:
|
|||
import posix
|
||||
const
|
||||
ENET_SOCKET_NULL*: cint = -1
|
||||
type
|
||||
type
|
||||
TENetSocket* = cint
|
||||
PEnetBuffer* = ptr object
|
||||
TENetBuffer*{.pure, final.} = object
|
||||
TENetBuffer*{.pure, final.} = object
|
||||
data*: pointer
|
||||
dataLength*: csize
|
||||
TENetSocketSet* = Tfd_set
|
||||
## see if these are different on win32, if not then get rid of these
|
||||
template ENET_HOST_TO_NET_16*(value: expr): expr =
|
||||
template ENET_HOST_TO_NET_16*(value: expr): expr =
|
||||
(htons(value))
|
||||
template ENET_HOST_TO_NET_32*(value: expr): expr =
|
||||
template ENET_HOST_TO_NET_32*(value: expr): expr =
|
||||
(htonl(value))
|
||||
template ENET_NET_TO_HOST_16*(value: expr): expr =
|
||||
template ENET_NET_TO_HOST_16*(value: expr): expr =
|
||||
(ntohs(value))
|
||||
template ENET_NET_TO_HOST_32*(value: expr): expr =
|
||||
template ENET_NET_TO_HOST_32*(value: expr): expr =
|
||||
(ntohl(value))
|
||||
|
||||
template ENET_SOCKETSET_EMPTY*(sockset: expr): expr =
|
||||
template ENET_SOCKETSET_EMPTY*(sockset: expr): expr =
|
||||
FD_ZERO(addr((sockset)))
|
||||
template ENET_SOCKETSET_ADD*(sockset, socket: expr): expr =
|
||||
template ENET_SOCKETSET_ADD*(sockset, socket: expr): expr =
|
||||
FD_SET(socket, addr((sockset)))
|
||||
template ENET_SOCKETSET_REMOVE*(sockset, socket: expr): expr =
|
||||
template ENET_SOCKETSET_REMOVE*(sockset, socket: expr): expr =
|
||||
FD_CLEAR(socket, addr((sockset)))
|
||||
template ENET_SOCKETSET_CHECK*(sockset, socket: expr): expr =
|
||||
template ENET_SOCKETSET_CHECK*(sockset, socket: expr): expr =
|
||||
FD_ISSET(socket, addr((sockset)))
|
||||
|
||||
when defined(Windows):
|
||||
## put the content of win32.h in here
|
||||
|
||||
|
||||
type
|
||||
type
|
||||
PChannel* = ptr TChannel
|
||||
TChannel*{.pure, final.} = object
|
||||
TChannel*{.pure, final.} = object
|
||||
outgoingReliableSequenceNumber*: cushort
|
||||
outgoingUnreliableSequenceNumber*: cushort
|
||||
usedReliableWindows*: cushort
|
||||
|
|
@ -313,7 +313,7 @@ type
|
|||
incomingUnreliableCommands*: TENetList
|
||||
|
||||
PPeer* = ptr TPeer
|
||||
TPeer*{.pure, final.} = object
|
||||
TPeer*{.pure, final.} = object
|
||||
dispatchList*: TEnetListNode
|
||||
host*: ptr THost
|
||||
outgoingPeerID*: cushort
|
||||
|
|
@ -367,25 +367,25 @@ type
|
|||
needsDispatch*: cint
|
||||
incomingUnsequencedGroup*: cushort
|
||||
outgoingUnsequencedGroup*: cushort
|
||||
unsequencedWindow*: array[0..ENET_PEER_UNSEQUENCED_WINDOW_SIZE div 32 - 1,
|
||||
unsequencedWindow*: array[0..ENET_PEER_UNSEQUENCED_WINDOW_SIZE div 32 - 1,
|
||||
cuint]
|
||||
eventData*: cuint
|
||||
|
||||
PCompressor* = ptr TCompressor
|
||||
TCompressor*{.pure, final.} = object
|
||||
TCompressor*{.pure, final.} = object
|
||||
context*: pointer
|
||||
compress*: proc (context: pointer; inBuffers: ptr TEnetBuffer;
|
||||
inBufferCount: csize; inLimit: csize;
|
||||
compress*: proc (context: pointer; inBuffers: ptr TEnetBuffer;
|
||||
inBufferCount: csize; inLimit: csize;
|
||||
outData: ptr cuchar; outLimit: csize): csize{.cdecl.}
|
||||
decompress*: proc (context: pointer; inData: ptr cuchar; inLimit: csize;
|
||||
decompress*: proc (context: pointer; inData: ptr cuchar; inLimit: csize;
|
||||
outData: ptr cuchar; outLimit: csize): csize{.cdecl.}
|
||||
destroy*: proc (context: pointer){.cdecl.}
|
||||
|
||||
TChecksumCallback* = proc (buffers: ptr TEnetBuffer; bufferCount: csize): cuint{.
|
||||
cdecl.}
|
||||
|
||||
|
||||
PHost* = ptr THost
|
||||
THost*{.pure, final.} = object
|
||||
THost*{.pure, final.} = object
|
||||
socket*: TEnetSocket
|
||||
address*: TAddress
|
||||
incomingBandwidth*: cuint
|
||||
|
|
@ -402,14 +402,14 @@ type
|
|||
continueSending*: cint
|
||||
packetSize*: csize
|
||||
headerFlags*: cushort
|
||||
commands*: array[0..ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS - 1,
|
||||
commands*: array[0..ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS - 1,
|
||||
TEnetProtocol]
|
||||
commandCount*: csize
|
||||
buffers*: array[0..ENET_BUFFER_MAXIMUM - 1, TEnetBuffer]
|
||||
bufferCount*: csize
|
||||
checksum*: TChecksumCallback
|
||||
compressor*: TCompressor
|
||||
packetData*: array[0..ENET_PROTOCOL_MAXIMUM_MTU - 1,
|
||||
packetData*: array[0..ENET_PROTOCOL_MAXIMUM_MTU - 1,
|
||||
array[0..2 - 1, cuchar]]
|
||||
receivedAddress*: TAddress
|
||||
receivedData*: ptr cuchar
|
||||
|
|
@ -418,19 +418,19 @@ type
|
|||
totalSentPackets*: cuint
|
||||
totalReceivedData*: cuint
|
||||
totalReceivedPackets*: cuint
|
||||
|
||||
TEventType*{.size: sizeof(cint).} = enum
|
||||
EvtNone = 0, EvtConnect = 1,
|
||||
|
||||
TEventType*{.size: sizeof(cint).} = enum
|
||||
EvtNone = 0, EvtConnect = 1,
|
||||
EvtDisconnect = 2, EvtReceive = 3
|
||||
PEvent* = ptr TEvent
|
||||
TEvent*{.pure, final.} = object
|
||||
TEvent*{.pure, final.} = object
|
||||
kind*: TEventType
|
||||
peer*: ptr TPeer
|
||||
channelID*: cuchar
|
||||
data*: cuint
|
||||
packet*: ptr TPacket
|
||||
|
||||
TENetCallbacks*{.pure, final.} = object
|
||||
TENetCallbacks*{.pure, final.} = object
|
||||
malloc*: proc (size: csize): pointer{.cdecl.}
|
||||
free*: proc (memory: pointer){.cdecl.}
|
||||
no_memory*: proc (){.cdecl.}
|
||||
|
|
@ -473,10 +473,10 @@ proc send*(socket: TEnetSocket; address: var TAddress; buffer: ptr TEnetBuffer;
|
|||
importc: "enet_socket_send", dynlib: Lib.}
|
||||
proc send*(socket: TEnetSocket; address: ptr TAddress; buffer: ptr TEnetBuffer; size: csize): cint{.
|
||||
importc: "enet_socket_send", dynlib: Lib.}
|
||||
proc receive*(socket: TEnetSocket; address: var TAddress;
|
||||
proc receive*(socket: TEnetSocket; address: var TAddress;
|
||||
buffer: ptr TEnetBuffer; size: csize): cint{.
|
||||
importc: "enet_socket_receive", dynlib: Lib.}
|
||||
proc receive*(socket: TEnetSocket; address: ptr TAddress;
|
||||
proc receive*(socket: TEnetSocket; address: ptr TAddress;
|
||||
buffer: ptr TEnetBuffer; size: csize): cint{.
|
||||
importc: "enet_socket_receive", dynlib: Lib.}
|
||||
proc wait*(socket: TEnetSocket; a3: ptr cuint; a4: cuint): cint{.
|
||||
|
|
@ -485,7 +485,7 @@ proc setOption*(socket: TEnetSocket; a3: TSocketOption; a4: cint): cint{.
|
|||
importc: "enet_socket_set_option", dynlib: Lib.}
|
||||
proc destroy*(socket: TEnetSocket){.
|
||||
importc: "enet_socket_destroy", dynlib: Lib.}
|
||||
proc select*(socket: TEnetSocket; a3: ptr TENetSocketSet;
|
||||
proc select*(socket: TEnetSocket; a3: ptr TENetSocketSet;
|
||||
a4: ptr TENetSocketSet; a5: cuint): cint{.
|
||||
importc: "enet_socketset_select", dynlib: Lib.}
|
||||
|
||||
|
|
@ -578,13 +578,13 @@ proc resetQueues*(peer: PPeer){.
|
|||
proc setupOutgoingCommand*(peer: PPeer; outgoingCommand: POutgoingCommand){.
|
||||
importc: "enet_peer_setup_outgoing_command", dynlib: Lib.}
|
||||
|
||||
proc queueOutgoingCommand*(peer: PPeer; command: ptr TEnetProtocol;
|
||||
proc queueOutgoingCommand*(peer: PPeer; command: ptr TEnetProtocol;
|
||||
packet: PPacket; offset: cuint; length: cushort): POutgoingCommand{.
|
||||
importc: "enet_peer_queue_outgoing_command", dynlib: Lib.}
|
||||
proc queueIncomingCommand*(peer: PPeer; command: ptr TEnetProtocol;
|
||||
proc queueIncomingCommand*(peer: PPeer; command: ptr TEnetProtocol;
|
||||
packet: PPacket; fragmentCount: cuint): PIncomingCommand{.
|
||||
importc: "enet_peer_queue_incoming_command", dynlib: Lib.}
|
||||
proc queueAcknowledgement*(peer: PPeer; command: ptr TEnetProtocol;
|
||||
proc queueAcknowledgement*(peer: PPeer; command: ptr TEnetProtocol;
|
||||
sentTime: cushort): PAcknowledgement{.
|
||||
importc: "enet_peer_queue_acknowledgement", dynlib: Lib.}
|
||||
proc dispatchIncomingUnreliableCommands*(peer: PPeer; channel: PChannel){.
|
||||
|
|
@ -596,10 +596,10 @@ proc createRangeCoder*(): pointer{.
|
|||
importc: "enet_range_coder_create", dynlib: Lib.}
|
||||
proc rangeCoderDestroy*(context: pointer){.
|
||||
importc: "enet_range_coder_destroy", dynlib: Lib.}
|
||||
proc rangeCoderCompress*(context: pointer; inBuffers: PEnetBuffer; inLimit,
|
||||
proc rangeCoderCompress*(context: pointer; inBuffers: PEnetBuffer; inLimit,
|
||||
bufferCount: csize; outData: cstring; outLimit: csize): csize{.
|
||||
importc: "enet_range_coder_compress", dynlib: Lib.}
|
||||
proc rangeCoderDecompress*(context: pointer; inData: cstring; inLimit: csize;
|
||||
proc rangeCoderDecompress*(context: pointer; inData: cstring; inLimit: csize;
|
||||
outData: cstring; outLimit: csize): csize{.
|
||||
importc: "enet_range_coder_decompress", dynlib: Lib.}
|
||||
proc protocolCommandSize*(commandNumber: cuchar): csize{.
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ while server.hostService(addr event, 2500) >= 0:
|
|||
case event.kind
|
||||
of EvtConnect:
|
||||
echo "New client from $1:$2".format(event.peer.address.host, event.peer.address.port)
|
||||
|
||||
|
||||
var
|
||||
msg = "hello"
|
||||
msg = "hello"
|
||||
resp = createPacket(cstring(msg), msg.len + 1, FlagReliable)
|
||||
|
||||
|
||||
if event.peer.send(0.cuchar, resp) < 0:
|
||||
echo "FAILED"
|
||||
else:
|
||||
|
|
@ -32,9 +32,9 @@ while server.hostService(addr event, 2500) >= 0:
|
|||
echo "Recvd ($1) $2 ".format(
|
||||
event.packet.dataLength,
|
||||
event.packet.data)
|
||||
|
||||
|
||||
destroy(event.packet)
|
||||
|
||||
|
||||
of EvtDisconnect:
|
||||
echo "Disconnected"
|
||||
event.peer.data = nil
|
||||
|
|
@ -42,4 +42,4 @@ while server.hostService(addr event, 2500) >= 0:
|
|||
discard
|
||||
|
||||
server.destroy()
|
||||
enetDeinit()
|
||||
enetDeinit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue