You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
859 B

  1. package rpctypes
  2. type RPCRequest struct {
  3. JSONRPC string `json:"jsonrpc"`
  4. Method string `json:"method"`
  5. Params []interface{} `json:"params"`
  6. Id int `json:"id"`
  7. }
  8. type RPCResponse struct {
  9. Result interface{} `json:"result"`
  10. Error string `json:"error"`
  11. Id string `json:"id"`
  12. JSONRPC string `json:"jsonrpc"`
  13. }
  14. func NewRPCResponse(res interface{}, err string) RPCResponse {
  15. if res == nil {
  16. res = struct{}{}
  17. }
  18. return RPCResponse{
  19. Result: res,
  20. Error: err,
  21. Id: "",
  22. JSONRPC: "2.0",
  23. }
  24. }
  25. // for requests coming in
  26. type WSRequest struct {
  27. Type string `json:"type"` // subscribe or unsubscribe
  28. Event string `json:"event"`
  29. }
  30. // for responses going out
  31. type WSResponse struct {
  32. Event string `json:"event"`
  33. Data interface{} `json:"data"`
  34. Error string `json:"error"`
  35. }