Пример #1
0
        public SmqOppResult Opp(QueueMethod method, SessionMessage item)
        {
            //
            SmqOppResult ru = new SmqOppResult();

            if (QueueMethod.Add == method)
            {

                _smsgList.Enqueue(item);

               ru.oppSucess = true;

            }
            else if (QueueMethod.Shift == method && _smsgList.Count > 0)
            {
                ru.oppSucess = true;
                ru.item = _smsgList.Dequeue();
                 
            }
            else if (QueueMethod.Peek == method && _smsgList.Count > 0)
            {
                ru.oppSucess = true;
                ru.item = _smsgList.Peek();
            
            }
            else if (QueueMethod.Count == method)
            {
                ru.oppSucess = true;
                ru.count = _smsgList.Count;
            }

            return ru;
        
        }
        public void doorNeedProof(SocketConnector session, XmlDocument doc, SessionMessage item)
        {
                try
                {
                        String saction = ServerAction.hasProof;

                        //回复
                        session.Write(
                            XmlInstruction.DBfengBao(saction, "<proof>" + getGameLogicServer().RCConnector.getProof() + "</proof>")
                            );

                        //
                        Log.WriteStrBySend(saction, session.getRemoteEndPoint().ToString());
                }
                catch (Exception exd)
                {
                        Log.WriteStrByException(CLASS_NAME(), "doorNeedProof", exd.Message,exd.StackTrace);
                }

        }
        override public void messageReceived(object session, Object message)
        {
            string packeBufStr = string.Empty;

            try
            {
                Socket s = (Socket)session;

                Byte[] packeBuf = (Byte[])message;

                XmlDocument doc = new XmlDocument();

                //
                packeBufStr = Encoding.UTF8.GetString(packeBuf);

                doc.LoadXml(packeBufStr);

                //
                string rcCAction = doc.DocumentElement.ChildNodes[0].Attributes["action"].Value;

                string strIpPort = s.RemoteEndPoint.ToString();
                
                //create item
                SessionMessage item = new SessionMessage(null, doc, true, strIpPort);

                //save
                DdzLPU.msgList.Opp(QueueMethod.Add, item);

                //
                Log.WriteStrByServerRecv(rcCAction,SR.getRecordServer_displayName());


            }
            catch (Exception exd)
            {
                Log.WriteStrByException("DdzRCClientHandler", "messageReceived", exd.Message);
            }


        }
Пример #4
0
        /// <summary>
        /// 一个user To 另一个user的即时打开邮件系统
        /// </summary>
        /// <param name="session"></param>
        /// <param name="doc"></param>        
        public void doorSetMvars(AppSession session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                string strIpPort = session.RemoteEndPoint.ToString();

                XmlNode node = doc.SelectSingleNode("/msg/body");
                string roomId = node.Attributes["r"].Value;

                XmlNode node2 = doc.SelectSingleNode("/msg/body/vars");

                //安全检测
                if (!logicHasRoom(int.Parse(roomId))
                    )
                {
                    return;
                }

                //
                IRoomModel room = logicGetRoom(int.Parse(roomId));

                //check
                if (logicHasUser(strIpPort))
                {
                    IUserModel fromUser = logicGetUser(strIpPort);

                    //<val n="5a105e8b9d40e1329780d62ea2265d8a" t="s"><![CDATA[askJoinRoom,100]]></val>
                    for (int i = 0; i < node2.ChildNodes.Count; i++)
                    {
                        string n = node2.ChildNodes[i].Attributes["n"].Value;
                        string v = node2.ChildNodes[i].InnerText;

                        //使用拷贝的参数
                        IUserModel fromUserCpy = UserModelFactory.Create(fromUser.getStrIpPort(),
                                                                         fromUser.Id,
                                                                         0,
                                                                         fromUser.getSex(),
                                                                         fromUser.getAccountName(),
                                                                         fromUser.getNickName(),
                                                                         fromUser.getBbs(),
                                                                         fromUser.getHeadIco()
                                                                         );

                        if (logicHasUserById(v))
                        {
                            IUserModel toUser = logicGetUserById(v);
                            IUserModel toUserCpy = UserModelFactory.Create(toUser.getStrIpPort(),
                                                                           toUser.Id,
                                                                           0,
                                                                           toUser.getSex(),
                                                                           toUser.getAccountName(),
                                                                           toUser.getNickName(),
                                                                           toUser.getBbs(),
                                                                           toUser.getHeadIco()
                                                                           );


                            //Mail().setMvars(fromUserCpy,
                            //                toUserCpy,
                            //                n,
                            //                room.Tab.ToString() + "," + room.Id.ToString() + "," + room.getDig().ToString() + "," + room.getCarryg().ToString()
                            //                );

                        }
                        else
                        {
                            //离线存储
                        }
                    }//end for            
                }//end if

                //发送
                netSendMail();

            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME, "doorSetMvars", exd.Message, exd.Source, exd.Message);
            }

        }
Пример #5
0
        /// <summary>
        /// 房间变量
        /// 对roomId要验证一次
        /// 转发给房间的其他人
        /// </summary>
        /// <param name="session"></param>
        /// <param name="doc"></param>        
        public void doorSetRvars(AppSession session, XmlDocument doc, SessionMessage item)
        {
            
            int roomId = 0;
            string strIpPort = string.Empty;

            try
            {
                strIpPort = session.RemoteEndPoint.ToString();

                //<vars><var n='selectQizi' t='s'><![CDATA[red_pao_1]]></var></vars>
                XmlNode node = doc.SelectSingleNode("/msg/body");
                roomId = int.Parse(node.Attributes["r"].Value);

                //安全检测
                if (!logicHasRoom(roomId))
                {
                    return;
                }

                if (!logicHasUserInRoom(strIpPort, roomId))
                {
                    return;
                }

                //
                XmlNode nodeVars = doc.SelectSingleNode("/msg/body/vars");

                //
                IRoomModel room = logicGetRoom(roomId);

                IUserModel user = logicGetUser(strIpPort);

                //save
                //关于转发数据的合法性,不合法的处理方法需要再研究
                int len = nodeVars.ChildNodes.Count;
                int i = 0;

                string n = string.Empty;
                string v = string.Empty;

                for (i = 0; i < len; i++)
                {
                    n = nodeVars.ChildNodes[i].Attributes["n"].Value;
                    v = nodeVars.ChildNodes[i].InnerText;

                    RvarsStatus sta;
                    //检测不通过
                    if (!room.chkVars(n, v, user.Id, ref nodeVars,i,out sta))
                    {
                        return;
                    }
                }

                //
                n = string.Empty;
                v = string.Empty;

                for (i = 0; i < len; i++)
                {
                    n = nodeVars.ChildNodes[i].Attributes["n"].Value;
                    v = nodeVars.ChildNodes[i].InnerText;

                    room.setVars(n,v);
                }
                

                //转发
                string saction = ServerAction.rVarsUpdate;
                string contentXml = "<room id='" + roomId.ToString() + "'>" + nodeVars.OuterXml + "</room>";

                netTurnRoom(strIpPort, roomId, saction, contentXml);

                //log                
                Log.WriteStrByTurn(SR.Room_displayName + roomId.ToString(), strIpPort, saction, n, nodeVars.InnerText);

            }
            catch (Exception exd)
            {

                Log.WriteStrByException(CLASS_NAME, "doorSetRvars", exd.Message, exd.Source, exd.StackTrace);

            }

            try
            {
                //群发,全部准备可以开始游戏
                //判断游戏是否可以开始
                logicCheckGameStart(roomId);

                //群发
                logicCheckGameStartFirstChuPai(roomId, strIpPort);

                //判断游戏是否中断结束,此情况为三轮均不叫,全部踢出房间,不扣金点
                logicCheckGameOver_RoomClear(roomId, strIpPort);

                //群发
                //判断游戏是否可以结束
                logicCheckGameOver(roomId, strIpPort);
            

            }
            catch (Exception exc)
            {

                Log.WriteStrByException(CLASS_NAME, "doorSetRvars", exc.Message, exc.Source ,exc.StackTrace);

            }


        }
