예제 #1
0
_HYEvent*	generateButtonPushEvent (long objID, long newSel)
{
	_String eventClass (_hyButtonPushEvent),
			eventData (objID);
	eventData = eventData & ','& _String (newSel);
	return	new _HYEvent (eventClass,eventData);
}
예제 #2
0
_HYEvent*	generateListDblClickEvent (long objID, long newSel)
{
	_String eventClass (_hyListDblClickEvent),
			eventData (objID);
	eventData = eventData & ','& _String (newSel);
	return	new _HYEvent (eventClass,eventData);
}
예제 #3
0
_HYEvent*	generateContextPopUpEvent (long objID, long locH, long locV)
{
	_String eventClass (_hyContextPopUp),
			eventData  (objID);
	eventData = eventData & ','& _String (locH) & ',' & _String (locV);
	return	new _HYEvent (eventClass,eventData);
}
예제 #4
0
_HYEvent*	generateTableEditCellEvent (long objID, long index)
{
	_String eventClass (_hyTableEditCellEvent),
			eventData  (objID);
	eventData = eventData & ','& _String (index);
	return	new _HYEvent (eventClass,eventData);
}
예제 #5
0
_HYEvent*	generateTablePullDownEvent (long objID, long index, long location)
{
	_String eventClass (_hyTablePullDownEvent),
			eventData  (objID);
	eventData = eventData & ','& _String (index) & ',' & _String (location);
	return	new _HYEvent (eventClass,eventData);
}
예제 #6
0
_HYEvent*	generateTableResizeCEvent (long objID, long index, long shift)
{
	_String eventClass (_hyTableResizeCEvent),
			eventData  (objID);
	eventData = eventData & ','& _String (index) & ','& _String (shift);
	return	new _HYEvent (eventClass,eventData);
}
void
CCodecBasedProductInfoListProvider::OnAllDataRetrieved( void )
{
    CORE::CDStoreCodecRegistry& codecRegistry = CORE::CCoreGlobal::Instance()->GetDStoreCodecRegistry();

    CORE::CDStoreCodecRegistry::TDStoreCodecPtr codec;
    if ( codecRegistry.TryLookup( m_codecToUse ,
                                  codec        ,
                                  false        ) )
    {
        // we have our codec, parse the data into data nodes
        CORE::CDataNode rootNode;
        if ( codec->BuildDataTree( &rootNode, m_dataRetriever.GetIOAccess() ) )
        {
            // Now try to load the product info list data
            CProductInfoListPtr productInfoList = new CProductInfoList();
            if ( productInfoList->LoadConfig( rootNode ) )
            {
                rootNode.Clear();
                
                CProductInfoListRetrievedEventData eventData( m_dataRetriever.GetURL().GetURL(), productInfoList );
                NotifyObservers( ProductInfoListRetrievedEvent, &eventData );
            }
        }
    }
}
예제 #8
0
_HYEvent*	generateMenuSelChangeEvent (long objID, long newSel)
{
	_String eventClass (_hyMenuSelChangeEvent),
			eventData (objID);
	eventData = eventData & ','& _String (newSel);
	return	new _HYEvent (eventClass,eventData);
}
    virtual Size tableCellSizeForIndex(TableView *table, ssize_t idx) override
    {
        if (nullptr != table )
        {
            int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX);
            if (0 != handler)
            {
                LuaTableViewEventData eventData(&idx);
                BasicScriptData data(table,&eventData);
                float width = 0.0;
                float height = 0.0;
                LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_SIZE_FOR_INDEX, (void*)&data,2,[&](lua_State* L,int numReturn) {
                    CCASSERT(numReturn == 2, "tableCellSizeForIndex return count error");
                    ValueVector vec;
                    width  = (float)tolua_tonumber(L, -1, 0);
                    lua_pop(L, 1);
                    height = (float)tolua_tonumber(L, -1, 0);
                    lua_pop(L, 1);
                });

                return Size(width, height);
            }
        }

        return Size::ZERO;
    }
