Ejemplo n.º 1
0
    /// <summary>
    /// type=2,获取全部区服信息,主要获取大区名、IP、端口号,其他次要
    /// </summary>
    /// <returns></returns>
    public CallbackArgs GetGameServerInfosSqlite()
    {
        CallbackArgs     args   = new CallbackArgs();
        SqliteDataReader reader = SqliteHelper.Instance.Query("IchSagaDBAccount", "GameServer", new string[] { "*" });

        if (reader == null)
        {
            //reader为null,查询失败
            args = GenerateSqlErrorMsg();
            return(args);
        }
        if (!reader.HasRows) //没有查询到数据
        {
            args = GenerateErrorMsg(Constant.GAMESERVER_NO_SERVER_INFO, "网络错误,无区服信息!");
            return(args);
        }
        else
        {
            List <ClientEntityBase> list = new List <ClientEntityBase>();
            while (reader.Read())
            {
                GameServerEntity entity = new GameServerEntity();
                entity.Id          = reader.GetInt32(reader.GetOrdinal("Id"));
                entity.RunStatus   = reader.GetInt32(reader.GetOrdinal("RunStatus"));
                entity.IsRecommend = reader.GetBoolean(reader.GetOrdinal("IsRecommend"));
                entity.IsNew       = reader.GetBoolean(reader.GetOrdinal("IsNew"));
                entity.Name        = reader.GetString(reader.GetOrdinal("Name"));
                entity.Ip          = reader.GetString(reader.GetOrdinal("Ip"));
                entity.Port        = reader.GetInt32(reader.GetOrdinal("Port"));
                list.Add(entity);
            }
            args = GenerateSuccessMsg(list, "省略json,直接读list");
        }
        return(args);
    }
