Пример #1
0
		public ActionResult HostStart(int id, string roomName) {
			var clnt = Controller.GetClientById(id);
			var room = Controller.GetChatRoom(roomName);
			var viewModel = new ChatViewModel();

			if (clnt == null || room == null) {
				viewModel.InvalidSession = true;
			}
			else {
				viewModel.AutoStart = true;
				viewModel.Online = true;
				viewModel.IsHost = true;
				viewModel.RoomName = room.Name;
				viewModel.Name = clnt.Name;
				viewModel.Email = clnt.Email;
				viewModel.Logo = clnt.Logo;

				//add the client to the room
				room.AddMember(clnt.Email, clnt.Name);
				
				// add waiting members to the room
				foreach (var waiter in clnt.GetRoomWaiters(room.Name)) {
					room.AddMember(waiter.Email, waiter.Name);
					clnt.WaitingMembers.Remove(waiter);
					// Notify waiter that he is able to join now
					Controller.SendMessage(clnt.Email, "Entrou na sala", room.Name, waiter.Email, EventType.RoomSpaceAvailable);
				}
			}

			return View("Start", viewModel);
		}
Пример #2
0
		public ActionResult Start(int id) {
			var clnt = Controller.GetClientById(id);
			var viewModel = new ChatViewModel();

			if (clnt == null) {
				viewModel.InvalidSession = true;
			}
			else {
				viewModel.AutoStart = false;
				viewModel.IsHost = false;
				viewModel.Online = clnt.IsOnline;
				viewModel.Logo = clnt.Logo;
			}

			return View(viewModel);
		}