Пример #6
0
        /// <summary>
        /// 获取空闲的用户列表
        /// </summary>
        /// <param name="session"></param>
        /// <param name="doc"></param>
        /// 不需要同步
        public void doorLoadD(AppSession session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                //var 
                string svrAction = string.Empty;
                StringBuilder contentXml = new StringBuilder();

                //send
                svrAction = ServerAction.dList;

                //
                List<string> userStrIpPortList = CLIENTAcceptor.getUserList();

                //
                List<string> idleList = new List<string>();

                //
                int i = 0;
                int len = userStrIpPortList.Count;

                //找出空闲的用户
                for (i = 0; i < len; i++)
                {
                    //if (logicHasUser(userStrIpPortList[i]))
                    //{
                        bool userInRoom = false;
                        //--
                        foreach (int key in roomList.Keys)
                        {
                            
                            IRoomModel room = roomList.get(key);

                            //logicHasUserInRoom
                            if (logicQueryUserInRoom(userStrIpPortList[i], room.Id))
                            {
                                userInRoom = true;
                                break;
                            }

                        }//end for 

                        if (!userInRoom)
                        {
                            //idleList.Add(logicGetUser(userStrIpPortList[i]));
                            idleList.Add(userStrIpPortList[i]);
                        }

                        //--
                    //}//end if  

                }//end for

                //随机抽取10个
                //用户觉得10个太少,本人认为如改成全部或100个太多,现改为30
                //刷新时间则客户端控制
                //if (idleList.Count > 10)
                //30 现改为 50
                //现改为60
                int IDLE_LIST_MAX = 100;//60;

                if (idleList.Count > IDLE_LIST_MAX)
                {
                    Random r = new Random(RandomUtil.GetRandSeed());

                    //while (idleList.Count > 10)
                    while (idleList.Count > IDLE_LIST_MAX)
                    {
                        idleList.RemoveAt(r.Next(idleList.Count));
                    }
                }

                //封包
                len = idleList.Count;

                for (i = 0; i < len; i++)
                {
                    // contentXml.Append((idleList[i] as IUserModel).toXMLString());

                    //
                    if (logicHasUser(idleList[i]))
                    {
                        IUserModel idleUser = logicGetUser(idleList[i]);

                        contentXml.Append(idleUser.toXMLString());
                    }

                }

                //回复
                Send(session,

                    XmlInstruction.fengBao(svrAction, contentXml.ToString())

                    );

                //log
                Log.WriteStrBySend(svrAction, session.RemoteEndPoint.ToString());

            }
            catch (Exception exd)
            {
                Log.WriteStrByException("Logic", "doorLoadD", exd.Message, exd.Source, exd.Message);
            }

        }
Пример #7
0
        /// <summary>
        /// 自动加入房间
        /// 查找时注意tab种类,是否为密码房间
        /// </summary>
        /// <param name="session"></param>
        /// <param name="doc"></param>
        ///         
        public void doorAutoJoinRoom(AppSession session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                //var 
                string svrAction = string.Empty;
                StringBuilder contentXml = new StringBuilder();
                string roomXml = string.Empty;
                int tab = 0;

                //
                XmlNode node = doc.SelectSingleNode("/msg/body/room");
                string old = node.Attributes["old"].Value;

                XmlNode node2 = doc.SelectSingleNode("/msg/body/tab");
                tab = Convert.ToInt32(node2.ChildNodes[0].InnerText);

                //尝试退出当前的房间
                //这个一般是针对外挂,
                //根据客户端的old来退出当前的房间
                //用户只能身在某一个房间中
                if (logicHasRoom(int.Parse(old)))
                {
                    if (logicHasUserInRoom(session.RemoteEndPoint.ToString(), int.Parse(old)))
                    {
                        logicLeaveRoom(session.RemoteEndPoint.ToString());
                    }

                }

                //尝试坐下
                ToSitDownStatus sitDownStatus = ToSitDownStatus.ProviderError3;
                bool sitDown = false;
                int roomId = -1;
                int matchLvl = 1;

                //自动匹配差1人
                foreach (int key in roomList.Keys)
                {
                    IRoomModel room = (IRoomModel)roomList.get(key);

                    if (room.Tab == tab)
                    {
                        roomId = room.Id;

                        //自动匹配原则是 差1人的游戏最佳
                        //所以这里不能单单只是坐下,要做在差一人的坐位上
                        sitDown = logicHasIdleChairAndMatchSitDown(roomId,
                            matchLvl,
                            session.RemoteEndPoint.ToString(),
                            false,
                            out sitDownStatus);

                        if (sitDown)
                        {
                            break;
                        }//end if
                    }//end if

                }//end for

                //自动匹配差2人
                if (!sitDown)
                {
                    matchLvl++;

                    foreach (int key2 in roomList.Keys)
                    {
                        IRoomModel room2 = (IRoomModel)roomList.get(key2);

                        if (room2.Tab == tab)
                        {
                            roomId = room2.Id;

                            //自动匹配原则是 差1人的游戏最佳
                            //所以这里不能单单只是坐下,要做在差一人的坐位上
                            sitDown = logicHasIdleChairAndMatchSitDown(roomId,
                                matchLvl,
                                session.RemoteEndPoint.ToString(),
                                false,
                                out sitDownStatus);

                            if (sitDown)
                            {
                                break;
                            }//end if
                        }//end if

                    }//end for

                }//end if

                //自动匹配差3人
                if (!sitDown)
                {
                    matchLvl++;

                    foreach (int key3 in roomList.Keys)
                    {
                        IRoomModel room3 = (IRoomModel)roomList.get(key3);

                        if (room3.Tab == tab)
                        {
                            roomId = room3.Id;

                            //自动匹配原则是 差1人的游戏最佳
                            //所以这里不能单单只是坐下,要做在差一人的坐位上
                            sitDown = logicHasIdleChairAndMatchSitDown(roomId,
                                matchLvl,
                                session.RemoteEndPoint.ToString(),
                                false,
                                out sitDownStatus);

                            if (sitDown)
                            {
                                break;
                            }//end if
                        }//end if

                    }//end for

                }//end if


                if (sitDown)
                {
                    svrAction = ServerAction.joinOK;

                    //获取房间的xml输出
                    IRoomModel room = logicGetRoom(roomId);
                    roomXml = room.toXMLString();

                    //坐下成功不需要code
                    //contentXml.Append("<code>0</code>");
                    contentXml.Append(roomXml);

                    //回复
                    Send(session,

                        XmlInstruction.fengBao(svrAction, contentXml.ToString())

                        );

                    //log
                    Log.WriteStrBySend(svrAction, session.RemoteEndPoint.ToString());

                    //转发 uER = UserEnterRoom
                    string svrAction_uER = ServerAction.uER;

                    IUserModel sitDownUser = logicGetUser(session.RemoteEndPoint.ToString());

                    string chairAndUserXml = room.getChair(sitDownUser).toXMLString();

                    netTurnRoom(session.RemoteEndPoint.ToString(), roomId, svrAction_uER, chairAndUserXml);

                    Log.WriteStrByTurn(SR.Room_displayName + roomId.ToString(), "", svrAction_uER);

                }
                else
                {
                    //
                    svrAction = ServerAction.joinKO;

                    //获取房间的xml输出
                    roomXml = logicGetRoom(roomId).toXMLString();

                    if (sitDownStatus == ToSitDownStatus.NoIdleChair1)
                    {
                        //code 比 status 字符个数少,而且as3 help里很多也用的是code
                        contentXml.Append("<code>1</code>");
                    }
                    else if (sitDownStatus == ToSitDownStatus.ErrorRoomPassword2)
                    {
                        contentXml.Append("<code>2</code>");
                    }
                    else
                    {
                        contentXml.Append("<code>3</code>");
                    }

                    contentXml.Append(roomXml);

                    //回复
                    Send(session,

                        XmlInstruction.fengBao(svrAction, contentXml.ToString())

                        );

                    //
                    Log.WriteStrBySend(svrAction, session.RemoteEndPoint.ToString());

                }//end if



            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME, "doorAutoJoinRoom", exd.Message, exd.Source, exd.StackTrace);
            }
        }
