chowey / jsonrpc

Standards-compliant JSON-RPC for go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide a mechanism to do JSON-RPC over any arbitrary reader/writer

chowey opened this issue · comments

It should be simple to add a function like this:

h.ServeConn(ctx, rwc)

so that JSON-RPC could be served over any io.ReadWriteCloser. This would allow JSON-RPC to work over e.g. websockets or a hijacked HTTP connection or even raw TCP, with proper adapters.

Some requirements:

  • rwc.Write() should send a full JSON message in one write. This would make us easily compatible with websocket libraries which should send a full message in one websocket frame.
  • rwc.Write() should be protected by a mutex. Only one write at a time.

Fixed with 0bda81d.