コード例 #1
0
ファイル: Form1.cs プロジェクト: S-W-dev/DiceGame
        private void setImage(string image)
        {
            var message = new ClientMessage.ImageMessage();

            message.image = image;
            ServerComponents.SendMessage(server, JsonConvert.SerializeObject(message));
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: S-W-dev/DiceGame
        private void setMoney(int money)
        {
            var message = new ClientMessage.MoneyMessage();

            message.money = money;
            ServerComponents.SendMessage(server, JsonConvert.SerializeObject(message));
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: S-W-dev/DiceGame
        public GameMain(bool join)
        {
            InitializeComponent();

            new DatabaseConn("", "").DownloadAndSet();

            TopMost         = true;
            FormBorderStyle = FormBorderStyle.FixedSingle;
            WindowState     = FormWindowState.Maximized;
            MaximizeBox     = false;

            conn = new Thread(new ServerComponents(this).connection);
            conn.Start();
            while (!connected)
            {
                Thread.Sleep(1);
            }
            if (join)
            {
                var message = new ClientMessage.JoinMessage();
                message.room_code = Prompt.ShowDialog("Enter the room code", "Prompt");
                var message1 = JsonConvert.SerializeObject(message);
                //Console.WriteLine(message1);
                ServerComponents.SendMessage(server, message1);
            }

            //Console.WriteLine("ORIGINAL SIZE: " + Width);
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: S-W-dev/DiceGame
        private void setName(string name)
        {
            var message = new ClientMessage.NameMessage();

            message.name = name;
            ServerComponents.SendMessage(server, JsonConvert.SerializeObject(message));
        }
コード例 #5
0
        private void UnregisterGameServer()
        {
            var peerId = ClientPeerWrapper.PeerId;
            var gameServerInformationRemover = ServerComponents.GetComponent <IGameServerInformationRemover>();

            gameServerInformationRemover?.Remove(peerId);
        }
コード例 #6
0
        public AuthorizationOperationHandler(Action <int> onAuthorizedArg, Action onNonAuthorized)
        {
            this.onAuthorizedArg = onAuthorizedArg;
            this.onNonAuthorized = onNonAuthorized;

            authorizationServiceApi = ServerComponents.GetComponent <IAuthorizationServiceAPI>().AssertNotNull();
        }
コード例 #7
0
        private static int GenerateId()
        {
            var idGenerator = ServerComponents.GetComponent <IIdGenerator>().AssertNotNull();
            var id          = idGenerator.GenerateId();

            return(id);
        }
コード例 #8
0
        public void ChangeUserProfileProperties()
        {
            var userProfileServiceAPI = ServerComponents.GetComponent <IUserProfileServiceAPI>().AssertNotNull();
            var parameters            = new ChangeUserProfilePropertiesRequestParameters(userId, clientPeerProvider.PeerId, serverType, ConnectionStatus.Connected);

            userProfileServiceAPI.ChangeUserProfileProperties(parameters);
        }
 private void AddComponents()
 {
     ServerComponents.AddComponent(new AuthorizationService());
     ServerComponents.AddComponent(new UserProfileService());
     ServerComponents.AddComponent(new GameServersInformationStorage());
     ServerComponents.AddComponent(new UpdateGameServerConnectionsInfo());
 }
        public CharacterValidationOperationHandler(int userId, Action <CharacterParameters?> onCharacterSelected)
        {
            this.userId = userId;
            this.onCharacterSelected = onCharacterSelected;

            characterServiceAPI = ServerComponents.GetComponent <ICharacterServiceAPI>().AssertNotNull();
        }
コード例 #11
0
        protected override void OnAwake()
        {
            base.OnAwake();

            peerContainer      = ServerComponents.GetComponent <IPeerContainer>().AssertNotNull();
            clientPeerProvider = Components.GetComponent <IClientPeerProvider>().AssertNotNull();
        }
コード例 #12
0
        private PlayerGameObject CreatePlayerGameObject(CharacterParameters character)
        {
            var characterSceneObjectCreator = ServerComponents.GetComponent <IPlayerGameObjectCreator>().AssertNotNull();
            var characterSceneObject        = characterSceneObjectCreator.Create(character);

            return(characterSceneObject);
        }
コード例 #13
0
        private void OnRegisterToUserProfileService(int id)
        {
            serverId = id;

            var serverIdToPeerIdConverter = ServerComponents.GetComponent <IServerIdToPeerIdConverter>().AssertNotNull();

            serverIdToPeerIdConverter.Add(serverId, ClientPeerWrapper.PeerId);
        }
コード例 #14
0
        public AuthenticationOperationHandler(Action <int> onAuthenticated)
        {
            this.onAuthenticated = onAuthenticated;

            databaseUserVerifier         = ServerComponents.GetComponent <IDatabaseUserVerifier>().AssertNotNull();
            databaseUserPasswordVerifier = ServerComponents.GetComponent <IDatabaseUserPasswordVerifier>().AssertNotNull();
            databaseUserIdProvider       = ServerComponents.GetComponent <IDatabaseUserIdProvider>().AssertNotNull();
            authorizationServiceApi      = ServerComponents.GetComponent <IAuthorizationServiceAPI>().AssertNotNull();
        }
コード例 #15
0
 private void AddComponents()
 {
     ServerComponents.AddComponent(new AuthorizationService());
     ServerComponents.AddComponent(new UserProfileService());
     ServerComponents.AddComponent(new DatabaseConnectionProvider());
     ServerComponents.AddComponent(new DatabaseUserVerifier());
     ServerComponents.AddComponent(new DatabaseUserPasswordVerifier());
     ServerComponents.AddComponent(new DatabaseUserIdProvider());
 }
コード例 #16
0
        public ChangeSceneOperationHandler(int userId, PlayerGameObject playerGameObject)
        {
            this.userId           = userId;
            this.playerGameObject = playerGameObject;

            sceneContainer = ServerComponents.GetComponent <ISceneContainer>().AssertNotNull();
            CharacterSpawnDetailsProvider = ServerComponents.GetComponent <ICharacterSpawnDetailsProvider>().AssertNotNull();
            characterServiceApi           = ServerComponents.GetComponent <ICharacterServiceAPI>().AssertNotNull();
        }
コード例 #17
0
        protected override void OnAwake()
        {
            base.OnAwake();

            var        fiber         = ServerComponents.GetComponent <IFiberStarter>().AssertNotNull();
            IScheduler fiberExecutor = fiber.GetFiberStarter();

            fiberExecutor.ScheduleOnInterval(Update, 0, 10);
        }
コード例 #18
0
        public UserProfileService()
        {
            var idGenerator = ServerComponents.GetComponent <IRandomNumberGenerator>().AssertNotNull();

            serverId = idGenerator.GenerateRandomNumber();

            peerContainer           = ServerComponents.GetComponent <IPeerContainer>().AssertNotNull();
            userIdToPeerIdConverter = ServerComponents.AddComponent(new UserIdToPeerIdConverter());
        }
コード例 #19
0
        public ChangeUserProfilePropertiesOperationHandler(IUsersContainer usersContainer, IUserProfilePropertiesChangesNotifier userProfilePropertiesChangesNotifier)
        {
            this.usersContainer = usersContainer;
            this.userProfilePropertiesChangesNotifier = userProfilePropertiesChangesNotifier;

            databaseUserProfileExistence         = ServerComponents.GetComponent <IDatabaseUserProfileExistence>().AssertNotNull();
            databaseUserProfilePropertiesUpdater = ServerComponents.GetComponent <IDatabaseUserProfilePropertiesUpdater>().AssertNotNull();
            databaseUserProfileCreator           = ServerComponents.GetComponent <IDatabaseUserProfileCreator>().AssertNotNull();
        }
コード例 #20
0
 private void AddComponents()
 {
     ServerComponents.AddComponent(new AuthorizationService());
     ServerComponents.AddComponent(new DatabaseConnectionProvider());
     ServerComponents.AddComponent(new DatabaseUserProfileCreator());
     ServerComponents.AddComponent(new DatabaseUserProfilePropertiesUpdater());
     ServerComponents.AddComponent(new DatabaseUserProfileExistence());
     ServerComponents.AddComponent(new ServerIdToPeerIdConverter());
     ServerComponents.AddComponent(new UserIdToServerIdConverter());
 }
コード例 #21
0
        public override void Startup()
        {
            base.Startup();

            AddCommonComponents();

            ServerComponents.AddComponent(new Server2Service());

            RunTestForServer2Service();
        }
コード例 #22
0
        private void RunTestForServer2Service()
        {
            var server2Service = ServerComponents.GetComponent <IServer2ServiceAPI>().AssertNotNull();

            server2Service.TestAction += OnTestEvent;

            var coroutinesExecutor = ServerComponents.GetComponent <ICoroutinesManager>().AssertNotNull();

            coroutinesExecutor.StartCoroutine(Server2Service());
        }
コード例 #23
0
ファイル: Form1.cs プロジェクト: S-W-dev/DiceGame
        private void submit_Click(object sender, EventArgs e)
        {
            setBet = currentBet;
            setC   = currentChoice;
            var message = new ClientMessage.BetMessage();

            message.bet    = setBet >= 100 ? setBet : 100;;
            message.choice = setC;
            ServerComponents.SendMessage(server, JsonConvert.SerializeObject(message));
        }
コード例 #24
0
        public GameSceneWrapper(Maps map, Vector2 sceneSize, Vector2 regionSize)
            : base(sceneSize, regionSize)
        {
            this.map = map;

            pythonScriptEngine            = ServerComponents.GetComponent <IPythonScriptEngine>().AssertNotNull();
            characterSpawnDetailsProvider = ServerComponents.GetComponent <ICharacterSpawnDetailsProvider>().AssertNotNull();

            scriptScope = pythonScriptEngine.GetScriptEngine().CreateScope();
            scriptScope.SetVariable("scene", this);
        }
コード例 #25
0
 private void AddComponents()
 {
     ServerComponents.AddComponent(new AuthorizationService());
     ServerComponents.AddComponent(new DatabaseConnectionProvider());
     ServerComponents.AddComponent(new DatabaseCharacterCreator());
     ServerComponents.AddComponent(new DatabaseCharacterRemover());
     ServerComponents.AddComponent(new DatabaseCharacterNameVerifier());
     ServerComponents.AddComponent(new DatabaseCharacterGetter());
     ServerComponents.AddComponent(new DatabaseCharactersGetter());
     ServerComponents.AddComponent(new DatabaseCharacterExistence());
     ServerComponents.AddComponent(new DatabaseCharacterMapUpdater());
 }
コード例 #26
0
 private void AddComponents()
 {
     ServerComponents.AddComponent(new AuthorizationService());
     ServerComponents.AddComponent(new CharacterService());
     ServerComponents.AddComponent(new UserProfileService());
     ServerComponents.AddComponent(new GameServerProviderService());
     ServerComponents.AddComponent(new PythonScriptEngine());
     ServerComponents.AddComponent(new PythonAssemblies());
     ServerComponents.AddComponent(new CharacterSpawnDetailsProvider());
     ServerComponents.AddComponent(new SceneContainer());
     ServerComponents.AddComponent(new PlayerGameObjectCreator());
 }
コード例 #27
0
        private void OnAuthenticated()
        {
            outboundServerPeerLogic.Dispose();
            outboundServerPeerLogic = OutboundServerPeer.CreateOutboundServerPeerLogic <ServerOperations, EmptyEventCode>();

            LogUtils.Log(MessageBuilder.Trace("Authenticated with GameServerProvider service."));

            RegisterGameServer();

            var coroutinesManager = ServerComponents.GetComponent <ICoroutinesManager>().AssertNotNull();

            updateGameServerConnectionsContinuously = coroutinesManager.StartCoroutine(UpdateGameServerConnectionsContinuously());
        }
コード例 #28
0
        private void ChangeUserToOfflineStatus()
        {
            if (isManuallyDisconnected || !isUserProfileChanged)
            {
                return;
            }

            var userProfileServiceAPI = ServerComponents.GetComponent <IUserProfileServiceAPI>().AssertNotNull();
            var parameters            = new ChangeUserProfilePropertiesRequestParameters(userId, ConnectionStatus.Disconnected);

            userProfileServiceAPI.ChangeUserProfileProperties(parameters);

            RemoveAuthorizationForUser();
        }
コード例 #29
0
        private IEnumerator <IYieldInstruction> Server2Service()
        {
            yield return(new WaitForSeconds(15));

            var server2Service     = ServerComponents.GetComponent <IServer2ServiceAPI>().AssertNotNull();
            var coroutinesExecutor = ServerComponents.GetComponent <ICoroutinesManager>().AssertNotNull();

            coroutinesExecutor.StartTask(async(y) =>
            {
                var parameters     = new Server1OperationRequestParameters(50);
                var responseParams = await server2Service.Server1Operation(y, parameters);
                LogUtils.Log(MessageBuilder.Trace($"Received number: {responseParams.Number}"));
            });
        }
コード例 #30
0
        public ComponentServerCached GetComponentServerCached(
            string name, IReadOnlyDictionary <string, RoleCached> roles)
        {
            if (ServerComponents.TryGetValue(name, out ComponentServerCached componentServerCached))
            {
                if (componentServerCached.Roles.Any(x =>
                                                    roles.Keys.Any(role => String.Equals(x.Value.Name, role, StringComparison.OrdinalIgnoreCase))))
                {
                    return(componentServerCached);
                }
            }

            return(null);
        }