@@ -21,7 +21,6 @@ function RPC(_socket) constructor {
2121 network.sendData (_data, _socket);
2222 }
2323 // / @function sendRequest()
24- // /
2524 // / @description
2625 // / Function to send requests by invoking the specified method with the given parameters
2726 // / over the provided socket. Allows handling both successful results and errors through callbacks.
@@ -41,12 +40,27 @@ function RPC(_socket) constructor {
4140 requests.setElement (_id, _request);
4241 return _request;
4342 }
43+ // / @function sendNotification()
44+ // / @description
45+ // / Sends a notification with the specified method and parameters over the given socket.
46+ // /
47+ // / @param {String} method - Name of the method to be invoked.
48+ // / @param {Struct|Array} params - Parameters to be used in the notification.
49+ // / @param {Function} socket - Socket to which the notification will be sent.
4450 static sendNotification = function (_method, _params, _socket = socket) {
4551 sendJSON ({
4652 " method" : _method,
4753 " params" : _params
4854 }, _socket);
4955 }
56+ // / @function sendError()
57+ // / @description
58+ // / Sends an error with the specified code, message, and ID over the given socket.
59+ // /
60+ // / @param {Real} code - Error code.
61+ // / @param {string} message - Error message.
62+ // / @param {Real} id - ID associated with the error.
63+ // / @param {Function} socket - Socket to which the error will be sent.
5064 static sendError = function (_code, _message, _id, _socket) {
5165 sendJSON ({
5266 " error" : {
@@ -128,6 +142,13 @@ function RPC(_socket) constructor {
128142 requests.removeElement (_id);
129143 }
130144 }
145+ // / @function registerHandler()
146+ // / @description
147+ // / Registers a Remote Procedure Call (RPC) handler with the specified name and method.
148+ // / This function allows associating a method with a unique name for later invocation.
149+ // /
150+ // / @param {String} name - The name associated with the RPC handler.
151+ // / @param {Function} method - The method to be registered as the RPC handler.
131152 static registerHandler = function (_name, _method) {
132153 handlers[$ _name] = _method;
133154 }
0 commit comments