Exemplo n.º 1
0
void Entity::ProcessEvent(std::unique_ptr<Event> event)
{
    for (auto &eventCallback : mEventCallbacks[event->GetType()])
    {
        eventCallback(event.get());
    }
}
Exemplo n.º 2
0
    void SpineDrawable::handleEvent(int type, spTrackEntry* entry, spEvent* event)
    {
        if (eventCallback)
        {
            Event e;

            switch (type)
            {
                case SP_ANIMATION_START:
                    e.type = Event::Type::START;
                    break;
                case SP_ANIMATION_END:
                    e.type = Event::Type::END;
                    break;
                case SP_ANIMATION_COMPLETE:
                    e.type = Event::Type::COMPLETE;
                    break;
                case SP_ANIMATION_EVENT:
                    e.type = Event::Type::EVENT;
                    if (event)
                    {
                        e.name = event->data->name;
                        e.time = event->time;
                        e.intValue = event->intValue;
                        e.floatValue = event->floatValue;
                        if (event->stringValue) e.stringValue = event->stringValue;
                    }
                    break;
            }

            eventCallback(entry->trackIndex, e);
        }
    }
Exemplo n.º 3
0
/*
** SRV_NEventReportResponse
**
** Purpose:
**	SRV_NEventReportResponse assists an application that wants to be an SCU
**	of a number of SOP classes. When an application receives an
**	N-EVENT_REPORT request message, it calls this function with the
**	N-EVENT_REPORT request and other parameters. SRV_NEventReportResponse
**	checks the caller's parameters and calls the user's callback function.
**	In the callback	function, the caller fills in the parameters of the
**	N-EVENT_REPORT response	message and then returns to the SRV function.
**
**	After the callback function returns, SRV_NEventReportResponse
**	constructs a N-EVENT_REPORT Response message and sends it to the peer
**	application which sent the request message.
**
**	The arguments to the callback function are:
**		MSG_N_EVENT_REPORT_REQ	*eventRequest
**		MSG_N_EVENT_REPORT_RESP	*eventResponse
**		void			*eventCtx
**		DUL_PRESENTATIONCONTEXT	*pc
**
**	The first two arguments are MSG structures that contain the
**	N-EVENT_REPORT Request and N-EVENT_REPORT Response messages
**	respectively. The third argument is the caller's context variable that
**	is passed to SRV_NEventReportResponse.  The presentation context is
**	the one negotiated for this SOP class.
**
**	The callback function should return SRV_NORMAL. Any other return
**	value will cause the SRV facility to abort the Association.
**
** Parameter Dictionary:
**	association	The key which is used for transmitting the
**			N-EVENT_REPORT response.
**	presentationCtx	Pointer to presentation context to be used when sending
**			the N-EVENT_REPORT response.
**	eventRequest	Pointer to the structure with the N-EVENT_REPORT request
**			parameters which was received by the application.
**	eventResponse	Pointer to structure in the caller's area which will be
**			filled with the parameters of the N-EVENT_REPORT
**			response command. After the parameters are filled in,
**			the N-EVENT_REPORT response is sent to the peer
**			application which sent the request.
**	eventCallback	Address of user callback function to be called
**			with the N-EVENT_REPORT response from SCU.
**	eventCtx	Pointer to user context information which will be
**			passed to the callback function. Caller uses this
**			variable to contain any context required for the
**			callback function.
**      dirName         Name of directory where files may be created.
**
**
** Return Values:
**
**	SRV_CALLBACKABORTEDSERVICE
**	SRV_ILLEGALPARAMETER
**	SRV_NOCALLBACK
**	SRV_NORMAL
**	SRV_OBJECTBUILDFAILED
**	SRV_RESPONSEFAILED
**
** Algorithm:
**	Receive a data set, if any, from the peer application
**	Invoke the callback function, if it exists.
**	Build a command and send it to the requesting peer application.
**	Send a data set, if any, to the peer application.
**
** Notes:
**	The callback function is responsible for explicitly setting the
**	following fields in the N-EVENT_REPORT request message:
**
**	type
**	messageIDRespondedTo
**	classUID
**	dataSetType
**	instanceUID
**	status
**
*/
CONDITION
SRV_NEventReportResponse(DUL_ASSOCIATIONKEY ** association, DUL_PRESENTATIONCONTEXT * presentationCtx, MSG_N_EVENT_REPORT_REQ ** eventRequest,
						 MSG_N_EVENT_REPORT_RESP * eventResponse, SRV_N_EVENTREPORT_RESP_CALLBACK * eventCallback, void *eventCtx, char *dirName)
{
    CONDITION	cond;
    DCM_OBJECT	* responseObject;

    eventResponse->status = MSG_K_SUCCESS;
    if (eventCallback == NULL) {
    	(void) MSG_Free((void **) eventRequest);
    	return COND_PushCondition(SRV_NOCALLBACK, SRV_Message(SRV_NOCALLBACK), "SRV_NEventReportResponse");
    }
    if ((*eventRequest)->dataSetType != DCM_CMDDATANULL){
    	cond = SRV_ReceiveDataSet(association, presentationCtx, DUL_BLOCK, 0, dirName, &(*eventRequest)->dataSet);
    	if (cond != SRV_NORMAL){
    		(void) MSG_Free((void **) eventRequest);
    		return COND_PushCondition(SRV_RESPONSEFAILED, SRV_Message(SRV_RESPONSEFAILED), "SRV_NEventReportResponse");
    	}
    }
    eventResponse->dataSetType = DCM_CMDDATANULL;

    cond = DCM_CreateObject(&eventResponse->dataSet, 0);
    if (cond != DCM_NORMAL) {
    	(void) MSG_Free((void **) eventRequest);
    	return COND_PushCondition(SRV_RESPONSEFAILED, SRV_Message(SRV_RESPONSEFAILED), "SRV_NEventReportResponse");
    }

    cond = eventCallback(*eventRequest, eventResponse, eventCtx, presentationCtx);
    (void) MSG_Free((void **) eventRequest);
    if (cond != SRV_NORMAL) return COND_PushCondition(SRV_CALLBACKABORTEDSERVICE, SRV_Message(SRV_CALLBACKABORTEDSERVICE), "SRV_NEventReportRequest");

    if (eventResponse->type != MSG_K_N_EVENT_REPORT_RESP)
    	return COND_PushCondition(SRV_ILLEGALPARAMETER, SRV_Message(SRV_ILLEGALPARAMETER), "type", "N-EVENT_REPORT Response", "SRV_NEventReportResponse");

    cond = MSG_BuildCommand(eventResponse, &responseObject);
    if (cond != MSG_NORMAL) {
    	(void) DCM_CloseObject(&eventResponse->dataSet);
    	return COND_PushCondition(SRV_OBJECTBUILDFAILED, SRV_Message(SRV_OBJECTBUILDFAILED), "N-EVENT_REPORT Response", "SRV_NEventReportResponse");
    }

    cond = SRV_SendCommand(association, presentationCtx, &responseObject);
    (void) DCM_CloseObject(&responseObject);
    if (cond != SRV_NORMAL) {
    	(void) DCM_CloseObject(&eventResponse->dataSet);
    	return COND_PushCondition(SRV_RESPONSEFAILED, SRV_Message(SRV_RESPONSEFAILED), "SRV_NEventReportResponse");
    }
    if (eventResponse->dataSetType != DCM_CMDDATANULL){ /* application specific event reply exists */
    	cond = SRV_SendDataSet(association, presentationCtx, &eventResponse->dataSet, NULL, NULL, 0);
    	if (cond != SRV_NORMAL){
    		(void) DCM_CloseObject(&eventResponse->dataSet);
    		return COND_PushCondition(SRV_RESPONSEFAILED, SRV_Message(SRV_RESPONSEFAILED), "SRV_NEventReportResponse");
    	}
    }
    (void) DCM_CloseObject(&eventResponse->dataSet);
    return SRV_NORMAL;
}
	void WMTouchEventSource::touchUp(TOUCHINPUT *ti)
	{
		assert(ti);

		if(eventCallback != NULL) 
		{
			Point2f p = convert(ti);
			eventCallback(ti->dwID, p.getX(),p.getY(), FingerEventArgs::EventType::FINGER_REMOVED);
		}
	}