예제 #10
0
_HYEvent*	generateTextEditChangeEvent (long objID, long mouseOrKey)
{
	_String eventClass (_hyTextEditChange),
			eventData  (objID);
	eventData = eventData & ','& _String (mouseOrKey);
	return	new _HYEvent (eventClass,eventData);
}
void ofxOMXPlayerEngine::onVideoLoop()
{
	if (listener != NULL) 
	{
		
		ofxOMXPlayerListenerEventData eventData((void *)this);
		listener->onVideoLoop(eventData);
	}
}
예제 #12
0
void	postWindowCloseEvent (long senderID)
{
	_String eventClass (_hyGlobalCloseWindow),
			eventData (senderID);
	_HYEvent*
			closeEvent = new _HYEvent (eventClass,eventData);
			
	GlobalGUIEventQueue << closeEvent;
}
예제 #13
0
_HYEvent*	generateScrollEvent (int h,int v,long objID)
{
	_String eventClass (_hyScrollingEvent),
			eventData ((long)h);
	eventData = eventData & ','& _String ((long)v);
	if (objID>=0)
		eventData = _String (objID)&','&eventData;
		
	return	new _HYEvent (eventClass,eventData);
}
예제 #14
0
void	postObjectChangelEvent (long senderID,long objectKind, long objectID)
{
	_String eventClass (_hyGlobalChangeEvent),
			eventData (senderID);
	eventData = eventData & ','& _String ((objectKind<<28)+objectID);
	_HYEvent*
			killEvent = new _HYEvent (eventClass,eventData);
			
	GlobalGUIEventQueue << killEvent;
}
예제 #15
0
void	postDFKillEvent (long objID,long lfID)
{
	_String eventClass (_hyGlobalDFKillEvent),
			eventData (objID);
	eventData = eventData & ','& _String (lfID);
	_HYEvent*
			killEvent = new _HYEvent (eventClass,eventData);
			
	GlobalGUIEventQueue << killEvent;
}
예제 #16
0
void	postLFSpawnEvent (long objID,long lfID)
{
	_String eventClass (_hyGlobalLFSpawnEvent),
			eventData (objID);
	eventData = eventData & ','& _String (lfID);
	_HYEvent*
			spawnEvent = new _HYEvent (eventClass,eventData);
			
	GlobalGUIEventQueue << spawnEvent;
}
 virtual void onProgress(int percent) override
 {
     int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS);
     if (0 != handler)
     {
         LuaAssetsManagerEventData eventData(percent);
         BasicScriptData data((void*)this,&eventData);
         LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_PROGRESS, (void*)&data);
     }
 }
 virtual void onError(AssetsManager::ErrorCode errorCode) override
 {
     int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR);
     if (0 != handler)
     {
         LuaAssetsManagerEventData eventData((int)errorCode);
         BasicScriptData data((void*)this,&eventData);
         LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ASSETSMANAGER_ERROR, (void*)&data);
     }
 }
