コード例 #1
0
        public override void OnGet(HttpRequest request, HttpResponse response)
        {
            int    statusCode  = 400;
            string requestType = "";
            string content     = "";

            try
            {
                //获取客户端传递的参数
                requestType = request.Params["requestType"];
                // 设置返回信息

                if (requestType != null && requestType != "")
                {
                    switch (requestType)
                    {
                    case "LinkServer":
                    {
                        string link = request.Params["link"];
                        if (link != null && link == "link")
                        {
                            content = "LinkServer Success";
                        }
                        else
                        {
                            content = "LinkServer Failed";
                        }
                    }
                    break;

                    case "Login":
                    {
                        string userId  = request.Params["userId"];
                        string userPwd = request.Params["userPwd"];
                        if (userId != null && userId != "" && userPwd != null && userPwd != "")
                        {
                            GameUser gameUser = DaoFactory.GetGameUserDaoImp().Login(userId, userPwd);
                            if (gameUser != null && gameUser.userId != null)
                            {
                                if (gameUser.userId != "")
                                {
                                    content = gameUser.userId + "@@@" + gameUser.userPwd + "@@@" + gameUser.userName;
                                }
                                else
                                {
                                    content = "Login Failed";
                                }
                            }
                            else
                            {
                                content = "Login Failed";
                            }
                        }
                    }
                    break;

                    case "InsertGameUser":
                    {
                        string userId  = request.Params["userId"];
                        string userPwd = request.Params["userPwd"];
                        if (userId != null && userId != "" && userPwd != null && userPwd != "")
                        {
                            GameUser gameUser = new GameUser(userId, userPwd, "默认名字");
                            bool     isInsert = DaoFactory.GetGameUserDaoImp().InsertGameUser(gameUser);
                            if (isInsert)
                            {
                                content = "InsertGameUser Success";
                            }
                            else
                            {
                                content = "InsertGameUser Failed";
                            }
                        }
                        else
                        {
                            content = "InsertGameUser Failed";
                        }
                    }
                    break;

                    case "GetAGamePlayer":
                    {
                        string userId = request.Params["userId"];
                        if (userId != null && userId != "")
                        {
                            GamePlayer gamePlayer = DaoFactory.GetGamePlayerDaoImp().GetAGamePlayer(userId);
                            if (gamePlayer != null && gamePlayer.userId != null)
                            {
                                if (gamePlayer.userId != "")
                                {
                                    content = gamePlayer.userId + "@@@" +
                                              gamePlayer.userServer + "@@@" +
                                              gamePlayer.playerId + "@@@" +
                                              gamePlayer.playerPrefabName + "@@@" +
                                              gamePlayer.playerName + "@@@" +
                                              gamePlayer.playerLevel + "@@@" +
                                              gamePlayer.playerNowExp + "@@@" +
                                              gamePlayer.playerUpExp + "@@@" +
                                              gamePlayer.playerNowHP + "@@@" +
                                              gamePlayer.playerNowMP + "@@@" +
                                              gamePlayer.playerMoveSpeed + "@@@" +
                                              gamePlayer.playerRunSpeed + "@@@" +
                                              gamePlayer.playerElement + "@@@" +
                                              gamePlayer.playerMaxHP + "@@@" +
                                              gamePlayer.playerMaxMP + "@@@" +
                                              gamePlayer.playerAttack + "@@@" +
                                              gamePlayer.playerElementHurt + "@@@" +
                                              gamePlayer.playerAttackHit + "@@@" +
                                              gamePlayer.playerAttackCrit + "@@@" +
                                              gamePlayer.playerCritHurt + "@@@" +
                                              gamePlayer.playerDefend + "@@@" +
                                              gamePlayer.playerAgility + "@@@" +
                                              gamePlayer.playerMagicDefend;
                                }
                                else
                                {
                                    content = "GetAGamePlayer Failed";
                                }
                            }
                            else
                            {
                                content = "GetAGamePlayer Failed";
                            }
                        }
                    }
                    break;

                    case "GetGamePlayers":
                    {
                        string userId = request.Params["userId"];
                        if (userId != null && userId != "")
                        {
                            List <GamePlayer> gamePlayers = DaoFactory.GetGamePlayerDaoImp().GetServerGamePlayer(userId);
                            GamePlayer        gamePlayer  = DaoFactory.GetGamePlayerDaoImp().GetAGamePlayer(userId);
                            if (gamePlayer != null && gamePlayer.userId != null)
                            {
                                if (gamePlayer.userId != "")
                                {
                                    content = gamePlayer.userId + "@@@" +
                                              gamePlayer.userServer + "@@@" +
                                              gamePlayer.playerId + "@@@" +
                                              gamePlayer.playerPrefabName + "@@@" +
                                              gamePlayer.playerName + "@@@" +
                                              gamePlayer.playerLevel + "@@@" +
                                              gamePlayer.playerNowExp + "@@@" +
                                              gamePlayer.playerUpExp + "@@@" +
                                              gamePlayer.playerNowHP + "@@@" +
                                              gamePlayer.playerNowMP + "@@@" +
                                              gamePlayer.playerMoveSpeed + "@@@" +
                                              gamePlayer.playerRunSpeed + "@@@" +
                                              gamePlayer.playerElement + "@@@" +
                                              gamePlayer.playerMaxHP + "@@@" +
                                              gamePlayer.playerMaxMP + "@@@" +
                                              gamePlayer.playerAttack + "@@@" +
                                              gamePlayer.playerElementHurt + "@@@" +
                                              gamePlayer.playerAttackHit + "@@@" +
                                              gamePlayer.playerAttackCrit + "@@@" +
                                              gamePlayer.playerCritHurt + "@@@" +
                                              gamePlayer.playerDefend + "@@@" +
                                              gamePlayer.playerAgility + "@@@" +
                                              gamePlayer.playerMagicDefend;
                                }
                                else
                                {
                                    content = "GetAGamePlayer Failed";
                                }
                            }
                            else
                            {
                                content = "GetAGamePlayer Failed";
                            }
                        }
                    }
                    break;

                    case "GetServerGamePlayer":
                    {
                        string userId = request.Params["userId"];
                        if (userId != null && userId != "")
                        {
                            List <GamePlayer> gamePlayers = DaoFactory.GetGamePlayerDaoImp().GetServerGamePlayer(userId);
                            if (gamePlayers.Count > 0)
                            {
                                for (int i = 0; i < gamePlayers.Count; i++)
                                {
                                    content += gamePlayers[i].userId + "@@@" +
                                               gamePlayers[i].userServer + "@@@" +
                                               gamePlayers[i].playerId + "@@@" +
                                               gamePlayers[i].playerPrefabName + "@@@" +
                                               gamePlayers[i].playerName + "@@@" +
                                               gamePlayers[i].playerLevel + "@@@" +
                                               gamePlayers[i].playerNowExp + "@@@" +
                                               gamePlayers[i].playerUpExp + "@@@" +
                                               gamePlayers[i].playerNowHP + "@@@" +
                                               gamePlayers[i].playerNowMP + "@@@" +
                                               gamePlayers[i].playerMoveSpeed + "@@@" +
                                               gamePlayers[i].playerRunSpeed + "@@@" +
                                               gamePlayers[i].playerElement + "@@@" +
                                               gamePlayers[i].playerMaxHP + "@@@" +
                                               gamePlayers[i].playerMaxMP + "@@@" +
                                               gamePlayers[i].playerAttack + "@@@" +
                                               gamePlayers[i].playerElementHurt + "@@@" +
                                               gamePlayers[i].playerAttackHit + "@@@" +
                                               gamePlayers[i].playerAttackCrit + "@@@" +
                                               gamePlayers[i].playerCritHurt + "@@@" +
                                               gamePlayers[i].playerDefend + "@@@" +
                                               gamePlayers[i].playerAgility + "@@@" +
                                               gamePlayers[i].playerMagicDefend + "@@@" +
                                               gamePlayers[i].playerGCoins + "@@@" +
                                               gamePlayers[i].playerSCoins + "@@@";
                                }
                                content += gamePlayers.Count.ToString();
                            }
                            else
                            {
                                content = "GetServerGamePlayer Failed";
                            }
                        }
                    }
                    break;

                    case "InsertGamePlayer":
                    {
                        string userId           = request.Params["userId"];
                        string userServer       = request.Params["userServer"];
                        string playerId         = request.Params["playerId"];
                        string playerPrefabName = request.Params["playerPrefabName"];
                        string playerName       = request.Params["playerName"];

                        if (DaoFactory.GetGamePlayerDaoImp().IsExistPlayerName(playerName))
                        {
                            content = "Duplicate PlayerName";
                            break;
                        }

                        GamePlayer gamePlayer = null;
                        switch (playerPrefabName)
                        {
                        case "Eri":
                        case "Naoko":
                        case "Riko":
                            gamePlayer = new GamePlayer(userId, userServer, playerId, playerPrefabName, playerName,
                                                        PlayerBasicData.playerLevel,
                                                        PlayerBasicData.playerNowExp,
                                                        PlayerBasicData.playerUpExp,
                                                        PlayerBasicData.playerNowHP,
                                                        (int)(PlayerBasicData.playerNowMP * PlayerBasicData.SwordBsic),
                                                        PlayerBasicData.playerMoveSpeed,
                                                        PlayerBasicData.playerRunSpeed,
                                                        PlayerBasicData.playerElement,
                                                        PlayerBasicData.playerMaxHP,
                                                        (int)(PlayerBasicData.playerMaxMP * PlayerBasicData.SwordBsic),
                                                        PlayerBasicData.playerAttack,
                                                        PlayerBasicData.playerElementHurt,
                                                        PlayerBasicData.playerAttackHit,
                                                        PlayerBasicData.playerAttackCrit,
                                                        PlayerBasicData.playerCritHurt,
                                                        PlayerBasicData.playerDefend,
                                                        PlayerBasicData.playerAgility,
                                                        PlayerBasicData.playerMagicDefend,
                                                        PlayerBasicData.playerGCoins,
                                                        PlayerBasicData.playerSCoins);
                            break;

                        case "BladeM":
                        case "BladeW":
                            gamePlayer = new GamePlayer(userId, userServer, playerId, playerPrefabName, playerName,
                                                        PlayerBasicData.playerLevel,
                                                        PlayerBasicData.playerNowExp,
                                                        PlayerBasicData.playerUpExp,
                                                        (int)(PlayerBasicData.playerNowHP * PlayerBasicData.SwordBsic),
                                                        PlayerBasicData.playerNowMP,
                                                        PlayerBasicData.playerMoveSpeed,
                                                        PlayerBasicData.playerRunSpeed,
                                                        PlayerBasicData.playerElement,
                                                        (int)(PlayerBasicData.playerMaxHP * PlayerBasicData.SwordBsic),
                                                        PlayerBasicData.playerMaxMP,
                                                        PlayerBasicData.playerAttack,
                                                        PlayerBasicData.playerElementHurt,
                                                        PlayerBasicData.playerAttackHit,
                                                        PlayerBasicData.playerAttackCrit,
                                                        PlayerBasicData.playerCritHurt,
                                                        (int)(PlayerBasicData.playerDefend * PlayerBasicData.SwordBsic),
                                                        (int)(PlayerBasicData.playerAgility * PlayerBasicData.SwordBsic),
                                                        PlayerBasicData.playerMagicDefend,
                                                        PlayerBasicData.playerGCoins,
                                                        PlayerBasicData.playerSCoins);
                            break;
                        }

                        if (userId != null && userId != "")
                        {
                            if (gamePlayer != null)
                            {
                                DaoFactory.GetGamePlayerDaoImp().InsertGamePlayer(gamePlayer);
                                if (gamePlayer.playerId != null && gamePlayer.playerId != "")
                                {
                                    content = "InsertGamePlayer Success";

                                    switch (playerPrefabName)
                                    {
                                    case "Eri":
                                    case "Naoko":
                                    case "Riko":
                                        DaoFactory.GetGameGoodDaoImp().InsertGameGood(GoodBasicData.GetGood_Magic_Weapon_武器(playerId, 0));

                                        break;

                                    case "BladeM":
                                    case "BladeW":
                                        DaoFactory.GetGameGoodDaoImp().InsertGameGood(GoodBasicData.GetGood_Sword_Weapon_武器(playerId, 0));

                                        break;
                                    }
                                    DaoFactory.GetGameGoodDaoImp().InsertGameGood(GoodBasicData.GetGood_Weapon_首饰(playerId, 1));
                                    DaoFactory.GetGameGoodDaoImp().InsertGameGood(GoodBasicData.GetGood_Consumable_HP(playerId, 2));
                                    DaoFactory.GetGameGoodDaoImp().InsertGameGood(GoodBasicData.GetGood_Consumable_MP(playerId, 3));
                                    DaoFactory.GetGameGoodDaoImp().InsertGameGood(GoodBasicData.GetGood_Armor_上衣(playerId, 4));
                                }
                                else
                                {
                                    content = "InsertGamePlayer Failed";
                                }
                            }
                            else
                            {
                                content = "InsertGamePlayer Failed";
                            }
                        }
                    }
                    break;

                    case "DeleteGamePlayer":
                    {
                        string playerId = request.Params["playerId"];

                        if (playerId != null && playerId != "")
                        {
                            bool isDelete = DaoFactory.GetGamePlayerDaoImp().DeleteGamePlayer(playerId);
                            if (isDelete)
                            {
                                content = "DeleteGamePlayer Success";
                                DaoFactory.GetGameGoodDaoImp().DeleteGameGood(playerId);
                            }
                            else
                            {
                                content = "DeleteGamePlayer Failed";
                            }
                        }
                    }
                    break;

                    case "GetAllGamePlayerGameGood":
                    {
                        string          playerId  = request.Params["playerId"];
                        List <GameGood> gameGoods = DaoFactory.GetGameGoodDaoImp().GetAllGamePlayerGameGood(playerId);
                        if (playerId != null && playerId != "")
                        {
                            if (gameGoods != null && gameGoods.Count >= 0)
                            {
                                for (int i = 0; i < gameGoods.Count; i++)
                                {
                                    content +=
                                        gameGoods[i].goodId + "@@@" +
                                        gameGoods[i].goodName + "@@@" +
                                        gameGoods[i].goodDescrip + "@@@" +
                                        gameGoods[i].goodBuyPrice + "@@@" +
                                        gameGoods[i].goodSellPrice + "@@@" +
                                        gameGoods[i].goodIconPath + "@@@" +
                                        gameGoods[i].goodItemType + "@@@" +
                                        gameGoods[i].goodCount + "@@@" +
                                        gameGoods[i].goodType + "@@@" +
                                        gameGoods[i].goodEquip + "@@@" +
                                        gameGoods[i].ArmorBlood + "@@@" +
                                        gameGoods[i].ArmorDefend + "@@@" +
                                        gameGoods[i].ArmorAgility + "@@@" +
                                        gameGoods[i].ConsumableBcakHP + "@@@" +
                                        gameGoods[i].ConsumableBcakMP + "@@@" +
                                        gameGoods[i].WeaponDamage + "@@@";
                                    if (i == gameGoods.Count - 1)
                                    {
                                        content += gameGoods[i].WeaponMP;
                                    }
                                    else
                                    {
                                        content += gameGoods[i].WeaponMP + "@@@";
                                    }
                                }
                            }
                            else
                            {
                                content = "GetAllGamePlayerGameGood Failed";
                            }
                        }
                        else
                        {
                            content = "GetAllGamePlayerGameGood Failed";
                        }
                    }
                    break;

                    default:
                        Log("参数解析错误");
                        break;
                    }
                }

                StreamWriter sw = new StreamWriter(path, true);
                sw.WriteLine("[" + DateTime.Now + "] request: " + requestType + " response: " + content);
                sw.Close();

                //构造响应报文
                response.SetContent(content);
                response.Content_Encoding  = "utf-8";
                response.StatusCode        = statusCode.ToString();
                response.Content_Type      = "text/html; charset=UTF-8";
                response.Headers["Server"] = "ExampleServer";
                //发送响应
                response.Send();
            }
            catch (Exception ex)
            {
                Log(ex);
            }
            finally
            {
                statusCode++;
                requestType = "";
                content     = "";
            }
        }
