public void SetupTimeout(ref ConcurrentDictionary <int, Connection> connections, ref IdMap ids) { refConnections = connections; refIds = ids; timeoutTimer = new Timer(4000); timeoutTimer.AutoReset = true; timeoutTimer.Elapsed += timeoutEvent; timeoutTimer.Start(); }
public Server(short port, int maxPlayers, int maxEntities, int defaultFraction) { this.defaultFraction = defaultFraction; connections = new ConcurrentDictionary <int, Connection>(); connectionIds = new IdMap(maxPlayers); worldMap = new WorldMap(maxEntities, "map.xml"); entc = worldMap.entityContainer; socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Bind(new IPEndPoint(IPAddress.Any, port)); socket.Listen(maxPlayers); }
uint entitiesCount; //for id stuff public Server(short port, int maxPlayers, int maxEntities, int defaultFraction) { entitiesCount = 4; connections = new ConcurrentDictionary <int, Connection>(); connectionIds = new IdMap(maxPlayers); socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Bind(new IPEndPoint(IPAddress.Any, port)); socket.Listen(maxPlayers); game = new Game(ref connections); /* Initialize Map */ Fraction fr1 = new Fraction(ref connections); Fraction fr2 = new Fraction(ref connections); Fraction fr3 = new Fraction(ref connections); Fraction fr4 = new Fraction(ref connections); fr1.AddEntity(new Entity(32, 32, 16, 0)); fr1.AddEntity(new Entity(64, 64, 32, 1)); fr2.AddEntity(new Entity(608, 32, 16, 2)); fr2.AddEntity(new Entity(576, 64, 32, 3)); fr3.AddEntity(new Entity(32, 448, 16, 4)); fr3.AddEntity(new Entity(64, 416, 32, 5)); fr4.AddEntity(new Entity(608, 448, 16, 6)); fr4.AddEntity(new Entity(576, 416, 32, 7)); game.AddFraction(fr1); game.AddFraction(fr2); game.AddFraction(fr3); game.AddFraction(fr4); Thread gameThread = new Thread(game.Run); gameThread.Start(); }
// public float xBuffer, yBuffer; // public short sizeBuffer; public EntityContainer(int maxEntities) { entities = new ConcurrentDictionary <int, Entity>(); entityIdMap = new IdMap(maxEntities); }
public void SetupConnection(ref ConcurrentDictionary <int, Connection> connections, ref IdMap ids) { refConnections = connections; refIds = ids; }