예제 #19
0
void	postChangeLFParamsEvent (long senderID, long lfID)
{
	_String eventClass (_hyGlobalChangeLFParams),
			eventData (senderID);
			
	eventData = eventData & ',' & lfID;
	_HYEvent*
			modEvent = new _HYEvent (eventClass,eventData);
			
	GlobalGUIEventQueue << modEvent;
}
예제 #20
0
void
CPing::OnPumpedNotify( CORE::CNotifier* notifier    ,
                       const CORE::CEvent& eventid  ,
                       CORE::CICloneable* eventdata )
{GUCEF_TRACE;

    if ( CPingTaskConsumer::PingStartedEvent == eventid )
    {
        CPingTaskConsumer::CEchoReceivedEventData* taskData = static_cast< CPingTaskConsumer::CEchoReceivedEventData* >( eventdata );
        CPingEventData eventData( taskData->GetHostAddress(), taskData->GetEchoSize(), taskData->GetRoundTripTime() );
        NotifyObservers( PingStartedEvent, &eventData );
    }
    else
    if ( CPingTaskConsumer::PingReponseEvent == eventid )
    {
        CPingTaskConsumer::CEchoReceivedEventData* taskData = static_cast< CPingTaskConsumer::CEchoReceivedEventData* >( eventdata );
        CPingEventData eventData( taskData->GetHostAddress(), taskData->GetEchoSize(), taskData->GetRoundTripTime() );
        NotifyObservers( PingReponseEvent, &eventData );
    }
    else
    if ( CPingTaskConsumer::PingTimeoutEvent == eventid )
    {
        CPingTaskConsumer::CEchoReceivedEventData* taskData = static_cast< CPingTaskConsumer::CEchoReceivedEventData* >( eventdata );
        CPingEventData eventData( taskData->GetHostAddress(), taskData->GetEchoSize(), taskData->GetRoundTripTime() );
        NotifyObservers( PingTimeoutEvent, &eventData );
    }
    else
    if ( CPingTaskConsumer::PingFailedEvent == eventid )
    {
        CPingTaskConsumer::CEchoReceivedEventData* taskData = static_cast< CPingTaskConsumer::CEchoReceivedEventData* >( eventdata );
        CPingEventData eventData( taskData->GetHostAddress(), taskData->GetEchoSize(), taskData->GetRoundTripTime() );
        NotifyObservers( PingFailedEvent, &eventData );
    }
    else
    if ( CPingTaskConsumer::PingStoppedEvent == eventid )
    {
        CPingTaskConsumer::CEchoReceivedEventData* taskData = static_cast< CPingTaskConsumer::CEchoReceivedEventData* >( eventdata );
        CPingEventData eventData( taskData->GetHostAddress(), taskData->GetEchoSize(), taskData->GetRoundTripTime() );
        NotifyObservers( PingStoppedEvent, &eventData );
    }
}
 virtual void tableCellWillRecycle(TableView* table, TableViewCell* cell) override
 {
     if (nullptr != table && nullptr != cell)
     {
         int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE);
         if (0 != handler)
         {
             LuaTableViewEventData eventData(cell);
             BasicScriptData data(table,&eventData);
             LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_WILL_RECYCLE,(void*)&data);
         }
     }
 }
 virtual void tableCellUnhighlight(TableView* table, TableViewCell* cell) override
 {
     if (nullptr != table && nullptr != cell)
     {
         int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT);
         if (0 != handler)
         {
             LuaTableViewEventData eventData(cell);
             BasicScriptData data(table,&eventData);
             LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_UNHIGHLIGHT,(void*)&data);
         }
     }
 }
        void alert(const std::string &event)
            {
                events eventUsed;
                if (event == "next_level")
                    {
                        eventUsed = NEXT_LEVEL;
                    }
                else if (event == "player_lose_health")
                    {
                        eventUsed = PLAYER_LOSE_HEALTH;
                    }

                globals::_eventManager->alert(eventData(eventUsed));
            }
예제 #24
0
void SocketComponent::update()
{
	if (m_clientServer != 0)
	{
		unsigned int newSize = m_clientServer->getNewestMessagesSize();
		if (newSize > 0)
		{
			char* data = new char[newSize];
			m_clientServer->getNewestMessages(&data);
			GameEventData eventData(data, newSize);
			GameEvent newData(GameEvent::E_SOCKET_NEW_DATA, &eventData, this);
			delete[] data;
		}
	}
}
예제 #25
0
void CProcessControl::handleEventThread()
{
	MSG msg;
	while(::GetMessage(&msg, NULL, 0, 0)) {
		// TODO: exclusive control
		std::shared_ptr<EventData> eventData((EventData*)msg.lParam);
		if((m_state < 0) || (StateMax <= m_state) ||
			(eventData->event < 0) || (EventMax < eventData->event)) {
			// state or event is out of range
			break;
		}
		EventHandler eventHandler = eventStateTable[m_state][eventData->event];
		if(eventHandler == NULL) continue;

		m_state = (this->*eventHandler)(*eventData);
	}
}
    virtual TableViewCell* tableCellAtIndex(TableView *table, ssize_t idx) override
    {
        if (nullptr != table )
        {
            int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)table, ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX);
            if (0 != handler)
            {
                LuaTableViewEventData eventData(&idx);
                BasicScriptData data(table,&eventData);
                TableViewCell* viewCell = nullptr;
                LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::TABLECELL_AT_INDEX, (void*)&data, 1, [&](lua_State* L, int numReturn) {
                    CCASSERT(numReturn == 1, "tableCellAtIndex return count error");
                    viewCell = static_cast<TableViewCell*>(tolua_tousertype(L, -1, nullptr));
                    lua_pop(L, 1);
                });

                return viewCell;
            }
        }

        return NULL;
    }
