public static void foo() { RpcTcpServerChannel channel = new RpcTcpServerChannel(8000); channel.TransactionCreated += new Action <RpcServerTransaction>(channel_TransactionCreated); RpcServiceManager.RegisterServerChannel(channel); RpcServiceManager.RegisterRawService(new RpcRouteService()); }
static void Initialize() { RpcTcpServerChannel channel = new RpcTcpServerChannel(8888); RpcDuplexServer server = new RpcDuplexServer(channel); // // 如果Session没有建立成功,如果发起非注册的信令,直接断开连接 server.BeforeTransactionCreated += new Action <RpcServerTransaction>( delegate(RpcServerTransaction tx) { if (tx.Connection.Contexts["session"] == null) { if (tx.Request.ServiceDotMethod != "DuplexDemoService.Register") { tx.Connection.Disconnect(); } } } ); }