From 708d5844d3ef52e2e61f90f7c5bad374b6916889 Mon Sep 17 00:00:00 2001
From: a <a@a.a>
Date: Sat, 17 Sep 2022 20:07:44 -0500
Subject: [PATCH] ok

---
 client.go | 53 ++++++++++++++++++++++-------------------------------
 server.go |  4 ++--
 2 files changed, 24 insertions(+), 33 deletions(-)

diff --git a/client.go b/client.go
index c431c9a..22fc7c2 100644
--- a/client.go
+++ b/client.go
@@ -100,6 +100,10 @@ type Client struct {
 	reqTimeout  chan *requestOp  // removes response IDs when call timeout expires
 }
 
+func (c *Client) Router() Router {
+	return c.r
+}
+
 type reconnectFunc func(ctx context.Context) (ServerCodec, error)
 
 type clientContextKey struct{}
@@ -292,16 +296,16 @@ func (c *Client) call(ctx context.Context, result any, msg *jsonrpcMessage) erro
 	}
 }
 
-func (c *Client) CallP(result any, method string, param any) error {
+// Do performs a JSON-RPC call with the given arguments and unmarshals into
+// result if no error occurred.
+//
+// The result must be a pointer so that package json can unmarshal into it. You
+// can also pass nil, in which case the result is ignored.
+func (c *Client) Do(result any, method string, param any) error {
 	ctx := context.Background()
-	return c.CallPContext(ctx, result, method, param)
+	return c.DoContext(ctx, result, method, param)
 }
-
-// CallPContext is call except it uh uses a param instead of the variadic args
-// TODO: we should probably rewrite Call and CallContext to just call CallP and CallPContext
-//
-//	i havent done this because i want to make sure that callp and callpcontext work
-func (c *Client) CallPContext(ctx context.Context, result any, method string, param any) error {
+func (c *Client) DoContext(ctx context.Context, result any, method string, param any) error {
 	if result != nil && reflect.TypeOf(result).Kind() != reflect.Ptr {
 		return fmt.Errorf("call result parameter must be pointer or nil interface: %v", result)
 	}
@@ -312,31 +316,14 @@ func (c *Client) CallPContext(ctx context.Context, result any, method string, pa
 	return c.call(ctx, result, msg)
 }
 
-// Call performs a JSON-RPC call with the given arguments and unmarshals into
-// result if no error occurred.
-//
-// The result must be a pointer so that package json can unmarshal into it. You
-// can also pass nil, in which case the result is ignored.
+// Deprecated: use Do
 func (c *Client) Call(result any, method string, args ...any) error {
-	ctx := context.Background()
-	return c.CallContext(ctx, result, method, args...)
+	return c.Do(result, method, args)
 }
 
-// CallContext performs a JSON-RPC call with the given arguments. If the context is
-// canceled before the call has successfully returned, CallContext returns immediately.
-//
-// The result must be a pointer so that package json can unmarshal into it. You
-// can also pass nil, in which case the result is ignored.
+// Deprecated: use DoContext
 func (c *Client) CallContext(ctx context.Context, result any, method string, args ...any) error {
-	if result != nil && reflect.TypeOf(result).Kind() != reflect.Ptr {
-		return fmt.Errorf("call result parameter must be pointer or nil interface: %v", result)
-	}
-	msg, err := c.newMessage(method, args...)
-	if err != nil {
-		return err
-	}
-
-	return c.call(ctx, result, msg)
+	return c.DoContext(ctx, result, method, args)
 }
 
 // BatchCall sends all given requests as a single batch and waits for the server
@@ -411,10 +398,14 @@ func (c *Client) BatchCallContext(ctx context.Context, b []BatchElem) error {
 	return err
 }
 
-// Notify sends a notification, i.e. a method call that doesn't expect a response.
 func (c *Client) Notify(ctx context.Context, method string, args ...any) error {
+	return c.DoNotify(ctx, method, args)
+}
+
+// Notify sends a notification, i.e. a method call that doesn't expect a response.
+func (c *Client) DoNotify(ctx context.Context, method string, args any) error {
 	op := new(requestOp)
-	msg, err := c.newMessage(method, args...)
+	msg, err := c.newMessageP(method, args)
 	if err != nil {
 		return err
 	}
diff --git a/server.go b/server.go
index 99da306..8a8247d 100644
--- a/server.go
+++ b/server.go
@@ -106,13 +106,13 @@ func (s *Server) Stop() {
 	}
 }
 
-// RPCService gives meta information about the server.
+// Deprecated: RPCService gives meta information about the server.
 // e.g. gives information about the loaded modules.
 type RPCService struct {
 	server *Server
 }
 
-// Modules returns the list of RPC services with their version number
+// Deprecated: Modules returns the list of RPC services with their version number
 func (s *RPCService) Modules() map[string]string {
 	modules := make(map[string]string)
 	for _, route := range s.server.services.Routes() {
-- 
GitLab