Exemplo n.º 1
0
	void UIBinding::_CreateNotification(const ValueList& args, KValueRef result)
	{
		args.VerifyException("createNotification", "?o");
		AutoNotification n(new Notification());

		if (args.GetValue(0)->IsObject())
			n->Configure(args.GetObject(0));

		result->SetObject(n);
	}
	void HTTPClientBinding::Send(const ValueList& args, KValueRef result)
	{
		// Get send data if provided
		args.VerifyException("send", "?s|o|0");
		KValueRef sendData(args.GetValue(0));

		// Setup output stream for data
		this->outstream = new std::ostringstream(std::ios::binary | std::ios::out);
		result->SetBool(this->BeginRequest(sendData));
	}
	void HTTPClientBinding::Receive(const ValueList& args, KValueRef result)
	{
		args.VerifyException("receive", "m|o ?s|o|0");

		// Set output handler
		this->outstream = 0;
		result->SetBool(false);

		if (args.at(0)->IsMethod())
		{
			this->outputHandler = args.at(0)->ToMethod();
		}
		else if (args.at(0)->IsObject())
		{
			KObjectRef handlerObject(args.at(0)->ToObject());
			KMethodRef writeMethod(handlerObject->GetMethod("write", 0));
			if (writeMethod.isNull())
			{
				logger->Error("Unsupported object type as output handler:"
					" does not have write method");
			}
			else
			{
				this->outputHandler = writeMethod;
			}
		}
		else
		{
			logger->Error("Invalid type as output handler!");
			return;
		}

		// Get the send data if provided
		KValueRef sendData(args.GetValue(1));
		result->SetBool(this->BeginRequest(sendData));
	}
Exemplo n.º 4
0
	void WorkerContext::_PostMessage(const ValueList &args, KValueRef result)
	{
		worker->SendMessageToMainThread(args.GetValue(0));
	}