示例#1
0
        /// <summary>
        /// 处理管理主机消息
        /// </summary>
        /// <param name="peer">消息来源主机</param>
        /// <param name="msg">消息</param>
        private static void ServerMessage(Peer peer, Msg msg)
        {
            switch (msg.type)
            {
            case 11:
                HostInfo info = msg.data as HostInfo;
                peer.info.id = info.id;
                ResHost curHost = HostManager.Singleton[info.id.ToString()];
                if (curHost == null)
                {
                    return;
                }
                curHost.rGroup(info.groups);
                curHost.searchService = info.SearchService;
                HoldingServer.Singleton.UpdateServices(HostGroup.getServices(HoldingServer.Self));
                Group.send(new Msg(13));
                break;

            case 12:
                peer.send(new Msg(13, HostGroup.getServices(msg.data as string[])));
                break;

            case 22:
                peer.send(new Msg(21, HoldingServer.Client.remote));
                break;
            }
        }
示例#2
0
 /// <summary>
 /// HoldingServer初始化
 /// </summary>
 public HoldingServer()
 {
     singleton = this;
     self      = new ResHost(new IPEndPoint(Functions.SelfIP, Configuration.Port), Dns.GetHostName());
     self.rGroup(Configuration.Groups);
     self.searchService = Functions.SearchService;
     lis            = new Listener(Configuration.Port);
     lis.onAccept  += new AcceptHandler(lis_onAccept);
     lis.onReceive += MessageDealer.UDPReceive;
     server         = new ServerObject();
     client         = new ClientObject();
     remoteAddress  = Functions.RemoteIP;
     selfAddress    = Functions.SelfIP;
     state          = 0;
 }
示例#3
0
 /// <summary>
 /// HoldingServer初始化
 /// </summary>
 public HoldingServer()
 {
     singleton = this;
     self = new ResHost(new IPEndPoint(Functions.SelfIP, Configuration.Port), Dns.GetHostName());
     self.rGroup(Configuration.Groups);
     self.searchService = Functions.SearchService;
     lis = new Listener(Configuration.Port);
     lis.onAccept += new AcceptHandler(lis_onAccept);
     lis.onReceive += MessageDealer.UDPReceive;
     server = new ServerObject();
     client = new ClientObject();
     remoteAddress = Functions.RemoteIP;
     selfAddress = Functions.SelfIP;
     state = 0;
 }
示例#4
0
 /// <summary>
 /// 处理主机断开
 /// </summary>
 /// <param name="peer">断开的主机</param>
 public static void onPeerQuit(Peer peer)
 {
     if (HoldingServer.State == 1)
     {
         if (peer.info.id == null)
         {
             return;
         }
         ResHost rh = HostManager.Singleton[peer.info.id.ToString()];
         if (rh != null)
         {
             rh.rGroup(new string[0]);
         }
     }
     else if (peer == HoldingServer.Client.server)
     {
         HoldingServer.Start(false);
     }
 }