|
|
@@ -16,40 +16,44 @@ namespace ETModel
|
|
|
#endif
|
|
|
|
|
|
[DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
|
|
|
- public static extern uint ikcp_check(IntPtr kcp, uint current);
|
|
|
+ private static extern uint ikcp_check(IntPtr kcp, uint current);
|
|
|
[DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
|
|
|
- public static extern IntPtr ikcp_create(uint conv, IntPtr user);
|
|
|
+ private static extern IntPtr ikcp_create(uint conv, IntPtr user);
|
|
|
[DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
|
|
|
- public static extern void ikcp_flush(IntPtr kcp);
|
|
|
+ private static extern void ikcp_flush(IntPtr kcp);
|
|
|
[DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
|
|
|
- public static extern uint ikcp_getconv(IntPtr ptr);
|
|
|
+ private static extern uint ikcp_getconv(IntPtr ptr);
|
|
|
[DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
|
|
|
- public static extern int ikcp_input(IntPtr kcp, byte[] data, long offset, long size);
|
|
|
+ private static extern int ikcp_input(IntPtr kcp, byte[] data, long offset, long size);
|
|
|
[DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
|
|
|
- public static extern int ikcp_nodelay(IntPtr kcp, int nodelay, int interval, int resend, int nc);
|
|
|
+ private static extern int ikcp_nodelay(IntPtr kcp, int nodelay, int interval, int resend, int nc);
|
|
|
[DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
|
|
|
- public static extern int ikcp_peeksize(IntPtr kcp);
|
|
|
+ private static extern int ikcp_peeksize(IntPtr kcp);
|
|
|
[DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
|
|
|
- public static extern int ikcp_recv(IntPtr kcp, byte[] buffer, int len);
|
|
|
+ private static extern int ikcp_recv(IntPtr kcp, byte[] buffer, int len);
|
|
|
[DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
|
|
|
- public static extern void ikcp_release(IntPtr kcp);
|
|
|
+ private static extern void ikcp_release(IntPtr kcp);
|
|
|
[DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
|
|
|
- public static extern int ikcp_send(IntPtr kcp, byte[] buffer, int len);
|
|
|
+ private static extern int ikcp_send(IntPtr kcp, byte[] buffer, int len);
|
|
|
[DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
|
|
|
- public static extern void ikcp_setminrto(IntPtr ptr, int minrto);
|
|
|
+ private static extern void ikcp_setminrto(IntPtr ptr, int minrto);
|
|
|
[DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
|
|
|
- public static extern int ikcp_setmtu(IntPtr kcp, int mtu);
|
|
|
+ private static extern int ikcp_setmtu(IntPtr kcp, int mtu);
|
|
|
[DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
|
|
|
- public static extern void ikcp_setoutput(IntPtr kcp, kcp_output output);
|
|
|
+ private static extern void ikcp_setoutput(IntPtr kcp, kcp_output output);
|
|
|
[DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
|
|
|
- public static extern void ikcp_update(IntPtr kcp, uint current);
|
|
|
+ private static extern void ikcp_update(IntPtr kcp, uint current);
|
|
|
[DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
|
|
|
- public static extern int ikcp_waitsnd(IntPtr kcp);
|
|
|
+ private static extern int ikcp_waitsnd(IntPtr kcp);
|
|
|
[DllImport(KcpDLL, CallingConvention=CallingConvention.Cdecl)]
|
|
|
- public static extern int ikcp_wndsize(IntPtr kcp, int sndwnd, int rcvwnd);
|
|
|
+ private static extern int ikcp_wndsize(IntPtr kcp, int sndwnd, int rcvwnd);
|
|
|
|
|
|
public static uint KcpCheck(IntPtr kcp, uint current)
|
|
|
{
|
|
|
+ if (kcp == IntPtr.Zero)
|
|
|
+ {
|
|
|
+ throw new Exception($"kcp error, kcp point is zero");
|
|
|
+ }
|
|
|
return ikcp_check(kcp, current);
|
|
|
}
|
|
|
|
|
|
@@ -60,71 +64,127 @@ namespace ETModel
|
|
|
|
|
|
public static void KcpFlush(IntPtr kcp)
|
|
|
{
|
|
|
+ if (kcp == IntPtr.Zero)
|
|
|
+ {
|
|
|
+ throw new Exception($"kcp error, kcp point is zero");
|
|
|
+ }
|
|
|
ikcp_flush(kcp);
|
|
|
}
|
|
|
|
|
|
public static uint KcpGetconv(IntPtr ptr)
|
|
|
{
|
|
|
+ if (ptr == IntPtr.Zero)
|
|
|
+ {
|
|
|
+ throw new Exception($"kcp error, kcp point is zero");
|
|
|
+ }
|
|
|
return ikcp_getconv(ptr);
|
|
|
}
|
|
|
|
|
|
public static int KcpInput(IntPtr kcp, byte[] data, long offset, long size)
|
|
|
{
|
|
|
+ if (kcp == IntPtr.Zero)
|
|
|
+ {
|
|
|
+ throw new Exception($"kcp error, kcp point is zero");
|
|
|
+ }
|
|
|
return ikcp_input(kcp, data, offset, size);
|
|
|
}
|
|
|
|
|
|
public static int KcpNodelay(IntPtr kcp, int nodelay, int interval, int resend, int nc)
|
|
|
{
|
|
|
+ if (kcp == IntPtr.Zero)
|
|
|
+ {
|
|
|
+ throw new Exception($"kcp error, kcp point is zero");
|
|
|
+ }
|
|
|
return ikcp_nodelay(kcp, nodelay, interval, resend, nc);
|
|
|
}
|
|
|
|
|
|
public static int KcpPeeksize(IntPtr kcp)
|
|
|
{
|
|
|
+ if (kcp == IntPtr.Zero)
|
|
|
+ {
|
|
|
+ throw new Exception($"kcp error, kcp point is zero");
|
|
|
+ }
|
|
|
return ikcp_peeksize(kcp);
|
|
|
}
|
|
|
|
|
|
public static int KcpRecv(IntPtr kcp, byte[] buffer, int len)
|
|
|
{
|
|
|
+ if (kcp == IntPtr.Zero)
|
|
|
+ {
|
|
|
+ throw new Exception($"kcp error, kcp point is zero");
|
|
|
+ }
|
|
|
return ikcp_recv(kcp, buffer, len);
|
|
|
}
|
|
|
|
|
|
public static void KcpRelease(IntPtr kcp)
|
|
|
{
|
|
|
+ if (kcp == IntPtr.Zero)
|
|
|
+ {
|
|
|
+ throw new Exception($"kcp error, kcp point is zero");
|
|
|
+ }
|
|
|
ikcp_release(kcp);
|
|
|
}
|
|
|
|
|
|
public static int KcpSend(IntPtr kcp, byte[] buffer, int len)
|
|
|
{
|
|
|
+ if (kcp == IntPtr.Zero)
|
|
|
+ {
|
|
|
+ throw new Exception($"kcp error, kcp point is zero");
|
|
|
+ }
|
|
|
return ikcp_send(kcp, buffer, len);
|
|
|
}
|
|
|
|
|
|
- public static void KcpSetminrto(IntPtr ptr, int minrto)
|
|
|
+ public static void KcpSetminrto(IntPtr kcp, int minrto)
|
|
|
{
|
|
|
- ikcp_setminrto(ptr, minrto);
|
|
|
+ if (kcp == IntPtr.Zero)
|
|
|
+ {
|
|
|
+ throw new Exception($"kcp error, kcp point is zero");
|
|
|
+ }
|
|
|
+ ikcp_setminrto(kcp, minrto);
|
|
|
}
|
|
|
|
|
|
public static int KcpSetmtu(IntPtr kcp, int mtu)
|
|
|
{
|
|
|
+ if (kcp == IntPtr.Zero)
|
|
|
+ {
|
|
|
+ throw new Exception($"kcp error, kcp point is zero");
|
|
|
+ }
|
|
|
return ikcp_setmtu(kcp, mtu);
|
|
|
}
|
|
|
|
|
|
public static void KcpSetoutput(IntPtr kcp, kcp_output output)
|
|
|
{
|
|
|
+ if (kcp == IntPtr.Zero)
|
|
|
+ {
|
|
|
+ throw new Exception($"kcp error, kcp point is zero");
|
|
|
+ }
|
|
|
ikcp_setoutput(kcp, output);
|
|
|
}
|
|
|
|
|
|
public static void KcpUpdate(IntPtr kcp, uint current)
|
|
|
{
|
|
|
+ if (kcp == IntPtr.Zero)
|
|
|
+ {
|
|
|
+ throw new Exception($"kcp error, kcp point is zero");
|
|
|
+ }
|
|
|
ikcp_update(kcp, current);
|
|
|
}
|
|
|
|
|
|
public static int KcpWaitsnd(IntPtr kcp)
|
|
|
{
|
|
|
+ if (kcp == IntPtr.Zero)
|
|
|
+ {
|
|
|
+ throw new Exception($"kcp error, kcp point is zero");
|
|
|
+ }
|
|
|
return ikcp_waitsnd(kcp);
|
|
|
}
|
|
|
|
|
|
public static int KcpWndsize(IntPtr kcp, int sndwnd, int rcvwnd)
|
|
|
{
|
|
|
+ if (kcp == IntPtr.Zero)
|
|
|
+ {
|
|
|
+ throw new Exception($"kcp error, kcp point is zero");
|
|
|
+ }
|
|
|
return ikcp_wndsize(kcp, sndwnd, rcvwnd);
|
|
|
}
|
|
|
}
|