コード例 #1
0
ファイル: Client.cs プロジェクト: AdrianN17/Juego_Hockey
        /// <summary>
        /// Inicializate Client
        /// max_channel default value is 0 and mean all channel, required
        /// timeout default value is 15, required
        /// </summary>
        /// <param name="ip_address">IP used for server </param>
        /// <param name="port">Port used for server</param>
        /// <param name="channel">Max channel used in server - Opcional</param>
        /// <param name="timeout">Max time to client's response time</param>
        public Client(string ip_address, ushort port, int channel, int timeout)
        {
            AllocCallback OnMemoryAllocate = (size) => {
                return(Marshal.AllocHGlobal(size));
            };

            FreeCallback OnMemoryFree = (memory) => {
                Marshal.FreeHGlobal(memory);
            };

            NoMemoryCallback OnNoMemory = () => {
                throw new OutOfMemoryException();
            };

            Callbacks callbacks = new Callbacks(OnMemoryAllocate, OnMemoryFree, OnNoMemory);

            if (ENet.Library.Initialize(callbacks))
            {
                Debug.LogWarning("ENet successfully initialized using a custom memory allocator");
            }

            client = new Host();

            Address address = new Address();

            address.Port = port;
            address.SetHost(ip_address);

            client.Create();
            client.EnableCompression();

            peer = client.Connect(address);
        }
コード例 #2
0
 public void ReadStart(AllocCallback allocCallback, ReadCallback readCallback, object allocState, object readState)
 {
     this.mAllocCallback      = allocCallback;
     this.mReadCallback       = readCallback;
     this.mReadCallbackState  = readState;
     this.mAllocCallbackState = allocState;
     UVIntrop.read_start(this, mOnAlloc, mOnRead);
 }
コード例 #3
0
ファイル: Server.cs プロジェクト: AdrianN17/ESharknet
        /// <summary>
        /// Inicializate server
        /// max_channel default value is 0 and mean all channel, required
        /// timeout default value is 15, required
        /// </summary>
        /// <param name="ip_address">IP used for server </param>
        /// <param name="port">Port used for server</param>
        /// <param name="max_clients">Max clients in server</param>
        /// <param name="max_channel">Max channel used in server - Opcional</param>
        /// <param name="timeout">Max time to client's response time</param>

        public Server(string ip_address, ushort port, int max_clients, int max_channel, int timeout)
        {
            AllocCallback OnMemoryAllocate = (size) => {
                return(Marshal.AllocHGlobal(size));
            };

            FreeCallback OnMemoryFree = (memory) => {
                Marshal.FreeHGlobal(memory);
            };

            NoMemoryCallback OnNoMemory = () => {
                throw new OutOfMemoryException();
            };

            Callbacks callbacks = new Callbacks(OnMemoryAllocate, OnMemoryFree, OnNoMemory);

            if (ENet.Library.Initialize(callbacks))
            {
                //Debug.LogWarning("ENet successfully initialized using a custom memory allocator");

                clients = new List <Peer>();
            }

            //init server

            Address address = new Address();

            address.SetHost(ip_address);
            address.Port = port;

            server = new Host();
            server.Create(address, max_clients, max_channel);
            server.EnableCompression();

            this.timeout = timeout;

            // Debug.Log("Create server IP : " + ip_address);
        }
コード例 #4
0
ファイル: ENet.cs プロジェクト: fadinglr/ENet-CSharp
 public Callbacks(AllocCallback allocCallback, FreeCallback freeCallback, NoMemoryCallback noMemoryCallback)
 {
     nativeCallbacks.malloc   = allocCallback;
     nativeCallbacks.free     = freeCallback;
     nativeCallbacks.noMemory = noMemoryCallback;
 }
コード例 #5
0
 public Callbacks(AllocCallback allocCallback, FreeCallback freeCallback, NoMemoryCallback noMemoryCallback)
 {
     nativeCallbacks.malloc    = Marshal.GetFunctionPointerForDelegate(allocCallback);
     nativeCallbacks.free      = Marshal.GetFunctionPointerForDelegate(freeCallback);
     nativeCallbacks.no_memory = Marshal.GetFunctionPointerForDelegate(noMemoryCallback);
 }
コード例 #6
0
 public void ReadStart(AllocCallback allocCallback, ReadCallback readCallback)
 {
     _allocCallback = allocCallback;
     _readCallback  = readCallback;
     LibuvNative.uv_read_start(this, AllocCb, ReadCb);
 }
コード例 #7
0
 [DllImport(LibraryName, EntryPoint = "ADL2_Main_Control_Create")] static extern Result _2MainControlCreate(AllocCallback mallocCallback, int a, ref IntPtr handle);
コード例 #8
0
 [DllImport(LibraryName, EntryPoint = "ADL_Main_Control_Create")] static extern Result MainControlCreate(AllocCallback mallocCallback, int a);