Exemple #1
0
 public void Dispose()
 {
     this._output   = null;
     this._writelog = null;
     NATIVE_TO_KCP.Remove(this._ikcpcb);
     KCPInterface.ikcp_release(this._ikcpcb);
 }
Exemple #2
0
        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);
        }
Exemple #3
0
        public int Send(byte[] buffer, int offset, int size)
        {
            int result = KCPInterface.ikcp_send(this._ikcpcb, ref buffer[offset], size);

            return(result);
        }
Exemple #4
0
        public int Recv(byte[] buffer, int size)
        {
            int result = KCPInterface.ikcp_recv(this._ikcpcb, ref buffer[0], size);

            return(result);
        }
Exemple #5
0
 public int PeekSize()
 {
     return(KCPInterface.ikcp_peeksize(this._ikcpcb));
 }
Exemple #6
0
 public void SetLogMask(int mask)
 {
     KCPInterface.ikcp_setlogmask(this._ikcpcb, mask);
 }
Exemple #7
0
 public void Clear()
 {
     KCPInterface.ikcp_clear(this._ikcpcb);
 }
Exemple #8
0
 public int WaitSnd()
 {
     return(KCPInterface.ikcp_waitsnd(this._ikcpcb));
 }
Exemple #9
0
 public int WndSize(int sndwnd, int rcvwnd)
 {
     return(KCPInterface.ikcp_wndsize(this._ikcpcb, sndwnd, rcvwnd));
 }
Exemple #10
0
 public int Interval(int interval)
 {
     return(KCPInterface.ikcp_interval(this._ikcpcb, interval));
 }
Exemple #11
0
 public int NoDelay(int nodelay, int interval, int resend, int nc)
 {
     return(KCPInterface.ikcp_nodelay(this._ikcpcb, nodelay, interval, resend, nc));
 }
Exemple #12
0
 public int SetMtu(int mtu)
 {
     return(KCPInterface.ikcp_setmtu(this._ikcpcb, mtu));
 }
Exemple #13
0
 public uint Check(uint current)
 {
     return(KCPInterface.ikcp_check(this._ikcpcb, current));
 }
Exemple #14
0
 public void Update(uint current)
 {
     KCPInterface.ikcp_update(this._ikcpcb, current);
 }
Exemple #15
0
        public int Input(byte[] data, int offset, int size)
        {
            int result = KCPInterface.ikcp_input(this._ikcpcb, ref data[offset], size);

            return(result);
        }