Пример #8
0
        /// <summary>
        /// 加入房间
        /// </summary>
        /// <param name="clientTmp"></param>
        /// <param name="xml"></param>
        /// <param name="clients"></param>
        public void doorJoinRoom(AppSession session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                //1.查询是否有空位
                //2.坐下
                XmlNode node = doc.SelectSingleNode("/msg/body/room");

                string roomId = node.Attributes["id"].Value;

                //房间密码暂不启用
                string pwd = node.Attributes["pwd"].Value;

                string old = node.Attributes["old"].Value;

                //
                string saction = string.Empty;

                StringBuilder contentXml = new StringBuilder();

                string roomXml = string.Empty;

                //验证roomId合法性
                if (!logicHasRoom(int.Parse(roomId)))
                {
                    return;
                }

                //尝试退出当前的房间
                //这个一般是针对外挂,
                //根据客户端的old来退出当前的房间
                //用户只能身在某一个房间中
                if (logicHasRoom(int.Parse(old)))
                {
                    if (logicHasUserInRoom(session.RemoteEndPoint.ToString(), int.Parse(old)))
                    {

                        logicLeaveRoom(session.RemoteEndPoint.ToString());
                    }

                }

                #region 尝试坐下

                ToSitDownStatus sitDownStatus;
                bool sitDown = logicHasIdleChairAndSitDown(int.Parse(roomId), session.RemoteEndPoint.ToString(), out sitDownStatus);

                if (sitDown)
                {
                    saction = ServerAction.joinOK;

                    //获取房间的xml输出
                    IRoomModel room = logicGetRoom(int.Parse(roomId));
                    roomXml = room.toXMLString();

                    //坐下成功不需要status
                    //contentXml.Append("<status>0</status>");
                    contentXml.Append(roomXml);

                    //回复
                    Send(session,

                        XmlInstruction.fengBao(saction, contentXml.ToString())

                        );

                    //
                    Log.WriteStrBySend(saction, session.RemoteEndPoint.ToString());

                    //转发 uER = UserEnterRoom
                    string saction_uER = ServerAction.uER;

                    IUserModel sitDownUser = logicGetUser(session.RemoteEndPoint.ToString());

                    string chairAndUserXml = room.getChair(sitDownUser).toXMLString();

                    netTurnRoom(session.RemoteEndPoint.ToString(), int.Parse(roomId), saction_uER, chairAndUserXml);

                    Log.WriteStrByTurn(SR.Room_displayName + roomId, "", saction_uER);

                }
                else
                {

                    saction = ServerAction.joinKO;

                    //获取房间的xml输出
                    roomXml = logicGetRoom(int.Parse(roomId)).toXMLString();

                    if (sitDownStatus == ToSitDownStatus.NoIdleChair1)
                    {
                        //code 比 status 字符个数少,而且as3 help里很多也用的是code
                        contentXml.Append("<code>1</code>");
                    }
                    else if (sitDownStatus == ToSitDownStatus.ErrorRoomPassword2)
                    {
                        contentXml.Append("<code>2</code>");
                    }
                    else
                    {
                        contentXml.Append("<code>3</code>");
                    }

                    contentXml.Append(roomXml);

                    //回复
                    Send(session,

                        XmlInstruction.fengBao(saction, contentXml.ToString())

                        );

                    //
                    Log.WriteStrBySend(saction, session.RemoteEndPoint.ToString());

                }//end if

                #endregion


                

            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME, "doorJoinRoom", exd.Message, exd.Source, exd.StackTrace);
            }
        }
Пример #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="session"></param>
        /// <param name="doc"></param>
        /// <param name="item"></param>
        public void doorListModule(AppSession session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                //var
                string svrAction = string.Empty;
                StringBuilder contentXml = new StringBuilder();                

                //send
                svrAction = ServerAction.listModule;


                contentXml.Append("<module>");

                //module list
                //foreach (int key in roomList.Keys)
                //{

                        contentXml.Append("<m n='");

                        contentXml.Append(DdzLogic_Toac.name);

                        contentXml.Append("' run='");

                        contentXml.Append(DdzLogic_Toac.turnOver_a_Card_module_run.ToString());
                        //
                        contentXml.Append("' g1='");

                        contentXml.Append(DdzLogic_Toac.g1);

                        contentXml.Append("' g2='");

                        contentXml.Append(DdzLogic_Toac.g2);

                        contentXml.Append("' g3='");

                        contentXml.Append(DdzLogic_Toac.g3);

                        contentXml.Append("' />");

                        
                //}

                contentXml.Append("</module>");        


                //回复
                Send(session,
                    XmlInstruction.fengBao(svrAction, contentXml.ToString())

                    );

                //log
                Log.WriteStrBySend(svrAction, session.RemoteEndPoint.ToString());

            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME, "doorListModule", exd.Message, exd.Source, exd.StackTrace);
            }
        }
