Пример #1
0
        public void ConnectAsync(string host, ushort port)
        {
            UAddress    address       = new UAddress(host, port);
            ENetAddress nativeAddress = address.Struct;

            this.PeerPtr = NativeMethods.ENetHostConnect(this.poller.Host, ref nativeAddress, 2, 0);
            if (this.PeerPtr == IntPtr.Zero)
            {
                throw new Exception($"host connect call failed, {host}:{port}");
            }
            this.poller.USocketManager.Add(this.PeerPtr, this);
        }
Пример #2
0
        public UPoller(string hostName, ushort port)
        {
            this.USocketManager = new USocketManager();

            UAddress    address       = new UAddress(hostName, port);
            ENetAddress nativeAddress = address.Struct;

            this.host = NativeMethods.ENetHostCreate(ref nativeAddress,
                                                     NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID, 0, 0, 0);

            if (this.host == IntPtr.Zero)
            {
                throw new Exception("Host creation call failed.");
            }

            NativeMethods.ENetHostCompressWithRangeCoder(this.host);
        }
Пример #3
0
        public UPoller(string hostName, ushort port)
        {
            try
            {
                this.USocketManager = new USocketManager();

                UAddress    address       = new UAddress(hostName, port);
                ENetAddress nativeAddress = address.Struct;
                this.host = NativeMethods.enet_host_create(ref nativeAddress,
                                                           NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID, 0, 0, 0);

                if (this.host == IntPtr.Zero)
                {
                    throw new Exception("Host creation call failed.");
                }

                NativeMethods.enet_host_compress_with_range_coder(this.host);
            }
            catch (Exception e)
            {
                throw new Exception($"UPoll construct error, address: {hostName}:{port}", e);
            }
        }
Пример #4
0
 internal static extern int ENetAddressGetHostIp(ref ENetAddress address, StringBuilder hostIp, uint ipLength);
Пример #5
0
 internal static extern int ENetAddressGetHost(ref ENetAddress address, StringBuilder hostName, uint nameLength);
Пример #6
0
 internal static extern int ENetAddressSetHost(ref ENetAddress address, string hostName);
Пример #7
0
		internal static extern IntPtr ENetHostConnect(IntPtr host, ref ENetAddress address, uint channelCount, uint data);
Пример #8
0
		internal static extern IntPtr ENetHostCreate(
				ref ENetAddress address, uint peerLimit, uint channelLimit, uint incomingBandwidth, uint outgoingBandwidth);
Пример #9
0
		internal static extern int ENetAddressGetHostIp(ref ENetAddress address, StringBuilder hostIp, uint ipLength);
Пример #10
0
 internal static extern int enet_address_set_host(ref ENetAddress address, string hostName);
Пример #11
0
		internal static extern int ENetAddressSetHost(ref ENetAddress address, string hostName);
Пример #12
0
 internal static extern IntPtr enet_host_connect(IntPtr host, ref ENetAddress address, uint channelCount, uint data);
Пример #13
0
 internal static extern int enet_address_get_host_ip(ref ENetAddress address, StringBuilder hostIp, uint ipLength);
Пример #14
0
 internal static extern int enet_address_get_host(ref ENetAddress address, StringBuilder hostName, uint nameLength);
Пример #15
0
 internal static extern IntPtr ENetHostCreate(
     ref ENetAddress address, uint peerLimit, uint channelLimit, uint incomingBandwidth, uint outgoingBandwidth);
Пример #16
0
 internal static extern IntPtr ENetHostConnect(IntPtr host, ref ENetAddress address, uint channelCount, uint data);
Пример #17
0
		internal static extern int ENetAddressGetHost(ref ENetAddress address, StringBuilder hostName, uint nameLength);