//incoming connection constructor internal Player(EZMultiplayer netManager, IPEndPoint remoteEndPoint) { Statistics = new NetStatistics(); _packetPool = netManager.NetPacketPool; _netManager = netManager; _remoteEndPoint = remoteEndPoint; _connectionState = ConnectionState.Incoming; }
//"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); }
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(); }
public void SendNetSerializable <T>(EZMultiplayer manager, T packet, DeliveryMethod options) where T : INetSerializable { _netDataWriter.Reset(); WriteNetSerializable(_netDataWriter, packet); manager.SendToAll(_netDataWriter, options); }
public void Send <T>(EZMultiplayer manager, T packet, DeliveryMethod options) where T : class, new() { _netDataWriter.Reset(); Write(_netDataWriter, packet); manager.SendToAll(_netDataWriter, options); }