Exemple #1
0
        //发送群组消息,如果在线则提示对方,如果不在线则送到离线数据库
        private void DoSendGroupMsg(string formatString)
        {
            AnalysisStr     analy = new AnalysisStr(formatString);
            DBFunction      dbf   = new DBFunction();
            List <UserInfo> list  = dbf.GetMembersInGroup(int.Parse(analy.GetParaIndexOf(1)));

            list.Add(dbf.GetUserInfo(dbf.GetGroupInfo(int.Parse(analy.GetParaIndexOf(1))).GroupCreator));
            string msg = "Server#" + OpType.SEND_GROUP_MSG_RES + "#" + analy.GetParaIndexOf(0) + "#" + dbf.GetUserInfo(analy.GetParaIndexOf(0)).UserName + "#" + analy.GetParaIndexOf(1) + "#" + analy.GetParaFromIndex(2);

            foreach (UserInfo user in list)
            {
                if (OLList.IsOnLine(user.UserID))
                {
                    SmallUser sUser  = OLList.GetUserByID(user.UserID);
                    CClient   client = new CClient(sUser.IPAddress, sUser.IPPort);
                    try
                    {
                        client.ConnectToServer();
                        client.GetNetworkStream();
                        client.Communicate(msg);
                        client.ReLeaseAll();
                    }
                    catch (Exception e)
                    {
                        System.Console.WriteLine("无法连接用户");
                    }
                }
                else
                {
                    dbf.SendOffLineMessage(user.UserID, analy.GetParaIndexOf(0), analy.GetParaFromIndex(2));
                }
            }
        }
Exemple #2
0
        private string DoSendOffLineMsg(string formatString)
        {
            AnalysisStr analy = new AnalysisStr(formatString);
            DBFunction  dbf   = new DBFunction();
            string      msg   = "Server#" + OpType.SEND_OFFLINE_MSG_RES;

            msg += "#" + dbf.SendOffLineMessage(analy.GetParaIndexOf(0), analy.GetParaIndexOf(1), analy.GetParaFromIndex(2));
            return(msg);
        }