コード例 #2
0
        /// <summary>
        /// 接收指定客户端Socket的消息
        /// </summary>
        /// <param name="clientSocket"></param>
        private static void RecieveMessage(object clientSocket)
        {
            Socket mClientSocket = (Socket)clientSocket;

            string[] data        = null;
            string   requestType = "";
            string   content     = "";

            while (true)
            {
                try
                {
                    int        receiveNumber = mClientSocket.Receive(result);
                    ByteBuffer buff          = new ByteBuffer(result);
                    int        len           = buff.ReadShort();
                    string     receiveData   = buff.ReadString();
                    Console.WriteLine("[{0}]{1}", mClientSocket.RemoteEndPoint.ToString(), receiveData);
                    data = System.Text.RegularExpressions.Regex.Split(receiveData, "@@@");

                    // 设置返回信息
                    requestType = data[0];
                    if (requestType != null && requestType != "")
                    {
                        switch (requestType)
                        {
                        case "LinkServer":
                        {
                            string link = data[1];
                            if (link != null && link == "link")
                            {
                                content = "LinkServer Success";
                            }
                            else
                            {
                                content = "LinkServer Failed";
                            }
                        }
                        break;

                        case "Login":
                        {
                            string userId  = data[1];
                            string userPwd = data[2];
                            if (userId != null && userId != "" && userPwd != null && userPwd != "")
                            {
                                GameUser gameUser = DaoFactory.GetGameUserDaoImp().Login(userId, userPwd);
                                if (gameUser != null && gameUser.userId != null)
                                {
                                    if (gameUser.userId != "")
                                    {
                                        content = gameUser.userId + "@@@" + gameUser.userPwd + "@@@" + gameUser.userName;
                                    }
                                    else
                                    {
                                        content = "Login Failed";
                                    }
                                }
                                else
                                {
                                    content = "Login Failed";
                                }
                            }
                        }
                        break;

                        case "InsertGameUser":
                        {
                            string userId  = data[1];
                            string userPwd = data[2];
                            if (userId != null && userId != "" && userPwd != null && userPwd != "")
                            {
                                GameUser gameUser = new GameUser(userId, userPwd, "默认名字");
                                bool     isInsert = DaoFactory.GetGameUserDaoImp().InsertGameUser(gameUser);
                                if (isInsert)
                                {
                                    content = "InsertGameUser Success";
                                }
                                else
                                {
                                    content = "InsertGameUser Failed";
                                }
                            }
                            else
                            {
                                content = "InsertGameUser Failed";
                            }
                        }
                        break;

                        case "GetAGamePlayer":
                        {
                            string userId = data[1];
                            if (userId != null && userId != "")
                            {
                                GamePlayer gamePlayer = DaoFactory.GetGamePlayerDaoImp().GetAGamePlayer(userId);
                                if (gamePlayer != null && gamePlayer.userId != null && gamePlayer.userId != "")
                                {
                                    content = gamePlayer.userId + "@@@" +
                                              gamePlayer.userServer + "@@@" +
                                              gamePlayer.playerId + "@@@" +
                                              gamePlayer.playerPrefabName + "@@@" +
                                              gamePlayer.playerName + "@@@" +
                                              gamePlayer.playerLevel + "@@@" +
                                              gamePlayer.playerNowExp + "@@@" +
                                              gamePlayer.playerUpExp + "@@@" +
                                              gamePlayer.playerNowHP + "@@@" +
                                              gamePlayer.playerNowMP + "@@@" +
                                              gamePlayer.playerMoveSpeed + "@@@" +
                                              gamePlayer.playerRunSpeed + "@@@" +
                                              gamePlayer.playerElement + "@@@" +
                                              gamePlayer.playerMaxHP + "@@@" +
                                              gamePlayer.playerMaxMP + "@@@" +
                                              gamePlayer.playerAttack + "@@@" +
                                              gamePlayer.playerElementHurt + "@@@" +
                                              gamePlayer.playerAttackHit + "@@@" +
                                              gamePlayer.playerAttackCrit + "@@@" +
                                              gamePlayer.playerCritHurt + "@@@" +
                                              gamePlayer.playerDefend + "@@@" +
                                              gamePlayer.playerAgility + "@@@" +
                                              gamePlayer.playerMagicDefend;
                                }
                                else
                                {
                                    content = "GetAGamePlayer Failed";
                                }
                            }
                        }
                        break;

                        case "GetServerGamePlayer":
                        {
                            string userId = data[1];
                            if (userId != null && userId != "")
                            {
                                List <GamePlayer> gamePlayers = DaoFactory.GetGamePlayerDaoImp().GetServerGamePlayer(userId);
                                if (gamePlayers.Count > 0)
                                {
                                    for (int i = 0; i < gamePlayers.Count; i++)
                                    {
                                        content += gamePlayers[i].userId + "@@@" +
                                                   gamePlayers[i].userServer + "@@@" +
                                                   gamePlayers[i].playerId + "@@@" +
                                                   gamePlayers[i].playerPrefabName + "@@@" +
                                                   gamePlayers[i].playerName + "@@@" +
                                                   gamePlayers[i].playerLevel + "@@@" +
                                                   gamePlayers[i].playerNowExp + "@@@" +
                                                   gamePlayers[i].playerUpExp + "@@@" +
                                                   gamePlayers[i].playerNowHP + "@@@" +
                                                   gamePlayers[i].playerNowMP + "@@@" +
                                                   gamePlayers[i].playerMoveSpeed + "@@@" +
                                                   gamePlayers[i].playerRunSpeed + "@@@" +
                                                   gamePlayers[i].playerElement + "@@@" +
                                                   gamePlayers[i].playerMaxHP + "@@@" +
                                                   gamePlayers[i].playerMaxMP + "@@@" +
                                                   gamePlayers[i].playerAttack + "@@@" +
                                                   gamePlayers[i].playerElementHurt + "@@@" +
                                                   gamePlayers[i].playerAttackHit + "@@@" +
                                                   gamePlayers[i].playerAttackCrit + "@@@" +
                                                   gamePlayers[i].playerCritHurt + "@@@" +
                                                   gamePlayers[i].playerDefend + "@@@" +
                                                   gamePlayers[i].playerAgility + "@@@" +
                                                   gamePlayers[i].playerMagicDefend + "@@@" +
                                                   gamePlayers[i].playerGCoins + "@@@" +
                                                   gamePlayers[i].playerSCoins + "@@@";
                                    }
                                    content += gamePlayers.Count.ToString();
                                }
                                else
                                {
                                    content = "GetServerGamePlayer Failed";
                                }
                            }
                        }
                        break;

                        case "InsertGamePlayer":
                        {
                            string userId           = data[1];
                            string userServer       = data[2];
                            string playerId         = data[3];
                            string playerPrefabName = data[4];
                            string playerName       = data[5];
                            if (DaoFactory.GetGamePlayerDaoImp().IsExistPlayerName(playerName))
                            {
                                content = "Duplicate PlayerName";
                                break;
                            }

                            GamePlayer gamePlayer = null;
                            switch (playerPrefabName)
                            {
                            case "Eri":
                            case "Naoko":
                            case "Riko":
                                gamePlayer = new GamePlayer(userId, userServer, playerId, playerPrefabName, playerName,
                                                            PlayerBasicData.playerLevel,
                                                            PlayerBasicData.playerNowExp,
                                                            PlayerBasicData.playerUpExp,
                                                            PlayerBasicData.playerNowHP,
                                                            (int)(PlayerBasicData.playerNowMP * PlayerBasicData.SwordBsic),
                                                            PlayerBasicData.playerMoveSpeed,
                                                            PlayerBasicData.playerRunSpeed,
                                                            PlayerBasicData.playerElement,
                                                            PlayerBasicData.playerMaxHP,
                                                            (int)(PlayerBasicData.playerMaxMP * PlayerBasicData.SwordBsic),
                                                            PlayerBasicData.playerAttack,
                                                            PlayerBasicData.playerElementHurt,
                                                            PlayerBasicData.playerAttackHit,
                                                            PlayerBasicData.playerAttackCrit,
                                                            PlayerBasicData.playerCritHurt,
                                                            PlayerBasicData.playerDefend,
                                                            PlayerBasicData.playerAgility,
                                                            PlayerBasicData.playerMagicDefend,
                                                            PlayerBasicData.playerGCoins,
                                                            PlayerBasicData.playerSCoins);
                                break;

                            case "BladeM":
                            case "BladeW":
                                gamePlayer = new GamePlayer(userId, userServer, playerId, playerPrefabName, playerName,
                                                            PlayerBasicData.playerLevel,
                                                            PlayerBasicData.playerNowExp,
                                                            PlayerBasicData.playerUpExp,
                                                            (int)(PlayerBasicData.playerNowHP * PlayerBasicData.SwordBsic),
                                                            PlayerBasicData.playerNowMP,
                                                            PlayerBasicData.playerMoveSpeed,
                                                            PlayerBasicData.playerRunSpeed,
                                                            PlayerBasicData.playerElement,
                                                            (int)(PlayerBasicData.playerMaxHP * PlayerBasicData.SwordBsic),
                                                            PlayerBasicData.playerMaxMP,
                                                            PlayerBasicData.playerAttack,
                                                            PlayerBasicData.playerElementHurt,
                                                            PlayerBasicData.playerAttackHit,
                                                            PlayerBasicData.playerAttackCrit,
                                                            PlayerBasicData.playerCritHurt,
                                                            (int)(PlayerBasicData.playerDefend * PlayerBasicData.SwordBsic),
                                                            (int)(PlayerBasicData.playerAgility * PlayerBasicData.SwordBsic),
                                                            PlayerBasicData.playerMagicDefend,
                                                            PlayerBasicData.playerGCoins,
                                                            PlayerBasicData.playerSCoins);
                                break;
                            }

                            if (userId != null && userId != "")
                            {
                                if (gamePlayer != null)
                                {
                                    DaoFactory.GetGamePlayerDaoImp().InsertGamePlayer(gamePlayer);
                                    if (gamePlayer.playerId != null && gamePlayer.playerId != "")
                                    {
                                        content = "InsertGamePlayer Success";
                                        switch (playerPrefabName)
                                        {
                                        case "Eri":
                                        case "Naoko":
                                        case "Riko":
                                            DaoFactory.GetGameGoodDaoImp().InsertGameGood(GoodBasicData.GetGood_Magic_Weapon_武器(playerId, 0));

                                            break;

                                        case "BladeM":
                                        case "BladeW":
                                            DaoFactory.GetGameGoodDaoImp().InsertGameGood(GoodBasicData.GetGood_Sword_Weapon_武器(playerId, 0));

                                            break;
                                        }
                                        DaoFactory.GetGameGoodDaoImp().InsertGameGood(GoodBasicData.GetGood_Weapon_首饰(playerId, 1));
                                        DaoFactory.GetGameGoodDaoImp().InsertGameGood(GoodBasicData.GetGood_Consumable_HP(playerId, 2));
                                        DaoFactory.GetGameGoodDaoImp().InsertGameGood(GoodBasicData.GetGood_Consumable_MP(playerId, 3));
                                        DaoFactory.GetGameGoodDaoImp().InsertGameGood(GoodBasicData.GetGood_Armor_上衣(playerId, 4));
                                    }
                                    else
                                    {
                                        content = "InsertGamePlayer Failed";
                                    }
                                }
                                else
                                {
                                    content = "InsertGamePlayer Failed";
                                }
                            }
                        }
                        break;

                        case "DeleteGamePlayer":
                        {
                            string playerId = data[1];

                            if (playerId != null && playerId != "")
                            {
                                bool isDelete = DaoFactory.GetGamePlayerDaoImp().DeleteGamePlayer(playerId);
                                if (isDelete)
                                {
                                    content = "DeleteGamePlayer Success";
                                    DaoFactory.GetGameGoodDaoImp().DeleteGameGood(playerId);
                                }
                                else
                                {
                                    content = "DeleteGamePlayer Failed";
                                }
                            }
                        }
                        break;

                        case "GetAllGamePlayerGameGood":
                        {
                            string          playerId  = data[1];
                            List <GameGood> gameGoods = DaoFactory.GetGameGoodDaoImp().GetAllGamePlayerGameGood(playerId);
                            if (playerId != null && playerId != "")
                            {
                                if (gameGoods != null && gameGoods.Count >= 0)
                                {
                                    for (int i = 0; i < gameGoods.Count; i++)
                                    {
                                        content +=
                                            gameGoods[i].goodId + "@@@" +
                                            gameGoods[i].goodName + "@@@" +
                                            gameGoods[i].goodDescrip + "@@@" +
                                            gameGoods[i].goodBuyPrice + "@@@" +
                                            gameGoods[i].goodSellPrice + "@@@" +
                                            gameGoods[i].goodIconPath + "@@@" +
                                            gameGoods[i].goodItemType + "@@@" +
                                            gameGoods[i].goodCount + "@@@" +
                                            gameGoods[i].goodType + "@@@" +
                                            gameGoods[i].goodEquip + "@@@" +
                                            gameGoods[i].ArmorBlood + "@@@" +
                                            gameGoods[i].ArmorDefend + "@@@" +
                                            gameGoods[i].ArmorAgility + "@@@" +
                                            gameGoods[i].ConsumableBcakHP + "@@@" +
                                            gameGoods[i].ConsumableBcakMP + "@@@" +
                                            gameGoods[i].WeaponDamage + "@@@";
                                        if (i == gameGoods.Count - 1)
                                        {
                                            content += gameGoods[i].WeaponMP;
                                        }
                                        else
                                        {
                                            content += gameGoods[i].WeaponMP + "@@@";
                                        }
                                    }
                                }
                                else
                                {
                                    content = "GetAllGamePlayerGameGood Failed";
                                }
                            }
                            else
                            {
                                content = "GetAllGamePlayerGameGood Failed";
                            }
                        }
                        break;

                        default:

                            break;
                        }


                        StreamWriter sw = new StreamWriter(path, true);
                        sw.WriteLine("[" + DateTime.Now + "] [" + mClientSocket.RemoteEndPoint.ToString() + "] request: " + requestType + " response: " + content);
                        sw.Close();

                        SendClientMessage(mClientSocket, content);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    mClientSocket.Shutdown(SocketShutdown.Both);
                    mClientSocket.Close();
                    break;
                }
                finally
                {
                    content     = "";
                    data        = null;
                    requestType = "";
                }
            }
        }