void EventManager::subscribeEvent(long eventId, EventChannel* ioChannel)
{
	boost::mutex::scoped_lock scoped_lock(mExecutionListMutex);

	EventChannelMaskMap::iterator it = mExecutionList.find (eventId);
	long mask = 0;
	if ( it != mExecutionList.end() )
	{	
		mask = (*it).second;
	}	
	int id = getChannelId(ioChannel);
	mExecutionList[eventId] = mask | (1 << id);
}
void		Packet_v1_Channel::Print_v1_Channel(std::string const &componentName, Manager const * manager) const
{
  Print_v1(componentName, manager);
  std::cout << "[CHANNELID: " << getChannelId() << " {" << PROTOV1_CHANNEL_CHANNELID_SIZE << "}]"
	    << "[CLIENTSESSIONID: " << getClientSessionId() << "{" << PROTOV1_CHANNEL_CLIENTSESSIONID_SIZE << "}]"
	    << std::endl;
  int id = getRequestId();
  if (id == CHANNEL_JOIN || id == CHANNEL_JOIN_OK || id == CHANNEL_JOIN_NOK_ALREADYINCHAN ||
      id == CHANNEL_JOINED || id == CHANNEL_LEAVE_OK || id == CHANNEL_LEAVED)
    std::cout << "# ChannelName: '" << getChannelName() << "'" << std::endl;
  if (id == CHANNEL_JOINED || id == CHANNEL_LEAVED)
    std::cout << "# Login: '******'" << std::endl;
  if (id == CHANNEL_MESSAGE || id == CHANNEL_MESSAGE_RECV)
    std::cout << "# Message: '" << getMessage() << "'" << std::endl;    
}
void EventManager::unregisterEventLoop(EventChannel* ioChannel)
{
	boost::mutex::scoped_lock scoped_lock(mEventChannelListMutex);

	int channel_id = getChannelId(ioChannel, false);
	if (channel_id == -1)
		return;

	if (channel_id == (mThreadCount - 1))
	{
		mEventChannelList[channel_id] = NULL;
	}
	else
	{
		mEventChannelList[channel_id] = mEventChannelList[mThreadCount - 1];
		mEventChannelList[mThreadCount - 1] = NULL;
	}	
	--mThreadCount;
}
void EventManager::unsubscribeAll(EventChannel* ioChannel)
{
	// Takes a very long time
	boost::mutex::scoped_lock scoped_lock(mExecutionListMutex);

	EventChannelMaskMap::iterator it = mExecutionList.begin();

	int id = getChannelId(ioChannel);
	if (id == -1)
		return;
	
	long channelmask = (1 << id);
	while(it != mExecutionList.end())
	{
		if ((*it).second & channelmask)
		{
			long mask = (*it).second;
			mExecutionList[(*it).first] = (mask - channelmask);
		}
		++it;
	}

}
Beispiel #5
0
static int lua_msdk_getChannelId(lua_State * L)
{
		PUSHDELETESTRING(getChannelId());
    return 1;
}