Exemplo n.º 5
0
void Checkbox::onClick()
{
	if (_selected) {
		_selected = false;
		uvRect = _spriteSheet.getUVs(0);
	}
	else {
		_selected = true;
		uvRect = _spriteSheet.getUVs(1);
	}

	if (eventCallback != NULL)
		eventCallback();
}
Exemplo n.º 6
0
bool UI_Friend::Notify(const string& name, Args& args)
{
    if(IUILayer::Notify(name, args))
        return true;
    
//    Notify_Compare(MES_PLAYER_SETINVITECODE)
//    {
//        p_invite->setVisible(NO);
//        setInviteCode(_player->invitecode);
//        UIMessage::createMesBox("提交完成");
//        return YES;
//    }
    Notify_Compare(MES_PLAYER_GETFRIENDREWARD)
    {
        setFriendsList();
        UIMessage::createMesBox("领取成功");
        return YES;
    }
    
    Notify_Compare(SYSTEM_KEYBACK)
    {
//        if(p_invite->isVisible())
//        {
//            p_invite->setVisible(NO);
//            return YES;
//        }
        Ref* sender = rootNode->getChildByTag(B_BACK);
        if(sender)
            eventCallback(sender, Widget::TouchEventType::ENDED);
        return YES;
    }
    
    Notify_Compare(MES_GAMEINI_SCREENSHOOT_SUCCEED)
    {
        GAMELOG("---%s",args.content.c_str());
        ShareSDKHelper::getInstance()->sendImage(GameIni::getInstance()->shareSdkInfo.title,
                                                 GameIni::getInstance()->shareSdkInfo.description,
                                                 args.content);
        return YES;
    }
    
    return true;
}
Exemplo n.º 7
0
/* SRV_NEventReportRequest
**
** Purpose:
**	SRV_NEventReportRequest assists an application that wants to be an SCP
**	of a number of SOP classes. This function constructs an N-EVENT_REPORT
**	request message and sends it to the peer application which is acting as
**	SCU for a SOP class. This function waits for the response from the
**	peer application and invokes the caller's callback function.
**
**	The arguments to the callback function are:
**		MSG_N_EVENT_REPORT_REQ	*eventRequest
**		MSG_N_EVENT_REPORT_RESP	*eventResponse
**		void			*eventCtx
**
**	The first two arguments are MSG structures that contain the
**	N-EVENT_REPORT Request and N-EVENT_REPORT Response messages
**	respectively. The final argument is the caller's context variable
**	that is passed to SRV_NEventReportRequest.
**
**	The callback function should return SRV_NORMAL. Any other return
**	value will cause the SRV facility to abort the Association.
**
** Parameter Dictionary:
**	association	The key which is used to access an existing
**			association.
**	params		The list of parameters for the association. This
**			list includes the list of presentation contexts.
**	eventRequest	Pointer to the structure with the N-EVENT_REPORT request
**			parameters.
**	eventResponse	Pointer to caller's pointer to an N-EVENT_REPORT
**			response. This function will allocate an
**			MSG_N_EVENT_REPORT_RESP	message and return the
**			pointer to the caller.
**	eventCallback	Address of user callback function to be called
**			with the N-EVENT_REPORT response from SCU.
**	eventCtx	Pointer to user context information which will be
**			passed to the callback function. Caller uses this
**			variable to contain any context required for the
**			callback function.
**      dirName         Name of directory where files may be created.
**
**
** Return Values:
**
**	SRV_CALLBACKABORTEDSERVICE
**	SRV_ILLEGALPARAMETER
**	SRV_NOCALLBACK
**	SRV_NORMAL
**	SRV_OBJECTBUILDFAILED
**	SRV_REQUESTFAILED
**	SRV_UNEXPECTEDCOMMAND
**	SRV_UNSUPPORTEDSERVICE
**
** Algorithm:
**	Check if the callback function has been provided.
**	Determine the presentation context
**	Encode the N-EVENT_REPORT request message as a command object and
**		send it to an SCU
**	Send data set, if one exists, to the SCU.
**	Wait for a response message to arrive from the SCU
**	Receive a data set, if one exists, from the SCU
**	Return address of Response message structure to caller.
**
** Notes:
**	The caller is responsible for explicitly setting the following
**	fields in the N-EVENT_REPORT request message:
**
**	type
**	messageID
**	classUID
**	dataSetType
**	affectedInstanceUID
**	eventTypeID
**
**	The caller is also responsible for releasing the Response message
**	structure after the SRV_NEventReportRequest function returns,
**	using MSG_Free.
*/
CONDITION
SRV_NEventReportRequest(DUL_ASSOCIATIONKEY ** association, DUL_ASSOCIATESERVICEPARAMETERS * params,	MSG_N_EVENT_REPORT_REQ * eventRequest,
						MSG_N_EVENT_REPORT_RESP * eventResponse, SRV_N_EVENTREPORT_REQ_CALLBACK * eventCallback,	void *eventCtx, char *dirName)
{
    DCM_OBJECT					* commandObject;	/* Handle for a command object */
    CONDITION					cond;				/* Return value from function calls */
    DUL_PRESENTATIONCONTEXT		* presentationCtx;	/* Presentation context for this service */
    DUL_PRESENTATIONCONTEXTID	ctxID;
    void       					*message;
    MSG_TYPE					messageType;
    MSG_N_EVENT_REPORT_RESP		* localResponse;
    unsigned short        		command;

    if (eventCallback == NULL) return COND_PushCondition(SRV_NOCALLBACK, SRV_Message(SRV_NOCALLBACK), "SRV_NEventReportRequest");

    presentationCtx = SRVPRV_PresentationContext(params, eventRequest->classUID);
    if (presentationCtx == NULL)
    	return COND_PushCondition(SRV_UNSUPPORTEDSERVICE, SRV_Message(SRV_UNSUPPORTEDSERVICE), eventRequest->classUID, "SRV_NEventReportRequest");
    if (eventRequest->type != MSG_K_N_EVENT_REPORT_REQ)
    	return COND_PushCondition(SRV_ILLEGALPARAMETER, SRV_Message(SRV_ILLEGALPARAMETER), "type", "N-EVENT_REPORT Request", "SRV_NEventReportRequest");

    cond = MSG_BuildCommand(eventRequest, &commandObject);
    if (cond != MSG_NORMAL)	return COND_PushCondition(SRV_OBJECTBUILDFAILED, SRV_Message(SRV_OBJECTBUILDFAILED), "N-EVENT_REPORT Request", "SRV_NEventReportRequest");

    cond = SRV_SendCommand(association, presentationCtx, &commandObject);
    (void) DCM_CloseObject(&commandObject);
    if (cond != SRV_NORMAL)	return COND_PushCondition(SRV_REQUESTFAILED, SRV_Message(SRV_REQUESTFAILED), "SRV_NEventReportRequest");

    if (eventRequest->dataSetType != DCM_CMDDATANULL){	/* application specific event information exists */
    	cond = SRV_SendDataSet(association, presentationCtx, &eventRequest->dataSet, NULL, NULL, 0);
    	if (cond != SRV_NORMAL) return COND_PushCondition(SRV_REQUESTFAILED, SRV_Message(SRV_REQUESTFAILED), "SRV_NEventReportRequest");
    }

    cond = SRV_ReceiveCommand(association, params, DUL_BLOCK, 0, &ctxID, &command, &messageType, &message);
    if (cond != SRV_NORMAL)	return COND_PushCondition(SRV_REQUESTFAILED, SRV_Message(SRV_REQUESTFAILED), "SRV_NEventReportRequest");

    if (messageType != MSG_K_N_EVENT_REPORT_RESP) {
    	(void) MSG_Free(&message);
    	return COND_PushCondition(SRV_UNEXPECTEDCOMMAND, SRV_Message(SRV_UNEXPECTEDCOMMAND), (int) command, "SRV_NEventReportRequest");
    }
    localResponse = (MSG_N_EVENT_REPORT_RESP *) message;
    if (localResponse->dataSetType == DCM_CMDDATANULL) {
    	localResponse->dataSet = NULL;
    }else{
    	cond = SRV_ReceiveDataSet(association, presentationCtx, DUL_BLOCK, 0, dirName, &localResponse->dataSet);
    	if (cond != SRV_NORMAL) {
    		(void) MSG_Free(&message);
    		return COND_PushCondition(SRV_REQUESTFAILED, SRV_Message(SRV_REQUESTFAILED), "SRV_NEventReportRequest");
    	}
    }
    cond = eventCallback(eventRequest, eventResponse, eventCtx);
    (void) MSG_Free(&message);
    if (localResponse->dataSet != NULL) {
    	(void) DCM_CloseObject(&localResponse->dataSet);
    	localResponse->dataSet = NULL;
    }
    if (eventResponse != NULL) *eventResponse = *localResponse;

    if (cond != SRV_NORMAL)	return COND_PushCondition(SRV_CALLBACKABORTEDSERVICE, SRV_Message(SRV_CALLBACKABORTEDSERVICE), "SRV_NEventReportRequest");

    return SRV_NORMAL;
}
Exemplo n.º 8
0
void hal_notify_event(int event, int flags, void* data) {
    if (eventCallback) {
        eventCallback(event, flags, data);
    }
}