示例#1
0
        public async Task <IActionResult> PutClientRoom(int id, ClientRoom clientRoom)
        {
            if (id != clientRoom.ClientRoomID)
            {
                return(BadRequest());
            }


            _context.Entry(clientRoom).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClientRoomExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#2
0
        private int Correct(ClientRoom clientRoom)
        {
            var t = _context.ClientRoom.ToList();

            foreach (var tt in t)
            {
                if (tt.RoomID == clientRoom.RoomID && tt.ClientID == clientRoom.ClientID && tt.Check_inDate == clientRoom.Check_inDate && tt.Check_outDate == clientRoom.Check_outDate)
                {
                    return(1); //BadRequest("you're not allowed to create duplicate records");
                }
                if ((tt.RoomID == clientRoom.RoomID) && ((tt.Check_inDate >= clientRoom.Check_inDate && tt.Check_inDate <= clientRoom.Check_outDate) || (tt.Check_outDate >= clientRoom.Check_inDate && tt.Check_outDate <= clientRoom.Check_outDate)))
                {
                    return(2);// BadRequest("you're not allowed to create record for room which in use during this dates");
                }
            }
            if (clientRoom.Check_outDate <= clientRoom.Check_inDate)
            {
                return(3); //BadRequest("Check out date can't be same or samller then check in date");
            }
            if (!ClientsExists(clientRoom.ClientID))
            {
                return(4);// BadRequest("Client doesnt exist");
            }
            if (!RoomsExists(clientRoom.RoomID))
            {
                return(5);// BadRequest("Room doesnt exist");
            }
            return(0);
        }
示例#3
0
        private static void AddManyToManyWithFks()
        {
            _context = new HotelContext();
            var sb = new ClientRoom {
                ClientId = 1, RoomId = 1, DateStarded = new DateTime(2017, 05, 05), DateEnded = new DateTime(2017, 06, 12)
            };

            _context.ClientRooms.Add(sb);
            _context.SaveChanges();
        }
示例#4
0
 public void AddRoom(ClientRoom room)
 {
     Monitor.Enter(this);
     try
     {
         _roomList.Add(room);
     }
     finally
     {
         Monitor.Exit(this);
     }
 }
示例#5
0
        public WaitRoom(Client client)
        {
            this.client = client;
            ClientRoom cr = new ClientRoom();

            InitializeComponent();
            waitr = this;

            DispatcherTimer dispatcherTimer = new DispatcherTimer();

            dispatcherTimer.Tick    += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            dispatcherTimer.Start();
        }
示例#6
0
    private void DoStart()
    {
        DefaultGo.SetStage(GameRunningStage.BattleClient, false);

        _logger.InfoFormat("DoStart");
        gameObject.AddComponent <VersionDisplay>();
        IUserCmdGenerator userCmd;

        if (!IsRobot)
        {
            userCmd = new UnityUserCmdGenerator();
        }
        else
        {
            userCmd = new RobotUserCmdGenerator(new DummyRobotUserCmdProvider());
        }

        gameObject.AddComponent <Luminosity.IO.InputManager>();
        var consoleCommands = gameObject.AddComponent <DeveloperConsoleCommands>();
        var pool            = gameObject.AddComponent <UnityGameObjectPool>();
        ClientContextInitilizer intializer =
            new ClientContextInitilizer(userCmd, pool, this, _assetLoader, TestUtility.TestToken);


        _clientRoom             = new ClientRoom(intializer);
        _clientRoom.AddCommand += (consoleCommands.RegisterFreeCommand);

        consoleCommands._handler        = _clientRoom;
        consoleCommands._EcsDebugHelper = _clientRoom;
        consoleCommands._contexts       = _clientRoom.Contexts;
        consoleCommands.RegisterOpenCallback(BlockAllInput);
        if (!SharedConfig.IsOffline)
        {
            _loginClient = new LoginClient(SingletonManager.Get <ClientFileSystemConfigManager>().BootConfig.BattleServer.IP,
                                           new NetworkPortInfo(SingletonManager.Get <ClientFileSystemConfigManager>().BootConfig.BattleServer.TcpPort,
                                                               SingletonManager.Get <ClientFileSystemConfigManager>().BootConfig.BattleServer.UdpPort),
                                           _clientRoom);
        }
        _isInit = true;
        GlobalProperties.Instance.Properties["serverIp"]    = SingletonManager.Get <ClientFileSystemConfigManager>().BootConfig.BattleServer.IP;
        GlobalProperties.Instance.Properties["tcpPort"]     = SingletonManager.Get <ClientFileSystemConfigManager>().BootConfig.BattleServer.TcpPort;
        GlobalProperties.Instance.Properties["token"]       = TestUtility.TestToken;
        GlobalProperties.Instance.Properties["CS"]          = "Client";
        GlobalProperties.Instance.Properties["mutilThread"] = SharedConfig.MutilThread;
        GlobalProperties.Instance.Properties["version"]     = Version.Instance.LocalVersion;
        GlobalProperties.Instance.Properties["asset"]       = Version.Instance.LocalAsset;
        GlobalProperties.Instance.Properties["isOffline"]   = SharedConfig.IsOffline;
    }
        protected override void OnRun(MessageContent content, CommandArgs args)
        {
            if (content.Room == null)
            {
                throw new ArgumentNullException("content.Room");
            }

            using (var client = ClientModel.Get())
            {
                Room room = null;
                if (content.Room.Type == RoomType.Chat)
                {
                    var textRoom = new ClientRoom(content.Room);
                    client.Chat.AddRoom(textRoom);
                    room = textRoom;
                }

                if (content.Room.Type == RoomType.Voice)
                {
                    var voiceRoom = new ClientVoiceRoom(content.Room);
                    client.Chat.AddVoiceRoom(voiceRoom);
                    room = voiceRoom;
                }

                if (room == null)
                {
                    throw new ModelException(ErrorCode.UnknownRoomType);
                }

                AddUsers(client.Chat, content.Users);

                // Create P2P connections to users if need
                if (content.Room.ConnectTo != null)
                {
                    foreach (var nick in content.Room.ConnectTo)
                    {
                        ClientModel.Api.Perform(new ClientConnectToPeerAction(nick));
                    }
                }

                room.Enable();
            }

            ClientModel.Notifier.RoomOpened(new RoomOpenedEventArgs(content.Room.Name));
        }
示例#8
0
        public void SubscribeToRoom(RoomType roomType, Socket socket)
        {
            RoomSubscriber roomSubscriber = new RoomSubscriber(this.messageHub);
            SocketModel    socketModel    = generateSocketModel(roomType, socket);

            roomSubscriber.Subscribe(roomType, socketModel);
            var modelId = socketRepository.GetSocketId(socketModel.Port, socketModel.IpAddress);

            if (modelId == 0)
            {
                socketModel = socketRepository.Insert(socketModel);
            }
            var clientRoom = new ClientRoom();

            clientRoom.Room     = (int)roomType;
            clientRoom.SocketId = modelId;
            clientRoomRepository.Insert(clientRoom);
        }
示例#9
0
        public void UnsubscribeRoom(RoomType roomType, Socket socket)
        {
            SocketModel socketModel = generateSocketModel(roomType, socket);
            var         id          = socketRepository.GetSocketId(socketModel.Port, socketModel.IpAddress);

            if (id != 0)
            {
                var clientRoom = new ClientRoom();
                clientRoom.Room     = (int)roomType;
                clientRoom.SocketId = id;
                var clientroomid = clientRoomRepository.GetClientRoomId(clientRoom);
                if (clientroomid != 0)
                {
                    clientRoomRepository.Delete(clientroomid);
                    clientRoomRepository.Save();
                }
            }
        }
示例#10
0
        void EngineJoinRoom(object sender, JoinRoomEventArgs e)
        {
            var joinRoomEvent = e.Event;

            if (RoomManager == null)
            {
                return;
            }

            var room = RoomManager.FindById(joinRoomEvent.RoomId);

            if (room == null)
            {
                room = new ClientRoom(joinRoomEvent.RoomId)
                {
                    Name = joinRoomEvent.RoomName
                };
                RoomManager.AddRoom(room);
            }

            room.Description = joinRoomEvent.RoomDescription;
            room.IsProtected = joinRoomEvent.Protected;
            room.Capacity    = joinRoomEvent.Capacity;
            room.IsHidden    = joinRoomEvent.Hidden;

            //foreach (SharedObject roomVariable in joinRoomEvent.RoomVariables)
            //{
            //    room.AddRoomVariable(roomVariable.Name, roomVariable);
            //}

            foreach (var userListEntry in joinRoomEvent.Users)
            {
                var u = UserManager.AddUser(UserListEntryToUser(userListEntry));
                room.AddUser(u);
            }

            if (UserManager != null)
            {
                UserManager.Me.Room = room;
            }
        }
示例#11
0
        public async Task <ActionResult <ClientRoom> > PostClientRoom(ClientRoom clientRoom)
        {
            switch (Correct(clientRoom))
            {
            case 1:
                return(BadRequest("you're not allowed to create duplicate records"));

            case 2:
                return(BadRequest("you're not allowed to create record for room which in use during this dates"));

            case 3:
                return(BadRequest("Check out date can't be same or samller then check in date"));

            case 4:
                return(BadRequest("Client doesnt exist"));

            case 5:
                return(BadRequest("Room doesnt exist"));
            }
            _context.ClientRoom.Add(clientRoom);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetClientRoom", new { id = clientRoom.ClientRoomID }, clientRoom));
        }
示例#12
0
 private void OnJoinedRoom(ClientRoom <ITAlertPlayer> room)
 {
     QuickMatchSuccessEvent?.Invoke();
 }
示例#13
0
 private void OnJoinGameSuccess(ClientRoom <ITAlertPlayer> clientRoom)
 {
     JoinGameSuccessEvent?.Invoke();
 }
示例#14
0
 public ClientReceiver(ClientRoom cr)
 {
     this.cr = cr;
 }
示例#15
0
 private void OnJoinedRoom(ClientRoom <ITAlertPlayer> room)
 {
     JoinedRoomEvent?.Invoke();
 }
示例#16
0
 public void AddClientRoom(ClientRoom clientRoom)
 {
     _context.Entry(clientRoom).State = EntityState.Added;
 }