Пример #10
0
        public override void doorLogOK(SocketConnector session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                    XmlNode node = doc.SelectSingleNode("/msg/body");

                    String userStrIpPort = node.ChildNodes[0].InnerText;
                    String usersex     = node.ChildNodes[1].InnerText;
                    String username = node.ChildNodes[2].InnerText;
                    String userpwd = node.ChildNodes[3].InnerText;
                    String useremail   = node.ChildNodes[4].InnerText;
                    String bbs = node.ChildNodes[5].InnerText;
                    String hico = node.ChildNodes[6].InnerText;
                    String sid = node.ChildNodes[7].InnerText;
                    int id_sql = Integer.valueOf(node.ChildNodes[8].InnerText);

                    String id = node.ChildNodes[9].InnerText;
                    String status = node.ChildNodes[10].InnerText;


                    //
                    String saction = ServerAction.logOK;
                    StringBuilder contentXml = new StringBuilder();

                    //回复
                    //注意这里的session是上面的usersession,要判断是否还在线
                    AppSession userSession = DdzLogic.getInstance().CLIENTAcceptor.getSession(userStrIpPort);

                    //判断重复登录,如果这里发生异常,可能就需要多登录几次才能挤掉对方,并成功登录
                    AppSession outSession = DdzLogic.getInstance().CLIENTAcceptor.getSessionByAccountName(username);

                    if (null != outSession)
                    {
                            //发一个通知,您与服务器的连接断开,原因:您的帐号在另一处登录
                            //然后触发ClearSession
                            String logoutAction = ServerAction.logout;
                            String logoutCode = "1";
                            StringBuilder logoutXml = new StringBuilder();

                            logoutXml.Append("<session>").Append(userSession.getRemoteEndPoint().ToString()).Append("</session>");
                            logoutXml.Append("<session>").Append(outSession.getRemoteEndPoint().ToString()).Append("</session>");
                            logoutXml.Append("<code>").Append(logoutCode).Append("</code>");
                            logoutXml.Append("<u></u>");

                            DdzLogic.getInstance().Send(outSession, XmlInstruction.fengBao(logoutAction, logoutXml.ToString()));

                            //
                            Log.WriteStrBySend(logoutAction, outSession.getRemoteEndPoint().ToString());

                            //
                            DdzLogic.getInstance().CLIENTAcceptor.trigClearSession(outSession, outSession.getRemoteEndPoint().ToString());
                    }

                    //如果不在线则略过发送
                    if (null != userSession)
                    {
                            //超过在线人数
                                    if (DdzLogic.getInstance().CLIENTAcceptor.getUserCount() >= DdzLogic.getInstance().CLIENTAcceptor.getMaxOnlineUserConfig())
                                    {
                                            //调整saction
                                            saction = ServerAction.logKO;
                                            //调整status
                                            status = "12"; //来自MembershipLoginStatus2.PeopleFull12

                                            contentXml.Append("<session>").Append(userStrIpPort).Append("</session>");
                                            contentXml.Append("<status>").Append(status).Append("</status>");
                                            contentXml.Append("<u></u>");

                                            DdzLogic.getInstance().Send(userSession, XmlInstruction.fengBao(saction, contentXml.ToString()));

                                            //
                                            Log.WriteStrBySend(saction, userStrIpPort);
                                    }
                                    else
                                    {
                                            IUserModel user = UserModelFactory.Create(userStrIpPort, id, id_sql, usersex, username, username, bbs, hico);

                                            //加入在线用户列表
                                            //CLIENTAcceptor.addUser(userSession.getRemoteEndPoint().ToString(), user);
                                            DdzLogic.getInstance().CLIENTAcceptor.addUser(userStrIpPort, user);

                                            contentXml.Append("<session>").Append(userStrIpPort).Append("</session>");
                                            contentXml.Append("<status>").Append(status).Append("</status>");
                                            contentXml.Append(user.toXMLString());

                                            DdzLogic.getInstance().Send(userSession, XmlInstruction.fengBao(saction, contentXml.ToString()));

                                            //
                                            Log.WriteStrBySend(saction, userStrIpPort);

                                            //
                                            Log.WriteFileByLoginSuccess(username, userStrIpPort);
                                            Log.WriteFileByOnlineUserCount(DdzLogic.getInstance().CLIENTAcceptor.getUserCount());

                                    } //end if

                    } //end if



            }
            catch (Exception exd)
            {
                    Log.WriteStrByException(CLASS_NAME(), "doorLogOK", exd.Message,exd.StackTrace);
            }
    }    
        public void doorHasRegOK(SocketConnector session, XmlDocument doc, SessionMessage item)
        {
        
               try
               {

                        XmlNode node = doc.SelectSingleNode("/msg/body");

                        String userStrIpPort = node.ChildNodes[0].InnerText;//InnerText;
                    
                        AppSession userSession = getGameLogicServer().CLIENTAcceptor.getSession(userStrIpPort);
                    
                        //
                        String saction = ServerAction.hasRegOK;
                    
                        String contentXml = "";                        

                        //如果不在线则略过发送
                        getGameLogicServer().Send(userSession, XmlInstruction.fengBao(saction, contentXml));

                        //
                        Log.WriteStrBySend(saction, userSession.getRemoteEndPoint().ToString());
            
                }
               catch (Exception exd)
                {
                        Log.WriteStrByException(CLASS_NAME(), "doorHasRegOK", exd.Message, exd.StackTrace);
                }
    
        }
        public void doorProofOK(SocketConnector session, XmlDocument doc, SessionMessage item)
        {

            Log.WriteStr(SR.GetString(SR.getcert_vali(), session.getRemoteEndPoint().ToString()));
        }
        /**
         * 
         * 
         * @param session
         * @param doc
         * @param item 
         */
        public void doorLoadTopListOK(SocketConnector session, XmlDocument doc, SessionMessage item) 
        {
            try
            {

                 //<session>127.0.0.1:64828</session><chart total_add="0" total_sub="0"></chart>
                 XmlNode node = doc.SelectSingleNode("/msg/body");

                 String userStrIpPort = node.ChildNodes[0].InnerText;//InnerText;


                 String topListXml = node.ChildNodes[1].OuterXml;//(new XMLOutputter()).outputString(node.ChildNodes()[1]);

                 //
                 String saction = ServerAction.topList;

                 //回复
                 //注意这里的session是上面的usersession,要判断是否还在线
                 
                 AppSession userSession = this.getGameLogicServer().CLIENTAcceptor.getSession(userStrIpPort);

                 //
                 this.getGameLogicServer().Send(userSession, XmlInstruction.fengBao(saction, topListXml));

             }
            catch (Exception exd)
             {
                     Log.WriteStrByException(CLASS_NAME(), "doorLoadTopListOK", exd.Message,exd.StackTrace);
             }
        }
        /**
         * 每日登陆(至少玩一把)
         * 
         * @param session
         * @param doc
         * @param item 
         */
        public void doorChkEveryDayLoginAndGetOK(SocketConnector session, XmlDocument doc, SessionMessage item)
        {
            try
            {

                    XmlNode gameNode = doc.SelectSingleNode("/msg/body/game");

                    //具体奖励数额
                    String gv = gameNode.Attributes["v"].Value;

                    //
                    XmlNode node = doc.SelectSingleNode("/msg/body/game");

                    int len = node.ChildNodes.Count;

                    for (int i = 0; i < len; i++)
                    {
                            String edlValue = node.ChildNodes[i].Attributes["edl"].Value;

                            String id = node.ChildNodes[i].Attributes["id"].Value;
                        
                            IUserModel u = getGameLogicServer().CLIENTAcceptor.getUserById(id);
                        
                            if(u == null)
                            {
                                continue;
                            }
                        
                            String userStrIpPort = u.getstrIpPort();//node.ChildNodes()[i].getAttributeValue("session");

                            String saction = "";

                            saction = ServerAction.everyDayLoginVarsUpdate;

                            //

                            //回复
                            //注意这里的session是上面的usersession,要判断是否还在线
                            if (getGameLogicServer().CLIENTAcceptor.hasSession(userStrIpPort))
                            {
                                    AppSession userSession = getGameLogicServer().CLIENTAcceptor.getSession(userStrIpPort);

                                    getGameLogicServer().Send(userSession, XmlInstruction.fengBao(saction, "<edl v='" + gv + "'>" + edlValue + "</edl>"));

                                    //
                                    Log.WriteStrBySend(saction, userStrIpPort);
                            }

                    } //end for

            }
            catch (Exception exd)
            {
                    Log.WriteStrByException(CLASS_NAME(), "doorChkEveryDayLoginAndGetOK",exd.Message);
            }

        }
        public void doorLoadGOK(SocketConnector session, XmlDocument doc, SessionMessage item)
        {
                try
                {
                        XmlNode node = doc.SelectSingleNode("/msg/body");

                        String userStrIpPort = node.ChildNodes[0].InnerText;//InnerText;

                        String g = node.ChildNodes[1].InnerText;//InnerText;

                        String id_sql = node.ChildNodes[1].Attributes["id_sql"].Value;
                        //
                        String saction = ServerAction.gOK;

                        //回复
                        //注意这里的session是上面的usersession,要判断是否还在线
                        AppSession userSession = getGameLogicServer().netGetSession(userStrIpPort);

                        //如果不在线则略过发送
                        if (null != userSession)
                        {
                            IUserModel u = getGameLogicServer().CLIENTAcceptor.getUser(userStrIpPort);

                            //以免引发不必要的异常,方便测试
                            if (!(g == ""))
                            {
                                 u.setG(parseInt(g));
                            }
										
                            getGameLogicServer().Send(userSession, XmlInstruction.fengBao(saction, 
                                    "<g " + "id_sql='" + id_sql + "'" + ">" + g + "</g>"));

                            //
                            Log.WriteStrBySend(saction, userSession.getRemoteEndPoint().ToString());


                        }
                        else
                        {
                                Log.WriteStrBySendFailed(saction, userSession.getRemoteEndPoint().ToString());
                        } //end if

                }
                catch (Exception exd)
                {
                        Log.WriteStrByException(CLASS_NAME(), "doorLoadGOK", exd.Message);
                }
        }
