Example #1
0
 public int GetOnlineHumCount()
 {
     int result = 0;
     int I;
     int nCount;
     TMsgServerInfo MsgServer;
     try
     {
         nCount = 0;
         for (I = 0; I < m_ServerList.Count; I++)
         {
             MsgServer = m_ServerList[I];
             if (MsgServer.nServerIndex != 99)
             {
                 nCount += MsgServer.nOnlineCount;
             }
         }
         result = nCount;
     }
     catch
     {
         LSShare.MainOutMessage("TFrmMasSoc.GetOnlineHumCount");
     }
     return result;
 }
Example #2
0
 public void SendServerMsg(ushort wIdent, string sServerName, string sMsg)
 {
     int I;
     TMsgServerInfo MsgServer;
     string sSendMsg;
     string s18;
     const string sFormatMsg = "({0}/{1})";
     try
     {
         s18 = LimitName(sServerName);
         sSendMsg = string.Format(sFormatMsg, new string[] { wIdent.ToString(), sMsg });
         for (I = 0; I < m_ServerList.Count; I++)
         {
             MsgServer = m_ServerList[I];
             if (MsgServer.Socket.Socket.Connected)
             {
                 if ((s18 == "") || (MsgServer.sServerName == "") || ((MsgServer.sServerName).ToLower().CompareTo((s18).ToLower()) == 0) || (MsgServer.nServerIndex == 99))
                 {
                     MsgServer.Socket.Socket.Send(Encoding.Default.GetBytes(sSendMsg));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.StackTrace);
         LSShare.MainOutMessage("TFrmMasSoc.SendServerMsg");
     }
 }
Example #3
0
 private void RefServerLimit(string sServerName)
 {
     int I;
     int nCount;
     TMsgServerInfo MsgServer;
     try
     {
         nCount = 0;
         for (I = 0; I < m_ServerList.Count; I++)
         {
             MsgServer = m_ServerList[I];
             if ((MsgServer.nServerIndex != 99) && (MsgServer.sServerName == sServerName))
             {
                 nCount += MsgServer.nOnlineCount;
             }
         }
         for (I = UserLimit.GetLowerBound(0); I <= UserLimit.GetUpperBound(0); I++)
         {
             if ((UserLimit[I].sServerName).ToLower().CompareTo((sServerName).ToLower()) == 0)
             {
                 UserLimit[I].nLimitCountMin = nCount;
                 break;
             }
         }
     }
     catch
     {
         LSShare.MainOutMessage("TFrmMasSoc.RefServerLimit");
     }
 }
Example #4
0
 private void MSocket_OnClientConnect(object sender, AsyncSockets.AsyncUserToken e)
 {
     int I;
     string sRemoteAddr;
     bool boAllowed;
     TMsgServerInfo MsgServer;
     if (TFrmMain.Colsed) return;
     sRemoteAddr = e.EndPoint.Address.ToString();// Socket.RemoteAddress;
     boAllowed = false;
     for (I = LSShare.ServerAddr.GetLowerBound(0); I <= LSShare.ServerAddr.GetUpperBound(0); I++)
     {
         if (sRemoteAddr == LSShare.ServerAddr[I])
         {
             boAllowed = true;
             break;
         }
     }
     if (boAllowed)
     {
         MsgServer = new TMsgServerInfo();
         MsgServer.sServerName = "";
         MsgServer.sReceiveMsg = "";
         MsgServer.Socket = e;
         MsgServer.sIPaddr = e.EndPoint.Address.ToString() + ":" + e.EndPoint.Port;
         m_ServerList.Add(MsgServer);
     }
     else
     {
         LSShare.MainOutMessage("非法地址连接:" + sRemoteAddr);
         e.Socket.Close();
     }
 }
Example #5
0
 private string LimitName(string sServerName)
 {
     string result = string.Empty;
     int I;
     try
     {
         result = "";
         for (I = UserLimit.GetLowerBound(0); I <= UserLimit.GetUpperBound(0); I++)
         {
             if ((UserLimit[I].sServerName).ToLower().CompareTo((sServerName).ToLower()) == 0)
             {
                 result = UserLimit[I].sName;
                 break;
             }
         }
     }
     catch
     {
         LSShare.MainOutMessage("TFrmMasSoc.LimitName");
     }
     return result;
 }
Example #6
0
 public void SendServerMsgA(ushort wIdent, string sMsg)
 {
     int I;
     string sSendMsg;
     TMsgServerInfo MsgServer;
     const string sFormatMsg = "({0}/{1}/{2})";
     try
     {
         sSendMsg = string.Format(sFormatMsg, new string[] { wIdent.ToString(), sMsg, "游戏中心" });
         for (I = 0; I < m_ServerList.Count; I++)
         {
             MsgServer = m_ServerList[I];
             if (MsgServer.Socket.Socket.Connected)
             {
                 MsgServer.Socket.Socket.Send(Encoding.Default.GetBytes(sSendMsg));
             }
         }
     }
     catch (Exception e)
     {
         LSShare.MainOutMessage("TFrmMasSoc.SendServerMsgA");
         LSShare.MainOutMessage(e.Message);
     }
 }
Example #7
0
        public void Execute()
        {
            int     I;
            uint    dwTick2C;
            string  s18 = string.Empty;
            string  s1C = string.Empty;
            string  s24 = string.Empty;
            string  s28 = string.Empty;
            int     nC;
            int     n10;
            int     n14;
            TConfig Config;

            Config   = LSShare.g_Config;
            dwTick2C = 0;
            while (true)
            {
                if ((HUtil32.GetTickCount() - dwTick2C) > 5 * 60 * 1000)
                {
                    dwTick2C = HUtil32.GetTickCount();
                    try
                    {
                        if (File.Exists(Config.sFeedIDList))
                        {
                            AccountLoadList.Clear();
                            AccountLoadList.LoadFromFile(Config.sFeedIDList);
                            if (AccountLoadList.Count > 0)
                            {
                                AccountCostList.Clear();
                                for (I = 0; I < AccountLoadList.Count; I++)
                                {
                                    s18 = AccountLoadList[I].Trim();
                                    s18 = HUtil32.GetValidStr3(s18, ref s1C, new string[] { " ", "\t" });
                                    s18 = HUtil32.GetValidStr3(s18, ref s24, new string[] { " ", "\t" });
                                    s18 = HUtil32.GetValidStr3(s18, ref s28, new string[] { " ", "\t" });
                                    n10 = HUtil32.Str_ToInt(s24, 0);
                                    n14 = HUtil32.Str_ToInt(s28, 0);
                                    nC  = HUtil32.MakeLong(HUtil32._MAX(n14, 0), HUtil32._MAX(n10, 0));
                                    AccountCostList.Add(s1C, nC);
                                    if (!bo40)
                                    {
                                        if ((I % 100) == 0)
                                        {
                                            Thread.Sleep(1);
                                        }
                                    }
                                }
                            }

                            //LoadAccountCostList(Config, AccountCostList);
                        }
                    }
                    catch
                    {
                        LSShare.MainOutMessage("Exception] loading on IDStrList.");
                    }
                    try
                    {
                        if (File.Exists(Config.sFeedIPList))
                        {
                            IPaddrLoadList.Clear();
                            IPaddrLoadList.LoadFromFile(Config.sFeedIPList);
                            if (IPaddrLoadList.Count > 0)
                            {
                                IPaddrCostList.Clear();
                                for (I = 0; I < IPaddrLoadList.Count; I++)
                                {
                                    s18 = IPaddrLoadList[I].Trim();
                                    s18 = HUtil32.GetValidStr3(s18, ref s1C, new string[] { " ", "\t" });
                                    s18 = HUtil32.GetValidStr3(s18, ref s24, new string[] { " ", "\t" });
                                    s18 = HUtil32.GetValidStr3(s18, ref s28, new string[] { " ", "\t" });
                                    n10 = HUtil32.Str_ToInt(s24, 0);
                                    n14 = HUtil32.Str_ToInt(s28, 0);

                                    //@ Unsupported function or procedure: 'MakeLong'
                                    nC = HUtil32.MakeLong(HUtil32._MAX(n14, 0), HUtil32._MAX(n10, 0));
                                    IPaddrCostList.Add(s1C, nC);
                                    if (!bo40)
                                    {
                                        if ((I % 100) == 0)
                                        {
                                            Thread.Sleep(1);
                                        }
                                    }
                                }
                            }

                            //LoadIPaddrCostList(Config, IPaddrCostList);
                        }
                    }
                    catch
                    {
                        LSShare.MainOutMessage("Exception] loading on IPStrList.");
                    }
                }
                Thread.Sleep(10);

                //@ Unsupported property or method(C): 'Terminated'
                //if (this.Terminated)
                //{
                //    break;
                //}
            }
        }
Example #8
0
        public int ServerStatus(string sServerName)
        {
            int result = 0;
            int I;
            int nStatus = 0;
            TMsgServerInfo MsgServer;
            bool boServerOnLine;
            try
            {
                result = 0;
                boServerOnLine = false;
                for (I = 0; I < m_ServerList.Count; I++)
                {
                    MsgServer = m_ServerList[I];
                    if ((MsgServer.nServerIndex != 99) && (MsgServer.sServerName == sServerName))
                    {
                        boServerOnLine = true;
                    }
                }
                if (!boServerOnLine)
                {
                    return result;
                }
                for (I = UserLimit.GetLowerBound(0); I <= UserLimit.GetUpperBound(0); I++)
                {
                    if (UserLimit[I].sServerName == sServerName)
                    {
                        if (UserLimit[I].nLimitCountMin <= UserLimit[I].nLimitCountMax / 2)
                        {
                            nStatus = 1;

                            // 空闲
                            break;
                        }
                        if (UserLimit[I].nLimitCountMin <= UserLimit[I].nLimitCountMax - (UserLimit[I].nLimitCountMax / 5))
                        {
                            nStatus = 2;

                            // 良好
                            break;
                        }
                        if (UserLimit[I].nLimitCountMin < UserLimit[I].nLimitCountMax)
                        {
                            nStatus = 3;

                            // 繁忙
                            break;
                        }
                        if (UserLimit[I].nLimitCountMin >= UserLimit[I].nLimitCountMax)
                        {
                            nStatus = 4;

                            // 满员
                            break;
                        }
                    }
                }
                result = nStatus;
            }
            catch
            {
                LSShare.MainOutMessage("TFrmMasSoc.ServerStatus");
            }
            return result;
        }
Example #9
0
 private void SortServerList(int nIndex)
 {
     int nC;
     int n10;
     int n14;
     TMsgServerInfo MsgServerSort;
     TMsgServerInfo MsgServer;
     int nNewIndex;
     try
     {
         if (m_ServerList.Count <= nIndex)
         {
             return;
         }
         MsgServerSort = m_ServerList[nIndex];
         m_ServerList.RemoveAt(nIndex);
         for (nC = 0; nC < m_ServerList.Count; nC++)
         {
             MsgServer = m_ServerList[nC];
             if (MsgServer.sServerName == MsgServerSort.sServerName)
             {
                 if (MsgServer.nServerIndex < MsgServerSort.nServerIndex)
                 {
                     m_ServerList.Insert(nC, MsgServerSort);
                     return;
                 }
                 else
                 {
                     nNewIndex = nC + 1;
                     if (nNewIndex < m_ServerList.Count)
                     {
                         // Jacky 增加
                         for (n10 = nNewIndex; n10 < m_ServerList.Count; n10++)
                         {
                             MsgServer = m_ServerList[n10];
                             if (MsgServer.sServerName == MsgServerSort.sServerName)
                             {
                                 if (MsgServer.nServerIndex < MsgServerSort.nServerIndex)
                                 {
                                     m_ServerList.Insert(n10, MsgServerSort);
                                     for (n14 = n10 + 1; n14 < m_ServerList.Count; n14++)
                                     {
                                         MsgServer = m_ServerList[n14];
                                         if ((MsgServer.sServerName == MsgServerSort.sServerName) && (MsgServer.nServerIndex == MsgServerSort.nServerIndex))
                                         {
                                             m_ServerList.RemoveAt(n14);
                                             return;
                                         }
                                     }
                                     return;
                                 }
                                 else
                                 {
                                     nNewIndex = n10 + 1;
                                 }
                             }
                         }
                         m_ServerList.Insert(nNewIndex, MsgServerSort);
                         return;
                     }
                 }
             }
         }
         m_ServerList.Add(MsgServerSort);
     }
     catch
     {
         LSShare.MainOutMessage("TFrmMasSoc.SortServerList");
     }
 }