Exemplo n.º 1
0
        static void OperationUploadPacket(CardPeer self, OperationRequest request, SendParameters send)
        {
            if (!Operations.Validate(request))
            {
                return;
            }
            if (self._gameUser == null)
            {
                return;
            }
            OperationResponse response = new OperationResponse(request.OperationCode);
            byte ret = 0;

            if (0 == (self._gameUser.Auth & (uint)UserAuth.DESIGNER))
            {
                ret = 1;
            }
            else
            {
                CardServer app = (CardServer)(ApplicationBase.Instance);
                Message    msg = new Message((byte)UserCenter.MessageCodes.MSG_SAVE_PACKET);
                msg.Param = request[0];
                app.Center.SendMessage(msg);
            }
            response.Parameters = new Dictionary <byte, object>()
            {
                { 0, ret },
            };
            self.SendOperationResponse(response, send);
        }
Exemplo n.º 2
0
        static void OperationLogin(CardPeer self, OperationRequest request, SendParameters sendParameters)
        {
            if (!Operations.Validate(request))
            {
                return;
            }
            string usr, pwd;

            usr  = (string)request[0];
            pwd  = (string)request[1];
            pwd += "FANCY;STAR";
            MD5 md5hash = MD5.Create();

            byte []       data    = md5hash.ComputeHash(Encoding.UTF8.GetBytes(pwd));
            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < data.Length; ++i)
            {
                builder.Append(data[i].ToString("x2"));
            }
            pwd = builder.ToString();

            ArrayList al = new ArrayList();

            al.Add(self);
            al.Add(usr);
            al.Add(pwd);
            Message msg = new Message((byte)UserCenter.MessageCodes.MSG_LOGIN);

            msg.Param = al;
            CardServer app = (CardServer)(ApplicationBase.Instance);

            app.Center.SendMessage(msg);
        }
Exemplo n.º 3
0
        static void OperationEcho(CardPeer self, OperationRequest request, SendParameters sendParameters)
        {
            if (!Operations.Validate(request))
            {
                return;
            }
            string words    = (string)request[0];
            var    response = new OperationResponse(request.OperationCode);

            response.Parameters = new Dictionary <byte, object>()
            {
                { 0, words },
            };
            self.SendOperationResponse(response, sendParameters);
        }
Exemplo n.º 4
0
        static void MsgLoadPacket(UserCenter self, Message msg)
        {
            ArrayList al = msg.Param as ArrayList;

            if (al == null)
            {
                return;
            }
            CardPeer   peer     = al[0] as CardPeer;
            uint       revision = (uint)al[1];
            FileRecord file     = self._db.LoadPacket(revision);
            Message    ret      = new Message((byte)CardPeer.MessageCodes.MSG_LOAD_PACKET_RESULT);

            ret.Param = file;
            peer.SendMessage(ret);
        }
Exemplo n.º 5
0
        static void OperationDownloadPacket(CardPeer self, OperationRequest request, SendParameters send)
        {
            if (!Operations.Validate(request))
            {
                return;
            }
            if (self._gameUser == null)
            {
                return;
            }
            CardServer app = (CardServer)(ApplicationBase.Instance);
            Message    msg = new Message((byte)UserCenter.MessageCodes.MSG_LOAD_PACKET);

            msg.Param = request[0];
            app.Center.SendMessage(msg);
        }
Exemplo n.º 6
0
        static void OperationLogout(CardPeer self, OperationRequest request, SendParameters sendParameters)
        {
            if (!Operations.Validate(request))
            {
                return;
            }
            if (self._gameUser == null)
            {
                return;
            }
            CardServer app = (CardServer)(ApplicationBase.Instance);
            Message    msg = new Message((byte)UserCenter.MessageCodes.MSG_LOGOUT);

            msg.Param = self._gameUser.Email;
            app.Center.SendMessage(msg);
            self._gameUser = null;
        }
Exemplo n.º 7
0
        static void MsgLogin(UserCenter self, Message msg)
        {
            if (!(msg.Param is ArrayList))
            {
                return;
            }
            ArrayList al = (ArrayList)msg.Param;

            if (al.Count < 3)
            {
                return;
            }
            CardPeer peer = (CardPeer)al[0];
            string   usr  = (string)al[1];
            string   pwd  = (string)al[2];

            GameUser user = null;

            if (self._users.ContainsKey(usr))
            {
                user = self._users[usr];
            }
            else
            {
                user = self._db.ValidateUser(usr, pwd);
                if (user != null)
                {
                    self._users.Add(usr, user);
                }
                else if (log.IsDebugEnabled)                // user not found
                {
                    log.Debug(string.Format("User not found: name={0}, pwd={1}", usr, pwd));
                }
            }
            Message ret = new Message((byte)CardPeer.MessageCodes.MSG_LOGIN_RESULT);

            ret.Param = user;
            peer.SendMessage(ret);
        }
Exemplo n.º 8
0
        static void MsgLoadPacketResult(CardPeer self, Message msg)
        {
            FileRecord        file     = msg.Param as FileRecord;
            OperationResponse response = new OperationResponse((byte)Operations.Codes.OP_DOWNLOAD_PACKET);

            if (file != null)
            {
                response.Parameters = new Dictionary <byte, object>()
                {
                    { 0, file.Revision },
                    { 1, file.Content },
                };
            }
            else
            {
                response.Parameters = new Dictionary <byte, object>()
                {
                    { 0, 0 },
                };
            }
            self.SendOperationResponse(response, new SendParameters());
        }
Exemplo n.º 9
0
        static void MsgLoginResult(CardPeer self, Message msg)
        {
            int result;

            if (msg.Param is GameUser)
            {
                self._gameUser = (GameUser)msg.Param;
                result         = 0;
            }
            else
            {
                self._gameUser = null;
                result         = 1;
            }
            OperationResponse response = new OperationResponse((byte)Operations.Codes.OP_LOGIN);

            response.Parameters = new Dictionary <byte, object>()
            {
                { 0, (object)result },
            };
            self.SendOperationResponse(response, new SendParameters());
        }