Пример #1
0
/**
 * @return an exhaustive list of rooms matching the given qualifier
 */
std::vector<RoomRef>
RoomManager::GetRoomsWithQualifier(const RoomQualifier qualifier) const {
	if (qualifier == "")  {
		return GetRooms();
	}

	std::vector<RoomRef> roomlist;
	std::vector<RoomRef> rooms = GetRooms();
	for (auto it=rooms.begin(); it!=rooms.end(); ++it) {
		RoomRef room = *it;
		RoomID rid = room->GetRoomID();
		if (qualifier == UPCUtils::GetRoomQualifier(rid)) {
			roomlist.push_back(room);
		}
	}

	return roomlist;
};
Пример #2
0
/**
 * buids an exhaustive list from all possible sources of known clients
 */
std::vector<ClientRef>
RoomManager::GetAllClients() const {
	std::vector<ClientRef> clientSet;
	std::vector<RoomRef> rooms = GetRooms();
	for (auto it=rooms.begin(); it!=rooms.end(); ++it) {
		(*it)->GetOccupantList().AppendTo(clientSet);
		(*it)->GetObserverList().AppendTo(clientSet);
	}
	return clientSet;
}
Пример #3
0
/**
 * @return true if the given client is present in any imaginable local search
 */
bool
RoomManager::ClientIsKnown(const ClientID clientID) const {
	std::vector<RoomRef> rooms = GetRooms();
	for (auto it=rooms.begin(); it!=rooms.end(); ++it) {
		if (it->use_count() > 0) {
			const Room* r=it->get();
			if(r->GetOccupantList().Contains(clientID)) {
				return true;
			}
			if(r->GetObserverList().Contains(clientID)) {
				return true;
			}
		}
	}
	return false;
}
Пример #4
0
/*
 * Start proper action for command
 */
int ProcessCommand(char* command, char *content) {
   // printf("Entered command: %s\n", command);
    if(strcmp(command, "!connect")==0)
    {
       // printf("%s %s\n",command, content);
        return ConnectToServer(content);
    }
    else if(g_serverFd < 0)
    {
        printf("You must be connected!\n");
        return -1;
    }
    else if(strcmp(command, "!bye")==0)
    {
      //  printf("%s\n",command);
        return Disconnect();
    }
    else if(strcmp(command, "!rooms")==0)
    {
        //printf("%s\n",command);
        return GetRooms(command);
    }
    else if(strcmp(command, "!open")==0)
    {
       // printf("%s\n",command);
        return OpenRoom(command, content);
    }
    else if(strcmp(command, "!close")==0)
    {
        //printf("%s\n",command);
        return CloseRoom(content);
    }
    else if(strcmp(command, "!enter")==0)
    {
        //printf("%s\n",command);
        return EnterRoom(command, content);
    }
    else if(strcmp(command, "!leave")==0)
    {
        //printf("%s\n",command);
        return LeaveRoom();
    }
    else if(strcmp(command, "!files")==0)
    {
        //printf("%s\n",command);
        return CheckFiles();
    }
    else if(strcmp(command, "!push")==0)
    {
    //    printf("%s\n",command);
        return UploadFile(content);
    }
    else if(strcmp(command, "!pull")==0)
    {
      //  printf("%s\n",command);
        return DownloadFile(content);
    }
    else if(strcmp(command, "!rm")==0)
    {
        //printf("%s\n",command);
        return 1;
    }
    else if(strcmp(command, "!send")==0)
    {
        //printf("%s\n", command);
        return SendMessageToRoom(content);
    }
    else
        return -1;
}