Пример #16
0
        public void doorChkEveryDayLoginAndGetOK(Socket session, XmlDocument doc, SessionMessage item)
        {
            try
            {

                XmlNode gameNode = doc.SelectSingleNode("/msg/body/game");

                //具体奖励数额
                string gv = gameNode.Attributes["v"].Value;

                //
                XmlNode node = doc.SelectSingleNode("/msg/body/game");

                int len = node.ChildNodes.Count;

                for (int i = 0; i < len; i++)
                { 
                    string edlValue = node.ChildNodes[i].Attributes["edl"].Value;

                    string userStrIpPort = node.ChildNodes[i].Attributes["session"].Value;

                    string saction = string.Empty;

                    saction = ServerAction.everyDayLoginVarsUpdate;

                    //

                    //回复
                    //注意这里的session是上面的usersession,要判断是否还在线
                    if (CLIENTAcceptor.hasSession(userStrIpPort))
                    {
                        AppSession userSession = CLIENTAcceptor.getSession(userStrIpPort);

                        Send(userSession,

                           XmlInstruction.fengBao(saction, "<edl v='" + gv  + "'>" + edlValue + "</edl>")

                           );

                        //
                        Log.WriteStrBySend(saction, userStrIpPort);
                    }
                
                }//end for

            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME, "doorChkEveryDayLoginAndGetOK", "[" + exd.Message + "," + doc.InnerText + "]");
            }
        
        }        
Пример #17
0
        /// <summary>
        /// 版本号检查
        /// <开头为回 xml
        /// %开头为回 字符串
        /// {开头为回 json
        /// </summary>
        /// <param name="s"></param>
        /// <param name="xml"></param>
        /// 不需要同步
        public void doorVerChk(AppSession session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                //doc
                //<msg t='sys'><body action='verChk' r='0'><ver v='153' /></body></msg>

                XmlNode node = doc.SelectSingleNode("/msg/body/ver");
                                
                //
                int clientVer = int.Parse(node.Attributes["v"].Value);

                //不检查版本号
                string saction = string.Empty;

                //不能低于230
                if (clientVer >= 230)
                {
                    saction = ServerAction.apiOK;

                }
                else
                {
                    saction = ServerAction.apiKO;
                }

                //回复
                Send(session, 
                        XmlInstruction.fengBao(saction, "")
                    );

                
            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME, "doorVerChk", exd.Message,exd.Source,exd.StackTrace);
            }
        }
        override public void messageReceived(object session, object message)
        {
            try
            {
                AppSession s = (AppSession)session;

                XmlDocument doc = (XmlDocument)message;

                //<msg t="DBS"><body action=""></body></msg>
                string csAction = doc.DocumentElement.ChildNodes[0].Attributes["action"].Value;

                string strIpPort = s.RemoteEndPoint.ToString();

                //
                //Log.WriteStrByRecv(clientServerAction, strIpPort);

                //create item
                SessionMessage item = new SessionMessage(s, doc, false, strIpPort);

                //save
                RCLogicLPU.getInstance().getmsgList().Opp(QueueMethod.Add, item);

                //
                Log.WriteStrByRecv(csAction, strIpPort);
                
            }
            catch (Exception exd)
            {
                Log.WriteStrByException("RecordSocketDataHandler", "messageReceived", exd.Message);

            }

        }
Пример #19
0
        /// <summary>
        /// 获取大厅的房间列表
        /// </summary>
        /// <param name="session"></param>
        /// <param name="doc"></param>
        /// 不需要同步
        public void doorListRoom(AppSession session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                //var
                string svrAction = string.Empty;
                StringBuilder contentXml = new StringBuilder();
                int tab = 0;

                //read
                XmlNode node = doc.SelectSingleNode("/msg/body");
                tab = Convert.ToInt32(node.ChildNodes[0].InnerText);

                //验证tab合法性
                if (!logicHasTab(tab))
                {
                    return;
                }

                //send
                svrAction = ServerAction.listHallRoom;

                //
                ITabModel tabModel = logicGetTab(tab);

                contentXml.Append("<t id='");
                contentXml.Append(tabModel.Tab.ToString());
                contentXml.Append("' autoMatchMode='");
                contentXml.Append(tabModel.getTabAutoMatchMode());
                contentXml.Append("' >");

                //
                foreach (int key in roomList.Keys)
                {
                    IRoomModel room = (IRoomModel)roomList.get(key);

                    if (room.Tab == tab)
                    {

                        contentXml.Append("<r id='");

                        contentXml.Append(room.Id.ToString());

                        //为空则由客户端指定名字,如房间1
                        contentXml.Append("' n='");

                        contentXml.Append(room.getName());

                        contentXml.Append("' p='");

                        contentXml.Append(room.getSomeBodyChairCount().ToString());

                        contentXml.Append("' dg='");

                        contentXml.Append(room.getDig());

                        contentXml.Append("' cg='");

                        contentXml.Append(room.getCarryg());

                        contentXml.Append("' />");
                    }
                }

                contentXml.Append("</t>");

                //回复
                Send(session,
                    XmlInstruction.fengBao(svrAction, contentXml.ToString())

                    );

                //log
                Log.WriteStrBySend(svrAction, session.RemoteEndPoint.ToString());

            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME, "doorListRoom", exd.Message,exd.Source,exd.StackTrace);
            }
        }
