Skip to content

Instantly share code, notes, and snippets.

@brannondorsey
Created May 18, 2014 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brannondorsey/176a6e1d8126ff78ef96 to your computer and use it in GitHub Desktop.
Save brannondorsey/176a6e1d8126ff78ef96 to your computer and use it in GitHub Desktop.

main.js:

var data = {
    foo: "bar",
    val: $('#text-to-send').val()
}

$('#set-text').on('click', function() {
        var $this = $(this);
        JSONRPCClient.call('set-text', 
            data,
            function(result) {
                console.log(result);
            },
            function(error) {
                addError(error);
            });
    });

I have also tried with true JSON:

var data = {
    "foo": "bar",
    "val": $('#text-to-send').val()
}

ofApp.cpp:

void ofApp::setText(JSONRPC::MethodArgs& args)
{
    // Set the user text.
    userText = args.params.asString();
    cout<<userText<<endl;
}

Error:

[ error ] ServerWebSocketRouteHandler::handleRequest: exception: Type is not convertible to string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment