remoting在internet上面效果不怎么样,你可以做个试验试试看

解决方案 »

  1.   

    我的客户端是client的希望大家能给出自己的想法~~//bow~~
      

  2.   

    我的方法是在SERVER上保存每个CLIENT的CALLBACK,然后通过获得接收方的CALLBACK来实现直接通信
      

  3.   

    现在我按照 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又混在了一起,也就是说两个聊天室又串了~~真是搞不懂了,拜托各位高人指点迷津!!必定重酬!!
      

  4.   

    最近刚好有人要我写个remoting的聊天例子给他,是vb.net的,有兴趣就到我的PC上下载吧:
    http://218.19.97.36/temp/remoting.zip
      

  5.   

    不用谢,现在用.net的人不多,用.net做remoting的更少,所以更应该互相扶持