bool HTTPClientBinding::FireEvent(std::string& eventName)
	{
		// We're already exposed as an AutoPtr somewhere else, so we must create
		// an AutoPtr version of ourselves with the 'shared' argument set to true.
		ValueList args(Value::NewObject(GetAutoPtr()));

		// Must invoke the on*** handler functions
		if (eventName == Event::HTTP_STATE_CHANGED && !this->onreadystate.isNull())
		{
			this->host->InvokeMethodOnMainThread(this->onreadystate, args, true);

			if (this->Get("readyState")->ToInt() == 4 && !this->onload.isNull())
			{
				this->host->InvokeMethodOnMainThread(this->onload, args, true);
			}
		}
		else if (eventName == Event::HTTP_DATA_SENT && !this->onsendstream.isNull())
		{
			this->host->InvokeMethodOnMainThread(this->onsendstream, args, true);
		}
		else if (eventName == Event::HTTP_DATA_RECEIVED && !this->ondatastream.isNull())
		{
			this->host->InvokeMethodOnMainThread(this->ondatastream, args, true);
		}

		return KEventObject::FireEvent(eventName);
	}
示例#2
0
 void AsyncJob::DoCallback(KMethodRef method, bool reportErrors)
 {
     ValueList args(Value::NewObject(GetAutoPtr()));
     RunOnMainThread(method, args, false);
 }