Exemple #1
0
CEVENT(Channel, SubscribeChannels)
{
    World* world = World::GetPtr();

    std::list <std::string> *names=new std::list<std::string>();
    std::list <std::string>::iterator it, itEnd;
    Channel* chan=NULL;
    Player* mobile=(Player*)caller;
    mobile->events.AddCallback("OptionChanged", std::bind(&Channel::OptionChanged, std::placeholders::_1, std::placeholders::_2));
    world->GetChannelNames(names);

    itEnd = names->end();
    for (it = names->begin(); it != itEnd; ++it)
        {
            if (GetOptionValue((*it), mobile).GetInt() == 1)
                {
                    chan=world->FindChannel((*it));
                    if (chan)
                        {
                            chan->AddListener(mobile,true);
                        }
                }
        }
    delete names;
}
Exemple #2
0
CEVENT(Channel, UnsubscribeChannels)
{
    World* world = World::GetPtr();

    std::list <std::string>* names=new std::list <std::string>();
    std::list <std::string>::iterator it, itEnd;
    Channel* chan=NULL;
    Player* mobile=(Player*)caller;
    world->GetChannelNames(names);

    itEnd=names->end();
    for (it = names->begin(); it != itEnd; ++it)
        {
            chan=world->FindChannel((*it));
            if (chan)
                {
                    chan->RemoveListener(mobile,true);
                }
        }
    delete names;
}