Exemple #1
0
 void MatchMakingCallbackHandler_JoinedGame(Core.GameStateInformation.ServerInstanceInformation serverInstanceInformation)
 {
     Utility.Global.InitializeGameplayClient(serverInstanceInformation.GameplayUri);
     gameContainer1.BringToFront();
     Utility.Global.GameplayCallbackHandler.GameStateUpdated += new ServerCommunication.GameplayCallbackHandler.GameStateUpdatedEventHandler(GameplayCallbackHandler_GameStateUpdated);
     Utility.Global.GamePlayClient.Join(Utility.Global.ServerKey);
 }
        protected virtual void OnJoinedGame(Core.GameStateInformation.ServerInstanceInformation serverInstanceInformation)
        {
            JoinedGameEventHandler temp = JoinedGame;

            if (temp != null)
            {
                temp(serverInstanceInformation);
            }
        }
 public void JoinedGameCallback(Core.GameStateInformation.ServerInstanceInformation serverInstanceInformation)
 {
     OnJoinedGame(serverInstanceInformation);
 }
        public LegendsOfKesmaiSurvival.Core.GameStateInformation.ServerInstanceInformation HostZombiesInstance(Zombies.ZombiesService zombiesService)
        {
            LegendsOfKesmaiSurvival.Core.GameStateInformation.ServerInstanceInformation serverInstanceInformation = new Core.GameStateInformation.ServerInstanceInformation();
            serverInstanceInformation.ServerId = Guid.NewGuid();

            //TODO:Currently this will get any free tcp port on the server.  This works but it needs to be a known range so that port forwarding can
            //be setup for that known range.
            string baseAddress = "net.tcp://" + System.Environment.MachineName + ":" + GetFreeTcpPort().ToString() + "/LegendsOfKesmaiSurvival/Zombies";

            NamedServiceHost host = new NamedServiceHost(zombiesService, new Uri(baseAddress));

            host.Name = serverInstanceInformation.ServerId.ToString();

            NetTcpBinding binding = new NetTcpBinding(SecurityMode.None, true);

            binding.MaxBufferSize               = int.MaxValue;
            binding.MaxReceivedMessageSize      = int.MaxValue;
            binding.ReaderQuotas.MaxArrayLength = int.MaxValue;
            binding.SendTimeout = TimeSpan.FromSeconds(10);

            ServiceEndpoint gamePlayEndpoint = host.AddServiceEndpoint(typeof(Zombies.IGameplay), binding, "/Gameplay");

            serverInstanceInformation.GameplayUri = new Uri(baseAddress + "/Gameplay");

            host.ServerInstanceInformation = serverInstanceInformation;
            host.Open();

            this.ServiceHosts.Add(host);

            return(serverInstanceInformation);
        }