コード例 #1
0
ファイル: channel.cpp プロジェクト: renokun/Aspen
void Channel::AddListener(Player* subscriber,BOOL quiet)
{
    if (!subscriber->HasAccess(_access))
        {
            if (!quiet)
                {
                    subscriber->Message(MSG_ERROR,"You don't have seficient permissions to access this channel.");
                }
            return;
        }

    if (HasListener(subscriber))
        {
            if (!quiet)
                {
                    subscriber->Message(MSG_ERROR,"You are already subscribed to that channel.");
                }
            return;
        }

    _listeners->push_back(subscriber);
    if (!quiet)
        {
            subscriber->Message(MSG_INFO,"Tuned in.");
        }
}
コード例 #2
0
ファイル: channel.cpp プロジェクト: renokun/Aspen
void Channel::RemoveListener(Player* subscriber,BOOL quiet)
{
    if (HasListener(subscriber))
        {
            _listeners->remove(subscriber);
            if (!quiet)
                {
                    subscriber->Message(MSG_INFO,"Tuned out.");
                }
            return;
        }

    if (!quiet)
        {
            subscriber->Message(MSG_INFO,"You are not tuned into that channel.");
        }
}
コード例 #3
0
void EventManager::AddListener(EventListener* listener) {
    if(mListenersLocked) {
        Logger::Get().Debug("EventManager: Cannot add listener. List locked. Queued listener for adding.");
        mListenerAddQueue.push_back(listener);
        return;
    }

    if(!HasListener(listener)) {
        if(listener == nullptr) {
            Logger::Get().Error("EventManager: Could not add listener. It is NULL.");
        } else {
            mListeners.push_back(listener);
            UpdatePriorities();
        }
    } else {
        Logger::Get().Error("EventManager: Could not add listener - already registered.");
    }
}
コード例 #4
0
ファイル: channel.cpp プロジェクト: renokun/Aspen
void Channel::Broadcast(Player* caller,const std::string &message,BOOL access)
{
    std::list <Player*>::iterator it, itEnd;
    std::string paternized;

    if (access)
        {
            if (!caller->HasAccess(_access))
                {
                    caller->Message(MSG_ERROR,"You don't have the access needed to be able to broadcast to this channel.");
                    return;
                }
        }

    if (message=="")
        {
            caller->Message(MSG_ERROR,"You must provide a message.");
            return;
        }
    if (BitIsSet(caller->GetPflag(), PF_SILENCE))
        {
            caller->Message(MSG_ERROR, "You can not broadcast to channels while you are silenced.");
            return;
        }
    if (!HasListener(caller))
        {
            if (!CanBroadcastWithoutListening(caller))
                {
                    caller->Message(MSG_ERROR, "You must be tuned into that channel before you can broadcast on it.");
                    return;
                }
        }

    paternized=_Patternize(message,caller);

    itEnd = _listeners->end();
    for (it = _listeners->begin(); it != itEnd; ++it)
        {
            (*it)->Message(MSG_CHANNEL,paternized);
        }

    _AddHistoryEntry(paternized);
}