Пример #20
0
 public SmqOppResult()
 {
     oppSucess = false;
     item = null;
     count = -1;
 }
Пример #21
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="session"></param>
        /// <param name="doc"></param>
        /// <param name="item"></param>
        public void doorJoinReconnectionRoom(AppSession session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                //1.查询断线重连房间
                //2.坐下
                XmlNode node = doc.SelectSingleNode("/msg/body/room");

                string roomId = node.Attributes["id"].Value;

                //房间密码暂不启用
                string pwd = node.Attributes["pwd"].Value;

                string old = node.Attributes["old"].Value;

                //
                if(!logicHasUser(session.RemoteEndPoint.ToString()))
                {
                    return;
                }

                IUserModel user = logicGetUser(session.RemoteEndPoint.ToString());

                //
                string saction = string.Empty;

                StringBuilder contentXml = new StringBuilder();
                StringBuilder filterContentXml = new StringBuilder();

                string roomXml = string.Empty;
                string filterRoomXml = string.Empty;

                //重新对roomId赋值 
                roomId = "-1";

                //search
                IRoomModel room = null;
                foreach (int key in roomList.Keys)
                {
                    //
                    room = (IRoomModel)roomList.get(key);

                    if (room.isWaitReconnection)
                    {
                        if (room.WaitReconnectionUser.Id == user.Id)
                        {
                            roomId = room.Id.ToString();
                            break;
                        }
                    
                    }

                }


                //不尝试退出当前的房间
                
                //进入断线重连房间
                if ("-1" != roomId && 
                    null != room)
                {
                    #region 尝试坐下

                    ToSitDownStatus sitDownStatus;
                    bool sitDown = logicHasIdleChairAndSitDown(int.Parse(roomId), session.RemoteEndPoint.ToString(), out sitDownStatus);

                    if (sitDown)
                    {
                        //
                        room.setWaitReconnection(null);
                        
                        //
                        saction = ServerAction.joinOK;

                        //获取房间的xml输出
                        //IRoomModel room = logicGetRoom(int.Parse(roomId));
                        roomXml = room.toXMLString();
                        roomXml = room.getFilterContentXml(session.RemoteEndPoint.ToString(), roomXml);
                        
                        //坐下成功不需要status
                        //contentXml.Append("<status>0</status>");
                        contentXml.Append(roomXml);

                        //回复
                        Send(session,

                            XmlInstruction.fengBao(saction, contentXml.ToString())

                            );

                        //
                        Log.WriteStrBySend(saction, session.RemoteEndPoint.ToString());

                        //恢复

                        Send(session,

                            XmlInstruction.fengBao(ServerAction.joinReconnectionOK, contentXml.ToString())

                            );
                        //
                        Log.WriteStrBySend(saction, session.RemoteEndPoint.ToString());

                       
                        //转发 uER = UserEnterRoom
                        string saction_uER = ServerAction.uER;

                        IUserModel sitDownUser = logicGetUser(session.RemoteEndPoint.ToString());

                        string chairAndUserXml = room.getChair(sitDownUser).toXMLString();

                        netTurnRoom(session.RemoteEndPoint.ToString(), int.Parse(roomId), saction_uER, chairAndUserXml);

                        Log.WriteStrByTurn(SR.Room_displayName + roomId, "", saction_uER);

                        //转发 waitReconnectionEnd
                        netTurnRoom(session.RemoteEndPoint.ToString(), int.Parse(roomId), ServerAction.userWaitReconnectionRoomEnd, chairAndUserXml);

                        Log.WriteStrByTurn(SR.Room_displayName + roomId, "", ServerAction.userWaitReconnectionRoomEnd);


                        



                    }
                    else
                    {

                        saction = ServerAction.joinKO;

                        //获取房间的xml输出
                        roomXml = logicGetRoom(int.Parse(roomId)).toXMLString();

                        if (sitDownStatus == ToSitDownStatus.NoIdleChair1)
                        {
                            //code 比 status 字符个数少,而且as3 help里很多也用的是code
                            contentXml.Append("<code>1</code>");
                        }
                        else if (sitDownStatus == ToSitDownStatus.ErrorRoomPassword2)
                        {
                            contentXml.Append("<code>2</code>");
                        }
                        else
                        {
                            contentXml.Append("<code>3</code>");
                        }

                        contentXml.Append(roomXml);

                        //回复
                        Send(session,

                            XmlInstruction.fengBao(saction, contentXml.ToString())

                            );

                        //
                        Log.WriteStrBySend(saction, session.RemoteEndPoint.ToString());

                    }//end if

                    #endregion

                }
                else
                { 
                    #region 没有断线重连的房间

                    saction = ServerAction.joinReconnectionKO;

                    
                    //回复
                    Send(session,

                        XmlInstruction.fengBao(saction, "")

                        );

                    //
                    Log.WriteStrBySend(saction, session.RemoteEndPoint.ToString());

                    #endregion

                }
                

            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME, "doorJoinRoom", exd.Message, exd.Source, exd.StackTrace);
            }
        }
