serviceId, methodName, and string inputs. callMethod does not execute real code; it returns an output string computed using the rules below.
RPC (Remote Procedure Call) is a way for one program to call a function/method in another program over a network as if it were a local call.
The RPC framework handles things like serialization (marshalling), networking, and response/error handling behind the scenes.
(serviceId, methodName) with its parameter types.
serviceId is between 1 and 1000.methodName contains only a-z.inputParameterTypes is exactly one of: "String", "Long", "Double".inputParameterTypes.size() will always be between 1 and 20.true if the method existed and was removed. Otherwise returns false. After removal, a method cannot be called unless registered again.
1 and 100."method does not exist"inputValues.size() != registered parameter count: return "input size mismatch"inputValues[i] (0-based index) cannot be parsed into its expected type: return "invalid input parameter at index " + ii (0-based), append a piece and a trailing hyphen. After preparing complete output, remove the final trailing hyphen:
"String": append (i+1) + "-" + inputValues[i] + "-""Long": parse to long v, append ((i+1) * serviceId * v) + "-""Double": parse to double d, compute x = (i+1) * serviceId * 2 * d, append ((int)x) + "-"4.67 -> 4).
registerMethod(3, "sum", ["String","Long","Double"])
callMethod(3, "sum", ["ab", "10", "4.2"])
Output building:
i=0 String: "1-ab-"
i=1 Long: (2*3*10)=60 => "60-"
i=2 Double: (3*3*2*4.2)=75.6, (int)=75 => "75-"
returns: 1-ab-60-75
callMethod(3, "missing", ["x"])
returns: method does not exist
callMethod(3, "sum", ["ab", "10"])
returns: input size mismatch
callMethod(3, "sum", ["ab", "notALong", "4.2"])
returns: invalid input parameter at index 1
unregisterMethod(3, "sum") // returns true
callMethod(3, "sum", ["ab", "10", "4.2"])
returns: method does not exist
registerMethod(3, "sum", ["Long"]) // overwrites previous signature
callMethod(3, "sum", ["7"])
i=0 Long: (1*3*7)=21
returns: 21