t1

server

  

public static void Start() {
        Hashtable ht 
= new Hashtable();
            ht[
"port"= "8899";
            ht[
"name"= "Server";
            ht[
"authorizedGroup"= "Everyone";
            GameService.Messge(
"注册TCP");
            
try {
                TcpChannel channel 
= new TcpChannel(ht, nullnull);
                ChannelServices.RegisterChannel(channel, 
false);
                RemotingConfiguration.RegisterWellKnownServiceType(
typeof(RemoteClient), "ddd", WellKnownObjectMode.SingleCall);
                GameService.Messge(
"注册TCP成功");
            }
            
catch (Exception e) {
                Console.WriteLine(
string.Format(">注册IPC出错:{0}", e.Message));
            }

            
//==========================

        }

 

client

 

  IRemoteClient IRC = (IRemoteClient)Activator.GetObject(typeof(IRemoteClient), string.Format("tcp://{0}:8899/ddd", Config.Default.Service));
            
try {
                Hashtable ht 
= IRC.CheckLogin(textBox1.Text.Trim().ToLower(), textBox2.Text.Trim().ToLower());
                
if (ht == null ) {
                    MessageBox.Show(
"登录失败""提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    
this.button1.Enabled = !this.button1.Enabled;
                    
return;
                }
                           }
            
catch (Exception) {
                MessageBox.Show(
"连接服务器失败""提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }

 

posted @ 2011-05-10 16:24  小小部落  阅读(225)  评论(0编辑  收藏  举报