Пример #22
0
        public void doorLogOK(Socket session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                XmlNode node = doc.SelectSingleNode("/msg/body");

                string userStrIpPort = node.ChildNodes[0].InnerText;

                string status = node.ChildNodes[1].InnerText;

                //
                string userId = node.ChildNodes[2].Attributes["id"].Value;
                string userAccountName = node.ChildNodes[2].Attributes["n"].Value;
                string userNickName = node.ChildNodes[2].Attributes["n"].Value;
                string userSex = node.ChildNodes[2].Attributes["s"].Value;
                                
                //
                //新加头像路径,为兼容dvbbs
                string bbs = node.ChildNodes[3].InnerText;
                string headIco = node.ChildNodes[4].InnerText;

                //
                string saction = ServerAction.logOK;
                StringBuilder contentXml = new StringBuilder();

                //回复
                //注意这里的session是上面的usersession,要判断是否还在线
                AppSession userSession = CLIENTAcceptor.getSession(userStrIpPort);

                //判断重复登录,如果这里发生异常,可能就需要多登录几次才能挤掉对方,并成功登录
                AppSession outSession = CLIENTAcceptor.getSessionByAccountName(userAccountName);

                if (null != outSession)
                {
                    //发一个通知,您与服务器的连接断开,原因:您的帐号在另一处登录
                    //然后触发ClearSession
                    string logoutAction = ServerAction.logout;
                    string logoutCode = "1";
                    StringBuilder logoutXml = new StringBuilder();

                    logoutXml.Append("<session>" + userSession.RemoteEndPoint.ToString() + "</session>");
                    logoutXml.Append("<session>" + outSession.RemoteEndPoint.ToString() + "</session>");
                    logoutXml.Append("<code>" + logoutCode + "</code>");
                    logoutXml.Append("<u></u>");

                    Send(outSession,

                              XmlInstruction.fengBao(logoutAction, logoutXml.ToString())

                              );

                    //
                    Log.WriteStrBySend(logoutAction, outSession.RemoteEndPoint.ToString());

                    //
                    CLIENTAcceptor.trigClearSession(outSession, outSession.RemoteEndPoint.ToString());
                }

                //如果不在线则略过发送
                if (null != userSession)
                {
                    //超过在线人数
                        if (CLIENTAcceptor.getUserCount() >= CLIENTAcceptor.getMaxOnlineUserConfig())
                        {
                            //调整saction
                            saction = ServerAction.logKO;
                            //调整status
                            status = "12";//来自MembershipLoginStatus2.PeopleFull12

                            contentXml.Append("<session>" + userStrIpPort + "</session>");
                            contentXml.Append("<status>" + status + "</status>");
                            contentXml.Append("<u></u>");

                            Send(userSession,

                               XmlInstruction.fengBao(saction, contentXml.ToString())

                               );

                            //
                            Log.WriteStrBySend(saction, userStrIpPort);
                        }
                        else
                        {
                            IUserModel user = UserModelFactory.Create(userStrIpPort, userId, 0, userSex, userAccountName, userNickName, bbs,headIco);

                            //加入在线用户列表
                            //CLIENTAcceptor.addUser(userSession.RemoteEndPoint.ToString(), user);
                            CLIENTAcceptor.addUser(userStrIpPort, user);

                            contentXml.Append("<session>" + userStrIpPort + "</session>");
                            contentXml.Append("<status>" + status + "</status>");
                            contentXml.Append(user.toXMLString());

                            Send(userSession,

                               XmlInstruction.fengBao(saction, contentXml.ToString())

                               );

                            //
                            Log.WriteStrBySend(saction, userStrIpPort);

                            //
                            Log.WriteFileByLoginSuccess(userAccountName, userStrIpPort);
                            Log.WriteFileByOnlineUserCount(CLIENTAcceptor.getUserCount());

                        }//end if

                }//end if



            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME, "doorLogOK", exd.Message + ". " + exd.Source + ". " + exd.StackTrace);
            }
        }
Пример #23
0
        public void doorAutoMatchRoom(AppSession session, XmlDocument doc, SessionMessage item)
        {
            try
            {

                int tab = 0;

                //
                XmlNode node = doc.SelectSingleNode("/msg/body/room");
                string old = node.Attributes["old"].Value;

                XmlNode node2 = doc.SelectSingleNode("/msg/body/tab");
                tab = Convert.ToInt32(node2.ChildNodes[0].InnerText);

                //
                string strIpPort = session.RemoteEndPoint.ToString();

                //
                int roomOldId = Convert.ToInt32(old);
                AutoMatchRoomModel amr = new AutoMatchRoomModel(strIpPort, tab, roomOldId);

                //
                if (!getAutoMatchWaitList().containsKey(strIpPort))
                {
                    getAutoMatchWaitList().put(strIpPort, amr);
                }else
                {
                    //覆盖数据
                    getAutoMatchWaitList().put(strIpPort,amr);
                }

            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME, "doorAutoMatchRoom", exd.Message, exd.Source, exd.StackTrace);
            }
        }        
Пример #24
0
        public void doorRegKO(Socket session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                XmlNode node = doc.SelectSingleNode("/msg/body");

                string userStrIpPort = node.ChildNodes[0].InnerText;

                string status = node.ChildNodes[1].InnerText;

                string param = node.ChildNodes[2].InnerText;

                //
                string saction = ServerAction.regKO;

                //回复
                //注意这里的session是上面的usersession,要判断是否还在线
                AppSession userSession = CLIENTAcceptor.getSession(userStrIpPort);

                //如果不在线则略过发送
                if (null != userSession)
                {
                    Send(userSession,

                           XmlInstruction.fengBao(saction, "<status>" + status + "</status><p>" + param + "</p>")

                           );

                        //
                        Log.WriteStrBySend(saction, userStrIpPort);
                   

                }
                else
                {
                    Log.WriteStrBySendFailed(saction, userStrIpPort);
                }//end if
            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME, "doorRegKO", exd.Message, exd.Source, exd.StackTrace);
            }
        }
Пример #25
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="session"></param>
        /// <param name="doc"></param>
        /// <param name="item"></param>
        public void doorLeaveRoomAndGoHallAutoMatch(AppSession session, XmlDocument doc, SessionMessage item)
        {

            try
            {

                //1.查询是否有空位
                //2.坐下
                XmlNode node = doc.SelectSingleNode("/msg/body/room");

                int roomId = int.Parse(node.Attributes["id"].Value);

                //安全检测
                if (!logicHasRoom(roomId))
                {
                    return;
                }

                if (!logicHasUserInRoom(session.RemoteEndPoint.ToString(), roomId))
                {
                    return;
                }

                //sr = server response
                string srAction = string.Empty;
                string contentXml = string.Empty;


                //尝试退出
                logicLeaveRoom(session.RemoteEndPoint.ToString());

                //回复     
                srAction = ServerAction.leaveRoomAndGoHallAutoMatch;

                //
                contentXml = "<rm id='" + roomId + "'/>";

                Send(session,

                    XmlInstruction.fengBao(srAction, contentXml)

                    );

                //log
                Log.WriteStrBySend(srAction, session.RemoteEndPoint.ToString());

            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME, "doorLeaveRoomAndGoHallAutoMatch", exd.Message, exd.Source, exd.StackTrace);
            }

        
        }
Пример #26
0
        public void doorProofOK(Socket session, XmlDocument doc, SessionMessage item)
        {

            //Log.WriteStr("通过服务器 " + session.RemoteEndPoint.ToString() + "证书验证!");

            Log.WriteStr(
                SR.GetString(SR.getcert_vali(),session.RemoteEndPoint.ToString())
            );
        }
