Пример #1
0
        private string DoGetFriendIP(string formatString)
        {
            AnalysisStr analy = new AnalysisStr(formatString);
            string      msg   = "Server#" + OpType.FRIEND_IP_RES;

            if (OLList.IsOnLine(analy.GetParaIndexOf(0)))
            {
                msg += "#" + OLList.GetUserByID(analy.GetParaIndexOf(0)).IPAddress;
            }
            return(msg);
        }
Пример #2
0
        //检测函数,检测客户端是否关闭,检测异常关闭以及挂掉
        public void TrueOnLineUsers()
        {
            foreach (string userID in OLList.GetAllOLUsersID())
            {
                if (OLList.IsOnLine(userID))
                {
                    try
                    {
                        CClient client = new CClient(OLList.GetUserByID(userID).IPAddress, OLList.GetUserByID(userID).IPPort);
                        client.ConnectToServer();
                        client.GetNetworkStream();
                        client.Communicate("###");
                        client.ReLeaseAll();
                    }
                    catch (Exception e)
                    {
                        OLList.OffLined(userID);

                        System.Console.WriteLine(userID + "客户端异常关闭,现在在线用户数量:" + OLList.Length());
                    }
                }
            }
        }