Пример #1
0
 //incoming connection constructor
 internal Player(EZMultiplayer netManager, IPEndPoint remoteEndPoint)
 {
     Statistics       = new NetStatistics();
     _packetPool      = netManager.NetPacketPool;
     _netManager      = netManager;
     _remoteEndPoint  = remoteEndPoint;
     _connectionState = ConnectionState.Incoming;
 }
Пример #2
0
        //"Connect to" constructor
        internal Player(EZMultiplayer netManager, IPEndPoint remoteEndPoint, byte connectNum, Message connectData) : this(netManager, remoteEndPoint)
        {
            Initialize();
            _connectId       = DateTime.UtcNow.Ticks;
            _connectionState = ConnectionState.InProgress;
            ConnectionNum    = connectNum;

            //Make initial packet
            _connectRequestPacket = NetConnectRequestPacket.Make(connectData, _connectId);
            _connectRequestPacket.ConnectionNumber = connectNum;

            //Send request
            _netManager.SendRaw(_connectRequestPacket, _remoteEndPoint);

            NetUtils.DebugWrite(ConsoleColor.Cyan, "[CC] ConnectId: {0}, ConnectNum: {1}", _connectId, connectNum);
        }
Пример #3
0
        private const int Port = 9050; // Порт сервера | Server port
        static void Main(string[] args)
        {
            Console.WriteLine("*** EZMutiplayer Server by unity3ddd.ru ***");

            EZMultiplayer.StartServer(Port, out _serverListener);

            while (!Console.KeyAvailable)
            {
                EZMultiplayer.ReceiveMessage();
                Thread.Sleep(15);
            }

            EZMultiplayer.StopServer();

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
Пример #4
0
 public void SendNetSerializable <T>(EZMultiplayer manager, T packet, DeliveryMethod options) where T : INetSerializable
 {
     _netDataWriter.Reset();
     WriteNetSerializable(_netDataWriter, packet);
     manager.SendToAll(_netDataWriter, options);
 }
Пример #5
0
 public void Send <T>(EZMultiplayer manager, T packet, DeliveryMethod options) where T : class, new()
 {
     _netDataWriter.Reset();
     Write(_netDataWriter, packet);
     manager.SendToAll(_netDataWriter, options);
 }