C# 如何使用WampSharp向特定客户端发送消息?

C# 如何使用WampSharp向特定客户端发送消息?,c#,wamp-protocol,wampsharp,C#,Wamp Protocol,Wampsharp,假设我有3个客户:客户A、客户B和客户C 它们都支持Ping()函数,并使用反射(基于WampSharp文档的代码)注册该函数: 接下来,我在每个客户端上设置了一个代理以进行出站呼叫: DefaultWampChannelFactory channelFactory = new DefaultWampChannelFactory(); IWampChannel channel = channelFactory.CreateJsonChannel("ws://127.0.0.1:8080/", "

假设我有3个客户:客户A、客户B和客户C

它们都支持Ping()函数,并使用反射(基于WampSharp文档的代码)注册该函数:

接下来,我在每个客户端上设置了一个代理以进行出站呼叫:

DefaultWampChannelFactory channelFactory = new DefaultWampChannelFactory();
IWampChannel channel = channelFactory.CreateJsonChannel("ws://127.0.0.1:8080/", "realm1");
Task channelOpenTask = channel.Open();
channelOpenTask.Wait();
IArgumentsService proxy = channel.RealmProxy.Services.GetCalleeProxy<IArgumentsService>();

我猜这会向所有客户广播一条消息?如何仅指定一个客户端?甚至支持这种使用场景吗?

根据WAMP基本配置文件规范,不可能在每个路由器领域多次注册同一过程。以下代码将在注册时产生异常(wamp.error.procedure\u已存在)。
为了达到你想要的东西,考虑注册一个不同的程序URI。这可以通过使用iCallereRegistrationInterceptor来实现。

根据WAMP基本配置文件规范,不可能在每个路由器的域中多次注册同一过程。以下代码将在注册时产生异常(wamp.error.procedure\u已存在)。 为了达到你想要的东西,考虑注册一个不同的程序URI。这可以使用iCaleeRegistrationInterceptor实现

DefaultWampChannelFactory channelFactory = new DefaultWampChannelFactory();
IWampChannel channel = channelFactory.CreateJsonChannel("ws://127.0.0.1:8080/", "realm1");
Task channelOpenTask = channel.Open();
channelOpenTask.Wait();
IArgumentsService proxy = channel.RealmProxy.Services.GetCalleeProxy<IArgumentsService>();
proxy.Ping();