2

I've got this simple Java server process running as a MessagePack RPC service. I want to invoke the hello() service from Javascript, not Java, but have yet to find an example on how to achieve it. There does not appear to be a RPC implementation for Javascript on the MessagePack site.

import org.msgpack.rpc.Server;
import org.msgpack.rpc.loop.EventLoop;

public class ServerApp {
    public String hello() {
        return "OK";
    }

    public static void main(String[] args) throws Exception {
        EventLoop loop = EventLoop.defaultEventLoop();

        Server svr = new Server();
        svr.serve(new ServerApp()); 
        svr.listen(1985);

        loop.join();
    }
}

UPDATE Found a Javascript RPC client for MessagePack here...

https://github.com/nori0428/msgpack.rpc.js

Kazuki Ohta
  • 1,441
  • 17
  • 17
raffian
  • 31,267
  • 26
  • 103
  • 174

2 Answers2

1

There is a Javascript implementation (and one for node.js as well).

https://github.com/msgpack/msgpack-javascript

Documentation is missing however. You'll need to use the following script:

https://raw.github.com/msgpack/msgpack-javascript/master/msgpack.js

Take a look through that and you'll see the functions that are available. There is also the test directory. Look at the .html files in there for examples of use.

https://github.com/msgpack/msgpack-javascript/tree/master/test

Does it actually work? No idea, I haven't tried it myself. Let us know how it goes.

Bradley Dwyer
  • 8,102
  • 5
  • 32
  • 28
  • 1
    I looked at that, there does not appear to be any RPC functions in that code. The MessagePack clients that offer RPC say so explicitly. I suppose testing won't hurt, as you suggested., thx – raffian Mar 01 '12 at 04:02
  • Ahh. My bad. Completely missed the RPC in the question title - which is dumb. – Bradley Dwyer Mar 01 '12 at 05:49
0

These seem to be (unofficial) JavaScript bindings for MsgPack RPC—they might work (haven't tried them): https://github.com/nori0428/msgpack.rpc.js

HelloGoodbye
  • 3,624
  • 8
  • 42
  • 57