Ejemplo n.º 2
0
    public RetAccountEntity(AccountEntity accountEntity)
    {
        Id       = accountEntity.Id.Value;
        UserName = accountEntity.UserName;
        YuanBao  = accountEntity.Money;
        GameServerEntity serverEntity = GameServerCacheModel.Instance.GetEntity(accountEntity.LastLogOnServerId);

        //第一次登录 没有选择服务器,默认返回选择最新的服务器
        if (serverEntity == null)
        {
            List <GameServerEntity> list = GameServerCacheModel.Instance.GetList(isDesc: true);
            if (list != null && list.Count > 0)
            {
                LastServerId   = list[0].Id.Value;
                LastServerName = list[0].Name;
                LastServerIP   = list[0].Ip;
                LastServerPort = list[0].Port;
            }
        }
        else
        {
            LastServerId   = serverEntity.Id.Value;
            LastServerName = serverEntity.Name;
            LastServerIP   = serverEntity.Ip;
            LastServerPort = serverEntity.Port;
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// type=2,获取全部区服信息,主要获取大区名、IP、端口号,其他次要
    /// </summary>
    /// <returns></returns>
    public CallbackArgs GetGameServerInfos()
    {
        CallbackArgs args = new CallbackArgs();
        List <Dictionary <string, string> > results = XMLHelper.Instance.Query("GameServer.xml", "GameServer");

        if (results == null)
        {
            //reader为null,查询失败
            args = GenerateSqlErrorMsg();
            return(args);
        }
        if (results.Count == 0) //没有查询到数据
        {
            args = GenerateErrorMsg(Constant.GAMESERVER_NO_SERVER_INFO, "网络错误,无区服信息!");
            return(args);
        }
        else
        {
            List <ClientEntityBase> list = new List <ClientEntityBase>();
            for (int i = 0; i < results.Count; i++)
            {
                GameServerEntity entity = new GameServerEntity();
                entity.Id          = int.Parse(results[i]["Id"]);
                entity.RunStatus   = int.Parse(results[i]["RunStatus"]);
                entity.IsRecommend = bool.Parse(results[i]["IsRecommend"]);
                entity.IsNew       = bool.Parse(results[i]["IsNew"]);
                entity.Name        = results[i]["Name"];
                entity.Ip          = results[i]["Ip"];
                entity.Port        = int.Parse(results[i]["Port"]);
                list.Add(entity);
            }
            args = GenerateSuccessMsg(list, "省略json,直接读list");
        }
        return(args);
    }
Ejemplo n.º 4
0
    public RetAccountEntity(AccountEntity entity)
    {
        Id             = entity.Id.Value;
        UserName       = entity.UserName;
        YuanBao        = entity.Money;
        LastServerId   = entity.LastLogOnServerId;
        LastServerName = entity.LastLogOnServerName;

        if (LastServerId == 0)
        {
            MFReturnValue <List <GameServerEntity> > ret = GameServerCacheModel.Instance.GetPageList(isDesc: true, pageSize: 1);
            if (!ret.HasError)
            {
                List <GameServerEntity> lst = ret.Value;
                if (lst != null && lst.Count > 0)
                {
                    LastServerId        = lst[0].Id.Value;
                    LastServerName      = lst[0].Name;
                    LastServerIP        = lst[0].Ip;
                    LastServerPort      = lst[0].Port;
                    LastServerRunStatus = lst[0].RunStatus;
                }
            }
        }
        else
        {
            GameServerEntity entityGameServer = GameServerCacheModel.Instance.GetEntity(LastServerId);
            if (entityGameServer != null)
            {
                LastServerIP        = entityGameServer.Ip;
                LastServerPort      = entityGameServer.Port;
                LastServerRunStatus = entityGameServer.RunStatus;
            }
        }
    }
 /// <summary>
 /// 设置当前选择(点击)的大区详情页
 /// </summary>
 public void SetSelectedServerInfo(GameServerEntity entity)
 {
     if (mInfoView != null)
     {
         //把这个信息返回到EnterServerView上并显示
         //mInfoView.SetUI(entity);
     }
 }
Ejemplo n.º 6
0
 public void SetUI(GameServerEntity entity)
 {
     this.entity = entity;
     mServerStatus.overrideSprite = mServerStatusList[entity.RunStatus];
     mServerName.text             = entity.Name;
     mIp   = entity.Ip;
     mPort = entity.Port;
 }
 /// <summary>
 /// 详情页回调
 /// </summary>
 /// <param name="itemName"></param>
 private void OnServerInfoItemClick(GameServerEntity entity)
 {
     LogUtil.Log("点击了详情:" + entity.Name + "," + entity.Port);
     GlobalCache.Instance.Account_LastLoginServerId   = entity.Id;
     GlobalCache.Instance.Account_LastLoginServerName = entity.Name;
     GlobalCache.Instance.GameServer_CurrentIp        = entity.Ip;
     GlobalCache.Instance.GameServer_CurrentPort      = entity.Port;
     //实现OnInfoItemClick委托,进行传递值到EnterServerView上
     if (OnInfoItemClick != null)
     {
         OnInfoItemClick(entity);
     }
 }
Ejemplo n.º 8
0
 public void CreateServer()
 {
     for (int i = 0; i < 35; i++)
     {
         GameServerEntity entity = new GameServerEntity();
         entity.Status     = Mmcoy.Framework.AbstractBase.EnumEntityStatus.Released;
         entity.RunStatus  = 1;
         entity.IsCommand  = false;
         entity.IsNew      = false;
         entity.Name       = "琅嬛福地" + (i + 1);
         entity.Ip         = "";
         entity.Port       = 1000 + (i + 1);
         entity.CreateTime = DateTime.Now;
         entity.UpdateTime = DateTime.Now;
         GameServerCacheModel.Instance.Create(entity);
     }
 }
Ejemplo n.º 9
0
        public ServerResponse RequestHandle(GameParameters parameters)
        {
            if (parameters == null)
            {
                return new ServerResponse()
                       {
                           StatusCode = HttpStatusCode.BadRequest,
                           ResultText = string.Empty
                       }
            }
            ;

            var param = parameters as PutGameInfoParameters;


            var info = _jsonConverter.Deserialize <InfoGameEntity>(param.Json);

            // var info2 = _jsonConverter.Deserialize<InfoGameEntity>(param.Json);

            info.Id = Guid.NewGuid().ToString();//не тестируется

            var gameServer = new GameServerEntity()
            {
                Id       = Guid.NewGuid().ToString(),
                EndPoint = param.EndPoint,
                InfoId   = info.Id,
                Info     = info
            };

            _repository.DeleteExistGameServer(param.EndPoint);

            _repository.AddGameServer(gameServer);
            _repository.AddGameInfo(info);

            return(new ServerResponse()
            {
                StatusCode = HttpStatusCode.OK,
                ResultText = string.Empty
            });
        }
    }
 public void AddGameServer(GameServerEntity item)
 {
     dbContext.GameServerEntities.Add(item);
     dbContext.SaveChanges();
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public MFReturnValue <object> Update(GameServerEntity entity)
 {
     return(this.DBModel.Update(entity));
 }
Ejemplo n.º 12
0
        public RetValue Post([FromBody] string jsonStr)
        {
            RetValue ret = new RetValue();

            JsonData jsonData = JsonMapper.ToObject(jsonStr);

            //时间戳
            long   t = Convert.ToInt64(jsonData["t"].ToString());
            string deviceIdentifier = jsonData["deviceIdentifier"].ToString();
            string deviceModel      = jsonData["deviceModel"].ToString();
            string sign             = jsonData["sign"].ToString();

            //1.判断时间戳 如果大于3秒 直接返回错误
            if (MFDSAUtil.GetTimestamp() - t > 3)
            {
                ret.HasError = true;
                ret.ErrorMsg = "请求无效";
                return(ret);
            }

            //2.验证签名
            string signServer = MFEncryptUtil.Md5(string.Format("{0}:{1}", t, deviceIdentifier));

            if (!signServer.Equals(sign, StringComparison.CurrentCultureIgnoreCase))
            {
                ret.HasError = true;
                ret.ErrorMsg = "请求无效";
                return(ret);
            }

            //订单号 付费服务器识别码_玩家账号_要充值到哪个GameServerId_角色ID_充值的产品Id_时间
            string orderId = jsonData["orderId"].ToString();

            string[] arr = orderId.Split('_');
            if (arr.Length == 6)
            {
                //1.记录充值日志
                RechargeLogEntity rechargeLogEntity = new RechargeLogEntity();
                rechargeLogEntity.AccountId = arr[1].ToInt();
                string channelId = AccountCacheModel.Instance.GetEntity(rechargeLogEntity.AccountId).ChannelId;

                rechargeLogEntity.ChannelId         = channelId;
                rechargeLogEntity.GameServerId      = arr[2].ToInt();
                rechargeLogEntity.RoldId            = arr[3].ToInt();
                rechargeLogEntity.RechargeProductId = arr[4].ToString();
                rechargeLogEntity.OrderId           = orderId;
                rechargeLogEntity.CreateTime        = DateTime.Now;

                RechargeLogCacheModel.Instance.Create(rechargeLogEntity);


                //2.找到对应的游戏服
                int gameServerId = arr[2].ToInt();

                GameServerEntity entity = GameServerCacheModel.Instance.GetEntity(gameServerId);
                if (entity != null)
                {
                    //发送socket请求 给游戏服
                    Socket rechargeServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                    rechargeServer.Connect(new IPEndPoint(IPAddress.Parse(entity.Ip), entity.Port));
                    string str = string.Format("{0}_{1}_{2}", channelId, arr[3], arr[4]);
                    rechargeServer.Send(System.Text.UTF8Encoding.UTF8.GetBytes(str));
                }
                else
                {
                    ret.HasError = true;
                    ret.ErrorMsg = "充值失败";
                }
            }
            else
            {
                ret.HasError = true;
                ret.ErrorMsg = "充值失败";
            }
            return(ret);
        }
Ejemplo n.º 13
0
        public RetValue Post([FromBody] string jsonStr)
        {
            RetValue ret = new RetValue();

            JsonData jsonData = JsonMapper.ToObject(jsonStr);

            //时间戳
            long   t = Convert.ToInt64(jsonData["t"].ToString());
            string deviceIdentifier = jsonData["deviceIdentifier"].ToString();
            string deviceModel      = jsonData["deviceModel"].ToString();
            string sign             = jsonData["sign"].ToString();

            //1.判断时间戳 如果大于3秒 直接返回错误
            if (MFDSAUtil.GetTimestamp() - t > 3)
            {
                ret.HasError  = true;
                ret.ErrorCode = 1002;// "请求无效";
                return(ret);
            }

            //2.验证签名
            string signServer = MFEncryptUtil.Md5(string.Format("{0}:{1}", t, deviceIdentifier));

            if (!signServer.Equals(sign, StringComparison.CurrentCultureIgnoreCase))
            {
                ret.HasError  = true;
                ret.ErrorCode = 1002; //"请求无效";
                return(ret);
            }

            //苹果回执
            string receipt = jsonData["receipt"].ToString();

            string strJosn = string.Format("{{\"receipt-data\":\"{0}\"}}", receipt);
            // 请求验证
            string strResult = CreatePostHttpResponse(strJosn, true);

            JsonData retJson = LitJson.JsonMapper.ToObject(strResult);

            int status = int.Parse(retJson["status"].ToString());

            if (status == 0)
            {
                //成功
                string   retreceipt        = retJson["receipt"].ToJson();
                JsonData retReceiptJson    = JsonMapper.ToObject(retreceipt);
                string   rechargeProductId = retReceiptJson["product_id"].ToString();
                ret.Value = rechargeProductId; //把充值产品编号传递给客户端
                //订单号 付费服务器识别码_玩家账号_要充值到哪个GameServerId_角色ID_充值的产品Id_时间
                string orderId = jsonData["orderId"].ToString();

                string[] arr = orderId.Split('_');
                if (arr.Length == 6)
                {
                    //1.记录充值日志
                    RechargeLogEntity rechargeLogEntity = new RechargeLogEntity();
                    rechargeLogEntity.AccountId = arr[1].ToInt();
                    short channelId = AccountCacheModel.Instance.GetEntity(rechargeLogEntity.AccountId).ChannelId;
                    rechargeLogEntity.Status            = Mmcoy.Framework.AbstractBase.EnumEntityStatus.Released;
                    rechargeLogEntity.ChannelId         = channelId;
                    rechargeLogEntity.GameServerId      = arr[2].ToInt();
                    rechargeLogEntity.RoldId            = arr[3].ToInt();
                    rechargeLogEntity.RechargeProductId = short.Parse(rechargeProductId);
                    rechargeLogEntity.OrderId           = orderId;
                    rechargeLogEntity.CreateTime        = DateTime.Now;

                    RechargeLogCacheModel.Instance.Create(rechargeLogEntity);


                    //2.找到对应的游戏服
                    int gameServerId = arr[2].ToInt();

                    GameServerEntity entity = GameServerCacheModel.Instance.GetEntity(gameServerId);
                    if (entity != null)
                    {
                        //发送socket请求 给游戏服
                        Socket rechargeServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                        rechargeServer.Connect(new IPEndPoint(IPAddress.Parse(entity.Ip), entity.Port));
                        string str = string.Format("{0}_{1}_{2}", channelId, arr[3], arr[4]);
                        rechargeServer.Send(System.Text.UTF8Encoding.UTF8.GetBytes(str));
                    }
                    else
                    {
                        ret.HasError  = true;
                        ret.ErrorCode = 1004; //"充值失败";
                    }
                }
                else
                {
                    ret.HasError  = true;
                    ret.ErrorCode = 1004; //"充值失败";
                }
            }
            else
            {
                ret.HasError  = true;
                ret.ErrorCode = 1004; //"充值失败";
            }


            return(ret);
        }
Ejemplo n.º 14
0
        public HttpResponseMessage Post()
        {
            #region 接收通知
            byte[] buffer = new byte[HttpContext.Current.Request.InputStream.Length];
            HttpContext.Current.Request.InputStream.Read(buffer, 0, buffer.Length);
            string req = System.Text.Encoding.Default.GetString(buffer);
            req = HttpContext.Current.Server.UrlDecode(req);

            string xml = req;

            LogHelper.WriteLog(typeof(WeixinRechargeController), "收到xml数据");
            LogHelper.WriteLog(typeof(WeixinRechargeController), xml);


            XDocument receiveDoc = XDocument.Parse(xml);
            XElement  root       = receiveDoc.Root;

            string   return_code   = "";
            XElement return_codeXE = root.Element("return_code");
            if (return_codeXE != null)
            {
                return_code = return_codeXE.Value;
            }

            if (return_code == "SUCCESS")
            {
                StringBuilder sbr = new StringBuilder();

                //应用ID
                XElement appidXE = root.Element("appid");
                if (appidXE != null)
                {
                    string appid = appidXE.Value;
                    sbr.AppendFormat("appid={0}", appid);
                }

                string orderId   = ""; //订单号
                short  channelId = 0;  //渠道号

                //商家数据包
                XElement attachXE = root.Element("attach");
                if (attachXE != null)
                {
                    string   attach = attachXE.Value;
                    string[] arr    = attach.Split('^');
                    channelId = arr[0].ToShort();
                    orderId   = arr[1];

                    sbr.AppendFormat("&attach={0}", attach);
                }

                //付款银行
                XElement bank_typeXE = root.Element("bank_type");
                if (bank_typeXE != null)
                {
                    string bank_type = bank_typeXE.Value;
                    sbr.AppendFormat("&bank_type={0}", bank_type);
                }

                //现金支付金额
                XElement cash_feeXE = root.Element("cash_fee");
                if (cash_feeXE != null)
                {
                    int cash_fee = cash_feeXE.Value.ToInt();
                    sbr.AppendFormat("&cash_fee={0}", cash_fee);
                }

                //现金支付货币类型
                XElement cash_fee_typeXE = root.Element("cash_fee_type");
                if (cash_fee_typeXE != null)
                {
                    string cash_fee_type = cash_fee_typeXE.Value;
                    sbr.AppendFormat("&cash_fee_type={0}", cash_fee_type);
                }

                //代金券使用数量
                XElement coupon_countXE = root.Element("coupon_count");
                if (coupon_countXE != null)
                {
                    int coupon_count = coupon_countXE.Value.ToInt();
                    sbr.AppendFormat("&coupon_count={0}", coupon_count);
                }

                //代金券金额
                XElement coupon_feeXE = root.Element("coupon_fee");
                if (coupon_feeXE != null)
                {
                    int coupon_fee = coupon_feeXE.Value.ToInt();
                    sbr.AppendFormat("&coupon_fee={0}", coupon_fee);
                }

                //代金券ID
                XElement coupon_idXE = root.Element("coupon_id");
                if (coupon_idXE != null)
                {
                    string coupon_id = coupon_idXE.Value;
                    sbr.AppendFormat("&coupon_id={0}", coupon_id);
                }

                //设备号
                XElement device_infoXE = root.Element("device_info");
                if (device_infoXE != null)
                {
                    string device_info = device_infoXE.Value;
                    sbr.AppendFormat("&device_info={0}", device_info);
                }

                //错误代码
                XElement err_codeXE = root.Element("err_code");
                if (err_codeXE != null)
                {
                    string err_code = err_codeXE.Value;
                    sbr.AppendFormat("&err_code={0}", err_code);
                }

                //错误代码描述
                XElement err_code_desXE = root.Element("err_code_des");
                if (err_code_desXE != null)
                {
                    string err_code_des = err_code_desXE.Value;
                    sbr.AppendFormat("&err_code_des={0}", err_code_des);
                }

                //货币种类
                XElement fee_typeXE = root.Element("fee_type");
                if (fee_typeXE != null)
                {
                    string fee_type = fee_typeXE.Value;
                    sbr.AppendFormat("&fee_type={0}", fee_type);
                }

                //是否关注公众账号
                XElement is_subscribeXE = root.Element("is_subscribe");
                if (is_subscribeXE != null)
                {
                    string is_subscribe = is_subscribeXE.Value;
                    sbr.AppendFormat("&is_subscribe={0}", is_subscribe);
                }

                //商户号
                XElement mch_idXE = root.Element("mch_id");
                if (mch_idXE != null)
                {
                    string mch_id = mch_idXE.Value;
                    sbr.AppendFormat("&mch_id={0}", mch_id);
                }

                //随机字符串
                XElement nonce_strXE = root.Element("nonce_str");
                if (nonce_strXE != null)
                {
                    string nonce_str = nonce_strXE.Value;
                    sbr.AppendFormat("&nonce_str={0}", nonce_str);
                }

                //用户标识
                XElement openidXE = root.Element("openid");
                if (openidXE != null)
                {
                    string openid = openidXE.Value;
                    sbr.AppendFormat("&openid={0}", openid);
                }


                //商户订单号
                XElement out_trade_noXE = root.Element("out_trade_no");
                if (out_trade_noXE != null)
                {
                    string out_trade_no = out_trade_noXE.Value;
                    sbr.AppendFormat("&out_trade_no={0}", out_trade_no);
                }

                //业务结果
                XElement result_codeXE = root.Element("result_code");
                if (result_codeXE != null)
                {
                    string result_code = result_codeXE.Value;
                    sbr.AppendFormat("&result_code={0}", result_code);
                }

                //返回状态码
                //return_code
                sbr.AppendFormat("&return_code={0}", return_code);

                //返回信息
                XElement return_msgXE = root.Element("return_msg");
                if (return_msgXE != null)
                {
                    string return_msg = return_msgXE.Value;
                    sbr.AppendFormat("&return_msg={0}", return_msg);
                }

                //签名
                string   sign   = "";
                XElement signXE = root.Element("sign");
                if (signXE != null)
                {
                    sign = signXE.Value;
                }

                //支付完成时间
                XElement time_endXE = root.Element("time_end");
                if (time_endXE != null)
                {
                    string time_end = time_endXE.Value;
                    sbr.AppendFormat("&time_end={0}", time_end);
                }

                //总金额
                XElement total_feeXE = root.Element("total_fee");
                if (total_feeXE != null)
                {
                    int total_fee = total_feeXE.Value.ToInt();
                    sbr.AppendFormat("&total_fee={0}", total_fee);
                }

                //交易类型
                XElement trade_typeXE = root.Element("trade_type");
                if (trade_typeXE != null)
                {
                    string trade_type = trade_typeXE.Value;
                    sbr.AppendFormat("&trade_type={0}", trade_type);
                }

                //微信支付订单号
                XElement transaction_idXE = root.Element("transaction_id");
                if (transaction_idXE != null)
                {
                    string transaction_id = transaction_idXE.Value;
                    sbr.AppendFormat("&transaction_id={0}", transaction_id);
                }


                sbr.AppendFormat("&key={0}", SDK_Weixin.GetWeixinConfig(channelId).payKey);

                //SDK_Weixin.appid
                //校验签名
                string mySign = MFEncryptUtil.Md5(sbr.ToString()).ToUpper(); //签名是MD5大写形式

                if (mySign == sign)
                {
                    //签名验证通过

                    //订单号 付费服务器识别码_玩家账号_要充值到哪个GameServerId_角色ID_充值的产品Id_时间
                    string[] arr = orderId.Split('_');
                    if (arr.Length == 6)
                    {
                        //判断订单号是否已经处理过
                        RechargeLogEntity searchEntity = RechargeLogCacheModel.Instance.GetEntity("OrderId='" + orderId + "'");
                        if (searchEntity == null)
                        {
                            //1.记录充值日志
                            RechargeLogEntity rechargeLogEntity = new RechargeLogEntity();
                            rechargeLogEntity.AccountId         = arr[1].ToInt();
                            rechargeLogEntity.Status            = Mmcoy.Framework.AbstractBase.EnumEntityStatus.Released;
                            rechargeLogEntity.ChannelId         = channelId;
                            rechargeLogEntity.GameServerId      = arr[2].ToInt();
                            rechargeLogEntity.RoldId            = arr[3].ToInt();
                            rechargeLogEntity.RechargeProductId = arr[4].ToShort();
                            rechargeLogEntity.OrderId           = orderId;
                            rechargeLogEntity.CreateTime        = DateTime.Now;

                            RechargeLogCacheModel.Instance.Create(rechargeLogEntity);


                            //2.找到对应的游戏服
                            int gameServerId = arr[2].ToInt();

                            GameServerEntity entity = GameServerCacheModel.Instance.GetEntity(gameServerId);
                            if (entity != null)
                            {
                                try
                                {
                                    //发送socket请求 给游戏服
                                    Socket rechargeServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                                    rechargeServer.Connect(new IPEndPoint(IPAddress.Parse(entity.Ip), entity.Port));
                                    string str = string.Format("{0}_{1}_{2}", channelId, arr[3], arr[4]);
                                    rechargeServer.Send(System.Text.UTF8Encoding.UTF8.GetBytes(str));
                                }
                                catch { }
                            }
                        }
                    }
                }
            }

            #endregion

            #region 返回通知

            StringBuilder sbrReturn = new StringBuilder();

            sbrReturn.Append("<xml>");
            sbrReturn.Append("<return_code><![CDATA[SUCCESS]]></return_code>");
            sbrReturn.Append("<return_msg><![CDATA[OK]]></return_msg>");
            sbrReturn.Append("</xml>");

            //一定要这样写 才能正确的返回xml格式数据给微信,直接返回字符串 微信不识别,那么微信还会重复调用这个接口进行通知
            return(new HttpResponseMessage()
            {
                Content = new StringContent(sbrReturn.ToString(), Encoding.UTF8, "application/xml")
            });

            #endregion
        }
Ejemplo n.º 15
0
 /// <summary>
 /// 选择了一个服务器,返回enterServer界面,并已选的数据传回来
 /// </summary>
 /// <param name="obj"></param>
 private void OnInfoItemClick(GameServerEntity obj)
 {
     mSelectServerView.SelfClose();
     mEnterServerView.SetText(obj.Name);
     ResetGameServer();  //选择一个服务器并返回后,要把大区列表重置
 }