uber-archive / multitransport-jsonrpc

JSON-RPC Client (Node.js & Browser) and Server (Node.js) aim at "natural looking" server and client code.
116 stars 22 forks source link

Use tcp socket inside method #74

Closed lughino closed 8 years ago

lughino commented 8 years ago

Is there a way to use the socket within methods?

example: a user "A" calls a method that sends a message, users connected to "A" should receive the message and if they are connected through socket is also necessary to have the socket.

Is there a way to access it?

dfellis commented 8 years ago

I'm not entirely sure what you're asking for? You want access to the raw socket that's being used by the RPC call?

If that's the case, the answer is basically no for the server: The HTTP Server never exposes the request or response objects and neither does the TCP server.

If you mean from the client perspective you can inspect that only from the TCP client with the this.con property.

lughino commented 8 years ago

I understand that with regard to the server the raw socket http has no use, but the raw socket tcp, always server side, would use if it were available.

Let's take a case like this: real-time application based tcp ..

The last point I can not run it because I can not access the object with the open socket, see this line of code. We can find a way to access that object?

I hope I explained myself better, I apologize for my English.

dfellis commented 8 years ago

Yes. You want a message-passing server, but this is code for a remote procedure call (rpc) server and client.

Even if you had access to that socket, you would still need to significantly refactor the client code as it assumes that the server never initiates an action, and wouldn't know what to do with the forwarded RPC request.

This is not the library you need.