예제 #27
0
파일: EpollServer.cpp 프로젝트: mierl/zht-h
void EpollServer::serve() {

#ifdef THREADED_SERVE
	init_thread();
#endif

	int sfd, s;
	int efd;
	struct epoll_event event;
	struct epoll_event *events;

	sfd = makeSvrSocket();
	if (sfd == -1)
		abort();

	s = make_socket_non_blocking(sfd);
	if (s == -1)
		abort();

	reuseSock(sfd);

	efd = epoll_create(1);
	if (efd == -1) {
		perror("epoll_create");
		abort();
	}

	event.data.ptr = new EpollData(sfd, NULL);
	event.events = EPOLLIN | EPOLLET;
	s = epoll_ctl(efd, EPOLL_CTL_ADD, sfd, &event);
	if (s == -1) {
		perror("epoll_ctl");
		abort();
	}

	/* Buffer where events are returned */
	events = (epoll_event *) calloc(MAX_EVENTS, sizeof event);

	/* The event loop */
	while (1) {

		int n, i;

		n = epoll_wait(efd, events, MAX_EVENTS, -1);

		for (i = 0; i < n; i++) {

			EpollData *edata = (EpollData*) events[i].data.ptr;

			if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP)
					|| (!(events[i].events & EPOLLIN))) {

				/* An error has occured on this fd, or the socket is not
				 ready for reading (why were we notified then?) */
				fprintf(stderr, "epoll error\n");
				close(edata->fd());
				delete edata;
				continue;
			} else if (sfd == edata->fd()) {

				if (_tcp == true) {
					/* We have a notification on the listening socket, which
					 means one or more incoming connections. */
					while (1) {

						sockaddr *in_addr = (sockaddr *) calloc(1,
								sizeof(struct sockaddr));
						socklen_t in_len = sizeof(struct sockaddr);

						int infd = accept(sfd, in_addr, &in_len);
						if (infd == -1) {

							free(in_addr);

							if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) {

								/* We have processed all incoming connections. */
								break;
							} else {

								perror("accept");
								break;
							}
						}

						/* fprintf(stdout,
						 "sin_family[%hu], sin_zero[%s], sin_addr.s_addr[%u], sin_port[%hu]\n",
						 in_addr.sin_family, in_addr.sin_zero,
						 in_addr.sin_addr.s_addr, in_addr.sin_port);
						 */

						/*
						 char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
						 getnameinfo(in_addr, in_len, hbuf, sizeof hbuf, sbuf,
						 sizeof sbuf, 0);

						 if (s == 0) {

						 printf("Accepted connection on descriptor %d "
						 "(host=%s, _port=%s)\n", infd, hbuf, sbuf);
						 }*/

						/* Make the incoming socket non-blocking and add it to the
						 list of fds to monitor. */
						s = make_socket_non_blocking(infd);
						if (s == -1) {

							free(in_addr);
							abort();
						}

						reuseSock(infd);

						event.data.ptr = new EpollData(infd, in_addr);
						event.events = EPOLLIN | EPOLLET;
						s = epoll_ctl(efd, EPOLL_CTL_ADD, infd, &event);
						if (s == -1) {

							free(in_addr);
							perror("epoll_ctl");
							abort();
						}
					}
					continue;
				} else {

					int done = 0;

					while (1) {

						char buf[Env::BUF_SIZE];
						memset(buf, 0, sizeof(buf));
						//char *buf = (char*) calloc(Env::BUF_SIZE, sizeof(char));

						sockaddr fromaddr;
						socklen_t sender_len = sizeof(struct sockaddr);
						ssize_t count = recvfrom(edata->fd(), buf, sizeof buf,
								0, &fromaddr, &sender_len);
						//cout << "EpollServer.cpp: serve(): received "<< count << " bytes."<<endl;
						if (count == -1) {

							if (errno != EAGAIN) {

								perror("read");
								done = 1;
							}

						} else if (count == 0) {

							done = 1;
							break;

						} else {

#ifdef BIG_MSG
							bool ready = false;
							string bd = pbrb->getBdStr(sfd, buf, count, ready);

							if (ready) {

#ifdef THREADED_SERVE
								EventData eventData(edata->fd(), bd.c_str(), bd.size(),
										fromaddr);
								_eventQueue.push(eventData);

#else
								_ZProcessor->process(edata->fd(), bd.c_str(),
										fromaddr);
#endif
							}
#endif

#ifdef SML_MSG
#ifdef THREADED_SERVE
							EventData eventData(edata->fd(), buf, sizeof(buf),
									fromaddr);
							_eventQueue.push(eventData);

#else
							string bufstr(buf);
							_ZProcessor->process(edata->fd(), bufstr.c_str(),
									fromaddr);
#endif
#endif
						}

						//memset(buf, 0, sizeof(buf));
						//free(buf);
					}

					/*if (done) {

					 close(edata->fd());
					 delete edata;
					 }*/
				}

			} else {

				if (_tcp == true) {

					/* We have data on the fd waiting to be read. Read and
					 display it. We must read whatever data is available
					 completely, as we are running in edge-triggered mode
					 and won't get a notification again for the same
					 data. */
					int done = 0;

					while (1) {

						char buf[Env::BUF_SIZE];
						memset(buf, 0, sizeof(buf));
						//char *buf = (char*) calloc(Env::BUF_SIZE, sizeof(char));

						ssize_t count = recv(edata->fd(), buf, sizeof(buf), 0);

						if (count == -1) {

							/* If errno == EAGAIN, that means we have read all
							 data. So go back to the main loop. */
							if (errno != EAGAIN) {

								perror("read");
								done = 1;
							} /*else {

							 printf(
							 "Closed connection on descriptor %d, -1<--recv\n",
							 edata->fd());

							 close(edata->fd());
							 delete edata;
							 }*/
							break;
						} else if (count == 0) {

							/* End of file. The remote has closed the
							 connection. */
							done = 1;
							break;
						} else {

#ifdef BIG_MSG
							bool ready = false;
							string bd = pbrb->getBdStr(sfd, buf, count, ready);

							if (ready) {

#ifdef THREADED_SERVE
								EventData eventData(edata->fd(), bd.c_str(), bd.size(),
										*edata->sender());
								_eventQueue.push(eventData);
#else
								_ZProcessor->process(edata->fd(), bd.c_str(),
										*edata->sender());
#endif
							}
#endif

#ifdef SML_MSG
#ifdef THREADED_SERVE
							EventData eventData(edata->fd(), buf, sizeof(buf),
									*edata->sender());
							_eventQueue.push(eventData);
#else
							string bufstr(buf);
							_ZProcessor->process(edata->fd(), bufstr.c_str(),
									*edata->sender());
#endif
#endif
						}

						//memset(buf, 0, sizeof(buf));
						//free(buf);
					}

					if (done) {

						/*printf("Closed connection on descriptor %d, done.\n",
						 edata->fd());*/

						/* Closing the descriptor will make epoll remove it
						 from the set of descriptors which are monitored. */
						close(edata->fd());
						delete edata;
					}
				} //if TCP == true
			}
		}
	}

	free(events);

	close(sfd);

	EpollData *edata = (EpollData*) event.data.ptr;
	delete edata;
}
예제 #28
0
_HYEvent*	generateListChangeEvent (long objID)
{
	_String eventClass (_hyListChangeEvent),
			eventData (objID);
	return	new _HYEvent (eventClass,eventData);
}
예제 #29
0
_HYEvent*	generateKeyboardFocusEvent (long objID)
{
	_String eventClass (_hyKeyboardFocusEvent),
			eventData (objID);
	return	new _HYEvent (eventClass,eventData);
}
예제 #30
0
_HYEvent*	generateTableChangeSelEvent (long objID)
{
	_String eventClass (_hyTableChangeSelEvent),
			eventData  (objID);
	return	new _HYEvent (eventClass,eventData);
}