/// <summary> /// Add an RPC call to the manager /// </summary> /// <param name="callName">What the name of the call should be, this is the name that will be parsed out of the command line.</param> /// <param name="nativeCode">The native code to execute when this RPC command is executed.</param> /// <param name="securityLevel">The security level of this call.</param> /// <returns>True if the new call could be added.</returns> public bool AddRPCCall(string callName, RPCNativeCall nativeCode, RPCSecurityLevel securityLevel) { if (cmdTable.ContainsKey(callName)) { return(false); } cmdTable.Add(callName, new RPCTableEntry(nativeCode, securityLevel)); return(true); }
/// <summary> /// Processes a command line as an RPC command. /// </summary> /// <param name="command">The command line to execute.</param> /// <param name="securityLevel">The security level to process it with.</param> /// <returns>True if the process could be processed, false otherwise.</returns> public virtual bool ProcessCommand(string command, RPCSecurityLevel securityLevel) { RPCCommandInfo commandInfo = ExtractCommand(command); if (!commandInfo.IsValid) { return(false); } if (commandInfo.Destination != localName) { return(false); } if (!cmdTable.ContainsKey(commandInfo.Name)) { return(false); } RPCTableEntry entry = cmdTable[commandInfo.Name]; if (securityLevel < entry.Security) { return(false); } try { entry.Invoke(commandInfo.Args); } catch { return(false); } return(true); }
public NativeRPC(RPCSecurityLevel security) { this.security = security; }
public RPCTableEntry(RPCNativeCall nativeCall, RPCSecurityLevel securityLevel) { this.securityLevel = securityLevel; this.NativeCode += nativeCall; }