public HandshakeComponent(MatchScreen screen, ServerWorld world, AOSServer server) { this.screen = screen; this.server = server; this.world = world; handshakes = new Dictionary <NetConnection, Handshake>(); }
public NetPlayerComponent(AOSServer server) : base(server) { netPlayers = new BiDictionary <NetConnection, NetworkPlayer>(); stashedClientInfo = new Dictionary <NetConnection, ClientInfo>(); channel = server.GetChannel(AOSChannelType.NetInterface); snapshotComponent = server.GetComponent <SnapshotNetComponent>(); channel.AddRemoteEvent("Server_ClientInfo", R_ClientInfo); }
public Handshake(HandshakeComponent component, NetConnection with) { this.component = component; With = with; server = component.GetServer(); world = component.GetWorld(); TerrainChanges = new HashSet <BlockChange>(); Start(); }
public ServerGame() : base(120) { screens = new Dictionary <string, GameScreen>(); ConfigSection serverSection = Program.Config.GetSection("Server"); int maxPlayers = 32; if (serverSection == null) { DashCMD.WriteError("[server.cfg - ServerGame] Section 'Server' is missing!"); } else { maxPlayers = serverSection.GetInteger("max-players") ?? 32; ConfigSection socketSection = serverSection.GetSection("Socket"); if (socketSection == null) { DashCMD.WriteError("[server.cfg - ServerGame] Section 'Socket' is missing!"); } else { string ip = socketSection.GetString("host-ip") ?? "127.0.0.1"; int port = socketSection.GetInteger("host-port") ?? 12123; if (!NetHelper.TryParseIP(ip, out HostIP)) { DashCMD.WriteError("[server.cfg - ServerGame] Socket.host-ip is invalid!"); } } } if (!AOSServer.Initialize(maxPlayers, new IPEndPoint(HostIP, HostPort))) { DashCMD.WriteError("Failed to initialize server!"); DashCMD.StopListening(); return; } server = AOSServer.Instance; InitializeDebugging(); AddScreen(new MatchScreen(this)); SwitchScreen("Match"); }
public SnapshotNetComponent(AOSServer server) : base(server) { snapshotSystem = new SnapshotSystem(server); charSnapshotSystem = new CharacterSnapshotSystem(this, snapshotSystem); ConnectionStates = new Dictionary <NetConnection, NetConnectionSnapshotState>(); objectComponent = server.GetComponent <ObjectNetComponent>(); objectComponent.OnCreatableInstantiated += ObjectComponent_OnCreatableInstantiated; objectComponent.OnCreatableDestroyed += ObjectComponent_OnCreatableDestroyed; DashCMD.AddScreen(new DashCMDScreen("snapshot", "Displays information about the snapshot system.", true, (screen) => { try { foreach (KeyValuePair <NetConnection, NetConnectionSnapshotState> pair in ConnectionStates) { SnapshotStats stats = pair.Value.Stats; screen.WriteLine("[{0}]:", pair.Key); screen.WriteLine("Snapshot Round-Trip Time: {0}", pair.Value.RoundTripTime); screen.WriteLine("PacketHeader: {0} bytes", stats.PacketHeader); screen.WriteLine("Acks: {0} bytes", stats.Acks); screen.WriteLine("PlayerData: {0} bytes", stats.PlayerData); screen.WriteLine("TerrainData: {0} bytes", stats.TerrainData); screen.WriteLine("Total: {0} bytes", stats.Total); screen.WriteLine(""); } } catch (Exception) { } }) { SleepTime = 30 }); DashCMD.SetCVar("sv_tickrate", DEFAULT_TICKRATE); DashCMD.SetCVar("sv_await_cl_snap", false); DashCMD.SetCVar <ushort>("ag_max_cl_tickrate", 100); DashCMD.SetCVar("ag_cl_force_await_snap", false); //DashCMD.SetCVar("sv_tickrate", 25); //DashCMD.SetCVar("sv_await_cl_snap", true); //DashCMD.SetCVar<ushort>("ag_max_cl_tickrate", 30); //DashCMD.SetCVar("ag_cl_force_await_snap", true); }
public AOSServer(NetServerConfig config) : base(config) { if (Instance != null) { throw new Exception("An AOSServer already exists!"); } Instance = this; components = new Dictionary <Type, NetComponent>(); packetHooks = new List <NetPacketHookCallback>(); // Create each game channel foreach (object o in Enum.GetValues(typeof(AOSChannelType))) { CreateChannel((ushort)o); } // Add network components AddComponent(new ObjectNetComponent(this)); AddComponent(new SnapshotNetComponent(this)); AddComponent(new NetPlayerComponent(this)); foreach (NetComponent component in components.Values) { component.Initialize(); } // Hook into base events OnUserConnected += AOSServer_OnUserConnected; OnUserDisconnected += AOSServer_OnUserDisconnected; // Add some diag commands DashCMD.AddCommand("list", "Shows a list of all connected players.", (args) => { DashCMD.WriteImportant("Players ({0}):", Connections.Count); foreach (NetConnection conn in Connections.Values) { DashCMD.WriteStandard(" {0}", conn); } DashCMD.WriteStandard(""); }); }
/// <summary> /// Creates and attempts to start an AOSServer with /// the game specific config. /// </summary> public static bool Initialize(int maxConnections, IPEndPoint endPoint, IPEndPoint receiveEndPoint = null) { GlobalNetwork.SetupLogging(); NetServerConfig config = new NetServerConfig(); config.MaxConnections = maxConnections; config.DontApplyPingControl = true; AOSServer server = new AOSServer(config); bool success = server.Start(endPoint); if (success) { GlobalNetwork.IsServer = true; GlobalNetwork.IsConnected = true; } return(success); }
public ServerWorld() { players = new ConcurrentDictionary <NetConnection, ServerMPPlayer>(); physEntities = new Dictionary <ushort, GameObject>(); server = AOSServer.Instance; snapshotComponent = server.GetComponent <SnapshotNetComponent>(); objectComponent = server.GetComponent <ObjectNetComponent>(); channel = server.GetChannel(AOSChannelType.World); channel.AddRemoteEvent("Server_SetBlock", R_SetBlock); channel.AddRemoteEvent("Server_ThrowGrenade", R_ThrowGrenade); channel.AddRemoteEvent("Server_ShootMelon", R_ShootMelon); objectComponent.OnCreatableInstantiated += ObjectComponent_OnCreatableInstantiated; objectComponent.OnCreatableDestroyed += ObjectComponent_OnCreatableDestroyed; snapshotComponent.OnWorldSnapshotOutbound += Server_OnWorldSnapshotOutbound; InitializeCMD(); ConfigSection gameSection = Program.Config.GetSection("Game"); if (gameSection == null) { DashCMD.WriteError("[server.cfg - ServerWorld] Section 'Game' is missing!"); } else { string worldFile = gameSection.GetString("world-file"); if (!string.IsNullOrWhiteSpace(worldFile)) { LoadFromFile(worldFile); } else { DashCMD.WriteError("[server.cfg - ServerWorld] Game.world-file is missing!"); } } }
public ObjectNetComponent(AOSServer server) : base(server) { netObjects = new NetCreatableCollection(); instPackets = new Dictionary <ushort, NetOutboundPacket>(); }
public NetComponent(AOSServer server) { this.server = server; }