public void TestUnregisterListener() { Guid iid = Guid.NewGuid(); using (RpcServerApi server = new RpcServerApi(iid)) { server.AddProtocol(RpcProtseq.ncalrpc, "lrpctest", 5); server.AddAuthentication(RpcAuthentication.RPC_C_AUTHN_WINNT); server.StartListening(); RpcServerApi.RpcExecuteHandler handler = delegate(IRpcClientInfo client, byte[] arg) { return(arg); }; using (RpcClientApi client = new RpcClientApi(iid, RpcProtseq.ncalrpc, null, "lrpctest")) { client.AuthenticateAs(null, RpcClientApi.Self, RpcProtectionLevel.RPC_C_PROTECT_LEVEL_PKT_PRIVACY, RpcAuthentication.RPC_C_AUTHN_WINNT); server.OnExecute += handler; client.Execute(new byte[0]); server.OnExecute -= handler; try { client.Execute(new byte[0]); Assert.Fail(); } catch (RpcException) { } } } }
public virtual byte[] Execute(IRpcClientInfo client, byte[] input) { RpcServerApi.RpcExecuteHandler rpcExecuteHandler = this._handler; if (rpcExecuteHandler != null) { return(rpcExecuteHandler(client, input)); } return((byte[])null); }
public void Dispose() { this._handler = (RpcServerApi.RpcExecuteHandler)null; this.StopListening(); this._handle.Dispose(); }