示例#1
0
        public Server(GlobalHost globalHost, ActionSyncronizer sync, int serverSpawnDensity)
        {
            Host = globalHost.NewHost(Server.hostName, Game.Convert(AssignProcessor),
                                      BasicInfo.GenerateHandshake(NodeRole.SERVER), Aggregator.shortInactivityWait);

            base.serverHost = Address;

            this.serverSpawnDensity = serverSpawnDensity;
        }
示例#2
0
        public Aggregator(IPAddress myIP, Func <WorldInitializer, World> generateWorld)
        {
            sync     = new ActionSyncronizer();
            host     = new GlobalHost(sync.GetProxy(), myIP, sync.TimedAction);
            myClient = new Client(host, this, generateWorld);

            ILog statsLog = MasterLog.GetFileLog("stats.log");

            sync.TimedAction.AddAction(() => Log.EntryNormal(statsLog, this.GetStats()));
        }
示例#3
0
        public PlayerValidator(PlayerInfo info, GlobalHost globalHost, OverlayEndpoint serverHost, PlayerData playerData)
        {
            this.info       = info;
            this.serverHost = serverHost;
            this.playerData = playerData;

            Host = globalHost.NewHost(info.validatorHost.hostname, Game.Convert(AssignProcessor),
                                      BasicInfo.GenerateHandshake(NodeRole.PLAYER_VALIDATOR, info), Aggregator.longInactivityWait);

            SetConnectionHook(ProcessNewConnection);
        }
示例#4
0
        public PlayerAgent(PlayerInfo info, GlobalHost globalHost, OverlayEndpoint serverHost, Client myClient)
        {
            this.Info       = info;
            this.serverHost = serverHost;
            this.myClient   = myClient;
            this.Data       = null;

            Host = globalHost.NewHost(info.playerHost.hostname, Game.Convert(AssignProcessor),
                                      BasicInfo.GenerateHandshake(NodeRole.PLAYER_AGENT, info), Aggregator.longInactivityWait);

            ConnectAsync(info.validatorHost, (di) => ProcessPlayerValidatorDisconnect(di, info));

            Log.Console("Player Agent {0}", info.GetShortInfo());
        }
示例#5
0
        //public Action<World> onNewWorldHook = (a) => { };
        //public Action<World> onDeleteWorldHook = (a) => { };

        //public Action<PlayerInfo> onNewMyPlayerHook = (a) => { };

        //public Action<World, PlayerInfo, Point, ActionValidity> onMoveHook = (a, b, c, d) => { };
        //public Action<World, PlayerInfo, bool> onPlayerLeaveHook = (a, b, c) => { };

        //Func<WorldInitializer, World> generateWorld;

        public Client(GlobalHost globalHost, Aggregator all, Func <WorldInitializer, World> generateWorld)
        {
            this.all = all;
            //this.generateWorld = generateWorld;

            Host = globalHost.NewHost(Client.hostName, Game.Convert(AssignProcessor),
                                      BasicInfo.GenerateHandshake(NodeRole.CLIENT), Aggregator.longInactivityWait);

            SetConnectionHook(ProcessNewConnection);

            Action <WorldInfo> subscribe = wi => MessageWorld(wi, MessageType.SUBSCRIBE);

            Action <WorldInfo> unsubscribe = wi => MessageWorld(wi, MessageType.UNSUBSCRIBE);

            TrackedWorldData data = new TrackedWorldData()
            {
                generateWorld = generateWorld, recordWorldInfo = null, subscribe = subscribe, unsubscribe = unsubscribe
            };

            worlds = new WorldDatabase(data);

            connectedPlayers = new PlayerDatabase(p => worlds.At(p).Track(), p => worlds.At(p).Untrack(),
                                                  inf => worlds.At(inf.position).SetWorldInfo(inf));
        }