changed: server stopping, dial/listen to tcp dial/listen, json rpc encoding to msgpack, info getters for logging ; added keepalive setter to server, etc

This commit is contained in:
2022-07-26 14:26:40 +02:00
parent cddeee1412
commit f76cbc32aa
17 changed files with 268 additions and 97 deletions

View File

@@ -8,12 +8,13 @@ package dsrpc
import (
"encoding/json"
encoder "github.com/vmihailenco/msgpack/v5"
)
type Request struct {
Method string `json:"method" msgpack:"method"`
Params any `json:"params,omitempty" msgpack:"params,omitempty"`
Auth *Auth `json:"auth,omitempty" msgpack:"auth,omitempty"`
Method string `json:"method" msgpack:"method"`
Params any `json:"params,omitempty" msgpack:"params"`
Auth *Auth `json:"auth,omitempty" msgpack:"auth"`
}
func NewRequest() *Request {
@@ -22,12 +23,12 @@ func NewRequest() *Request {
return req
}
func (this *Request) Pack() ([]byte, error) {
rBytes, err := json.Marshal(this)
func (req *Request) Pack() ([]byte, error) {
rBytes, err := encoder.Marshal(req)
return rBytes, Err(err)
}
func (this *Request) JSON() []byte {
jBytes, _ := json.Marshal(this)
func (req *Request) JSON() []byte {
jBytes, _ := json.Marshal(req)
return jBytes
}