Exemplo n.º 1
0
        // get detail of players' HP information in the server
        private void setServerInfo(String serverName)
        {
            memberInServer = new MemberInServer();

            int index = 0;

            foreach (var player in playerSelectHero)
            {
                String name = player.Key;
                member = new Member(name, playerSelectHero[name], playerHeroInfo[name]);
                memberInServer.memberList.Insert(index, member);
                index++;
            }
        }
Exemplo n.º 2
0
        /**
         * Check the connection of every servers in Server Tier
         * **/
        public CheckServer(Dictionary <String, String> serverList)
        {
            playerSelectHero = new Dictionary <String, String>();
            playerHeroInfo   = new Dictionary <String, String>();
            serverState      = new ServerState();
            serverInfo       = new ServerInfo();
            bossInServer     = new List <String>();

            serverCount = 0;
            //run each server
            foreach (var server in serverList)
            {
                DuplexChannelFactory <IDGSerController> DGSer;
                NetTcpBinding tcpBinding = new NetTcpBinding();
                try
                {
                    //connect server
                    DGSer            = new DuplexChannelFactory <IDGSerController>(this, tcpBinding, server.Value);
                    m_DGSer          = DGSer.CreateChannel();
                    playerSelectHero = m_DGSer.GetPlayersHeroName();
                    playerHeroInfo   = m_DGSer.GetPlayersHeroHPInfo();

                    bossInServer.Add(m_DGSer.GetSelectedBossInfo());

                    setServerState(server.Key, true);
                    setServerInfo(server.Key);
                    serverInfo.serverInfoList.Insert(serverCount, memberInServer);
                    serverCount++;
                }
                catch (Exception)//if fail to connect
                {
                    bossInServer.Add("");
                    setServerState(server.Key, false);
                    memberInServer = new MemberInServer();
                    serverInfo.serverInfoList.Insert(serverCount, memberInServer);
                    serverCount++;
                }
            }
        }