大家来看下这个remoting问题有何解决方案? remoting在internet上面效果不怎么样,你可以做个试验试试看 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我的客户端是client的希望大家能给出自己的想法~~//bow~~ 我的方法是在SERVER上保存每个CLIENT的CALLBACK,然后通过获得接收方的CALLBACK来实现直接通信 现在我按照 lx1920(怀念1919年)的做法在做,但以下问题实在搞不清楚我先建立了一个InfoCenter,然后在里面包括了代理及事件(其实就跟例子里的那个一样),然后我又建立了一个InfoServices:public class InfoServices: MarshalByRefObject { //public event BroadcastEventHandler Broadcaster; public static Hashtable roomBroadCast = new Hashtable(); static InfoServices() { Console.WriteLine("I'm Constructing..."); roomBroadCast["room1"]=new InfoCenter(); roomBroadCast["room2"]=new InfoCenter(); //roomBroad["room1"]= // // TODO: 在此处添加构造函数逻辑 // } }在里面我用HASHTABLE静态构造了两个InfoCenter,随后我将Server.exe.config配置为SingleCall,在receiver1里,我通过以下方式获得InfoCenter:RemotingConfiguration.Configure("Receiver1.exe.config"); InfoCenter there=(InfoCenter)InfoServices.roomBroadCast["room1"];//转型 string s2; there.Broadcaster+= new BroadcastEventHandler(this.BroadcastReceiver); //订阅信息 Console.WriteLine("Ready to Recieve Message..."); for(int k=0;k<3;k++) { s2=Console.ReadLine(); there.Broadcasting(s2); }//发送消息 Console.ReadLine(); //取消订阅 there.Broadcaster-= new BroadcastEventHandler(this.BroadcastReceiver);同样在另外一个receiver2里我也如此做,只不过hashtable的key换成了"room2"所有的配置文件照常未更动:<configuration> <system.runtime.remoting> <application> <client> <wellknown type="PokerRemoting.InfoCenter, InfoCenter" url="http://localhost:8080/Broadcast"/> </client> <channels> <channel ref="http" port="0"/> </channels> </application> </system.runtime.remoting></configuration>(以上是接收器的配置文件)<configuration> <system.runtime.remoting> <application> <service> <wellknown mode="SingleCall" type="PokerRemoting.InfoCenter, InfoCenter" objectUri="Broadcast"/> </service> <channels> <channel ref="http" port="8080"/> </channels> </application> </system.runtime.remoting></configuration>(这个是Server的配置文件)现在开始调用,问题出来了虽然现在1跟2的确是互相没关系了但我每次通过receiver发消息,server上就显示新建立了一个InfoCenter,并且消息没有办法发布出去。而用Singleton的mode时候,虽然上面问题解决,但1跟2又混在了一起,也就是说两个聊天室又串了~~真是搞不懂了,拜托各位高人指点迷津!!必定重酬!! 最近刚好有人要我写个remoting的聊天例子给他,是vb.net的,有兴趣就到我的PC上下载吧:http://218.19.97.36/temp/remoting.zip 不用谢,现在用.net的人不多,用.net做remoting的更少,所以更应该互相扶持 c#反射工厂的应用 [饭后]大家觉得.net技术是属于慢热型技术还是属于半死不活随时会被更厉害的技术取代? dll反编译成mdb 多页纸扫描在一个.tif文件里,vs.net里面用PictureBox只能显示第一页,怎么显示其它页呢? 关于异常处理的几个问题,大分相赠! aspx不支持 <%%> Repeater日期列如何实现短日期? 与条形码读取器结合的编程,求教 如何在Vs2005中创建数据库 水晶报表编译怎么通过不了? 如何让 OpenFileDialog 只显示目录,而不显示文件,或为达到这功能用其它什么控件? c#中的用Remoting技术时,如何调试类模块?
public class InfoServices: MarshalByRefObject
{
//public event BroadcastEventHandler Broadcaster; public static Hashtable roomBroadCast = new Hashtable();
static InfoServices()
{
Console.WriteLine("I'm Constructing...");
roomBroadCast["room1"]=new InfoCenter();
roomBroadCast["room2"]=new InfoCenter();
//roomBroad["room1"]=
//
// TODO: 在此处添加构造函数逻辑
//
}
}在里面我用HASHTABLE静态构造了两个InfoCenter,
随后我将Server.exe.config配置为SingleCall,在receiver1里,我通过以下方式获得InfoCenter:RemotingConfiguration.Configure("Receiver1.exe.config"); InfoCenter there=(InfoCenter)InfoServices.roomBroadCast["room1"];//转型 string s2;
there.Broadcaster+= new BroadcastEventHandler(this.BroadcastReceiver); //订阅信息 Console.WriteLine("Ready to Recieve Message...");
for(int k=0;k<3;k++)
{
s2=Console.ReadLine();
there.Broadcasting(s2);
}//发送消息 Console.ReadLine(); //取消订阅
there.Broadcaster-= new BroadcastEventHandler(this.BroadcastReceiver);同样在另外一个receiver2里我也如此做,只不过hashtable的key换成了"room2"
所有的配置文件照常未更动:
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown type="PokerRemoting.InfoCenter, InfoCenter" url="http://localhost:8080/Broadcast"/>
</client>
<channels>
<channel ref="http" port="0"/>
</channels>
</application>
</system.runtime.remoting>
</configuration>
(以上是接收器的配置文件)<configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown mode="SingleCall" type="PokerRemoting.InfoCenter, InfoCenter" objectUri="Broadcast"/>
</service>
<channels>
<channel ref="http" port="8080"/>
</channels>
</application>
</system.runtime.remoting>
</configuration>
(这个是Server的配置文件)现在开始调用,问题出来了
虽然现在1跟2的确是互相没关系了
但我每次通过receiver发消息,server上就显示新建立了一个InfoCenter,并且消息没有办法发布出去。
而用Singleton的mode时候,虽然上面问题解决,但1跟2又混在了一起,也就是说两个聊天室又串了~~真是搞不懂了,拜托各位高人指点迷津!!必定重酬!!
http://218.19.97.36/temp/remoting.zip