public void Dispose() { this._output = null; this._writelog = null; NATIVE_TO_KCP.Remove(this._ikcpcb); KCPInterface.ikcp_release(this._ikcpcb); }
public KCPNative(uint conv, uint user, KCP.OutputHandler output, KCP.LoggerHandler writelog) { int size = Marshal.SizeOf(user); IntPtr intPtr = Marshal.AllocHGlobal(size); Marshal.StructureToPtr(user, intPtr, false); this._ikcpcb = KCPInterface.ikcp_create(conv, intPtr); Marshal.FreeHGlobal(intPtr); NATIVE_TO_KCP[this._ikcpcb] = this; this._output = output; this._writelog = writelog; IntPtr outputPtr = Marshal.GetFunctionPointerForDelegate(OUTPUT_DELEGATE); KCPInterface.ikcp_setoutput(this._ikcpcb, outputPtr); IntPtr logPtr = Marshal.GetFunctionPointerForDelegate(LOG_DELEGATE); KCPInterface.ikcp_setlog(this._ikcpcb, logPtr); }
public int Send(byte[] buffer, int offset, int size) { int result = KCPInterface.ikcp_send(this._ikcpcb, ref buffer[offset], size); return(result); }
public int Recv(byte[] buffer, int size) { int result = KCPInterface.ikcp_recv(this._ikcpcb, ref buffer[0], size); return(result); }
public int PeekSize() { return(KCPInterface.ikcp_peeksize(this._ikcpcb)); }
public void SetLogMask(int mask) { KCPInterface.ikcp_setlogmask(this._ikcpcb, mask); }
public void Clear() { KCPInterface.ikcp_clear(this._ikcpcb); }
public int WaitSnd() { return(KCPInterface.ikcp_waitsnd(this._ikcpcb)); }
public int WndSize(int sndwnd, int rcvwnd) { return(KCPInterface.ikcp_wndsize(this._ikcpcb, sndwnd, rcvwnd)); }
public int Interval(int interval) { return(KCPInterface.ikcp_interval(this._ikcpcb, interval)); }
public int NoDelay(int nodelay, int interval, int resend, int nc) { return(KCPInterface.ikcp_nodelay(this._ikcpcb, nodelay, interval, resend, nc)); }
public int SetMtu(int mtu) { return(KCPInterface.ikcp_setmtu(this._ikcpcb, mtu)); }
public uint Check(uint current) { return(KCPInterface.ikcp_check(this._ikcpcb, current)); }
public void Update(uint current) { KCPInterface.ikcp_update(this._ikcpcb, current); }
public int Input(byte[] data, int offset, int size) { int result = KCPInterface.ikcp_input(this._ikcpcb, ref data[offset], size); return(result); }