Пример #27
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="session"></param>
        /// <param name="doc"></param>
        /// <param name="item"></param>
        public void doorSetModuleVars(AppSession session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                string strIpPort = session.RemoteEndPoint.ToString();

                if (!logicHasUser(strIpPort))
                {
                    return;
                }

                XmlNode node = doc.SelectSingleNode("/msg/body");
                
                XmlNode node2 = doc.SelectSingleNode("/msg/body/vars");

                IUserModel user = logicGetUser(strIpPort);

                //
                RoomModelByToac roomToac = null;
                string game_result_xml_rc = string.Empty;
                string roomXml = string.Empty;

                //
                for (int i = 0; i < node2.ChildNodes.Count; i++)
                {
                    string n = node2.ChildNodes[i].Attributes["n"].Value;
                    string v = node2.ChildNodes[i].InnerText;

                    //-------------------------------------------------------
                    string[] setVarsStatus = {"",""};

                    //
                    if (n == DdzLogic_Toac.name)
                    {
                        roomToac = new RoomModelByToac(user);
                        setVarsStatus = roomToac.setVars(n, v);
                        
                    }
                    else
                    {

                        throw new ArgumentException("can not find module name:" + n);

                    }

                    //-------------------------------------------------------

                    if ("True" == setVarsStatus[0] ||
                        "true" == setVarsStatus[0])
                    {
                        
                        //----------------------------------------------------
                        if (n == DdzLogic_Toac.name)
                        {                            

                            //send 记录服务器,保存得分 
                            game_result_xml_rc = roomToac.getMatchResultXmlByRc();

                            roomXml = roomToac.toXMLString();
                            
                            //
                            RCConnector.Write(

                                XmlInstruction.DBfengBao(RCClientAction.updG, game_result_xml_rc)

                                );

                           
                        }else{
                        
                            throw new ArgumentException("can not find module name:" + n);
                        
                        }

                        //
                        Log.WriteStrByTurn(SR.getRecordServer_displayName(),
                                RCConnector.getRemoteEndPoint().ToString(),
                                RCClientAction.updG);

                        //----------------------------------------------------

                        //
                        
                        Send(session,

                             XmlInstruction.fengBao(ServerAction.moduleVarsUpdate, roomXml)

                             );

                        

                        //
                        Log.WriteStrBySend(ServerAction.moduleVarsUpdate, strIpPort);


                    }
                    else
                    {

                        Send(session,

                             XmlInstruction.fengBao(ServerAction.moduleVarsUpdateKO, setVarsStatus[1])

                             );

                        //
                        Log.WriteStrBySend(ServerAction.moduleVarsUpdateKO, strIpPort);


                    }


                }



            }
            catch (Exception exd)
            {

                Log.WriteStrByException(CLASS_NAME, "setModuleVars", exd.Message, exd.Source, exd.StackTrace);

            }
        }
Пример #28
0
        public void doorProofKO(Socket session, XmlDocument doc, SessionMessage item)
        {

            Log.WriteStr(
                 SR.GetString(SR.getcert_vali_ko(), session.RemoteEndPoint.ToString())
             );
        }
Пример #29
0
        public void doorPubAuMsg(AppSession session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                string strIpPort = session.RemoteEndPoint.ToString();

                //<msg t="sys"><body action="pubMsg" r="7"><txt><![CDATA[dffddf]]></txt></body></msg>
                XmlNode node = doc.SelectSingleNode("/msg/body");

                string roomId = node.Attributes["r"].Value;

                //安全检测
                if (!logicHasRoom(int.Parse(roomId))
                     )
                {
                    return;
                }

                if (!logicHasUserInRoom(session.RemoteEndPoint.ToString(), int.Parse(roomId))
                    )
                {
                    return;
                }

                XmlNode node2 = doc.SelectSingleNode("/msg/body/txt");

                string saction = ServerAction.pubAuMsg;
                string contentXml = "<room id='" + roomId + "'>" + node2.OuterXml + "</room>";

                netTurnRoom(strIpPort, int.Parse(roomId), saction, contentXml);

                //log
                Log.WriteStrByTurn(SR.Room_displayName, roomId, saction);
            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME, "doorSetRvars", exd.Message, exd.Source, exd.Message);
            }


        }
Пример #30
0
        public void doorLoadGOK(Socket session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                    XmlNode node = doc.SelectSingleNode("/msg/body");

                    string userStrIpPort = node.ChildNodes[0].InnerText;

                    string g = node.ChildNodes[1].InnerText;

                    string id_sql = node.ChildNodes[1].Attributes["id_sql"].Value;

                    //
                    string saction = ServerAction.gOK;

                    //回复
                    //注意这里的session是上面的usersession,要判断是否还在线
                    AppSession userSession = CLIENTAcceptor.getSession(userStrIpPort);

                    //如果不在线则略过发送
                    if (null != userSession)
                    {
                        //更新
                            if (CLIENTAcceptor.hasUser(userStrIpPort))
                            {
                                IUserModel u = CLIENTAcceptor.getUser(userStrIpPort);

                                //以免引发不必要的异常,方便测试
                                if ("" != g)
                                {
                                    u.setG(Convert.ToInt32(g));
                                }
                                
                                //本地金点,id是32位md5值
                                //其它数据库是int型
                                if ("" != id_sql)
                                {
                                    if (id_sql.IndexOf('a') >= 0 ||
                                        id_sql.IndexOf('b') >= 0 ||
                                        id_sql.IndexOf('c') >= 0 ||
                                        id_sql.IndexOf('d') >= 0 ||
                                        id_sql.IndexOf('e') >= 0 ||
                                        id_sql.IndexOf('f') >= 0 ||
                                        id_sql.IndexOf('g') >= 0 ||
                                        id_sql.IndexOf('h') >= 0 ||
                                        id_sql.IndexOf('i') >= 0 ||
                                        id_sql.IndexOf('j') >= 0 ||
                                        id_sql.IndexOf('k') >= 0 ||
                                        id_sql.IndexOf('l') >= 0 ||
                                        id_sql.IndexOf('m') >= 0 ||
                                        id_sql.IndexOf('n') >= 0 ||
                                        id_sql.IndexOf('o') >= 0 ||
                                        id_sql.IndexOf('p') >= 0 ||
                                        id_sql.IndexOf('q') >= 0 ||
                                        id_sql.IndexOf('r') >= 0 ||
                                        id_sql.IndexOf('s') >= 0 ||
                                        id_sql.IndexOf('t') >= 0 ||
                                        id_sql.IndexOf('u') >= 0 ||
                                        id_sql.IndexOf('v') >= 0 ||
                                        id_sql.IndexOf('w') >= 0 ||
                                        id_sql.IndexOf('x') >= 0 ||
                                        id_sql.IndexOf('y') >= 0 ||
                                        id_sql.IndexOf('z') >= 0
                                        )
                                    {
                                        u.setId(id_sql);
                                    }
                                    else
                                    {

                                        u.setId_SQL(Convert.ToInt64(id_sql));
                                    }

                                }//end if
                            }


                            //
                            Send(userSession,

                               XmlInstruction.fengBao(saction, "<g id_sql='" + id_sql + "'>" + g + "</g>")

                               );

                            //
                            Log.WriteStrBySend(saction, userStrIpPort);
                        

                    }
                    else
                    {
                        Log.WriteStrBySendFailed(saction, userStrIpPort);
                    }//end if
               
            }
            catch (Exception exd)
            {
                //这个地方经常报Input string错,因此加强打印
                //Log.WriteStrByException(CLASS_NAME, "doorLoadGOK", exd.Message + " " + doc.InnerText + " " + exd.StackTrace);

                Log.WriteStrByException(CLASS_NAME, "doorLoadGOK", "[" + exd.Message + "," + doc.InnerText + "]");
            }
        }