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)
                    { }
                }
            }
        }
Пример #2
0
 public virtual byte[] Execute(IRpcClientInfo client, byte[] input)
 {
     RpcServerApi.RpcExecuteHandler rpcExecuteHandler = this._handler;
     if (rpcExecuteHandler != null)
     {
         return(rpcExecuteHandler(client, input));
     }
     return((byte[])null);
 }
Пример #3
0
 public void Dispose()
 {
     this._handler = (RpcServerApi.RpcExecuteHandler)null;
     this.StopListening();
     this._handle.Dispose();
 }