| New file |
| | |
| | | using Snxxz.UI;
|
| | | using System;
|
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Security.Cryptography;
|
| | | using System.Text;
|
| | | using UnityEngine; |
| | | |
| | | public class LanguageVerify : Singleton<LanguageVerify>
|
| | | { |
| | | const string RequireVerifyAppid = "498_mrgame"; |
| | | const string Sercret = "c345a165b566d1c421afd8a748373d7f"; |
| | | bool requireVerify
|
| | | {
|
| | | get
|
| | | {
|
| | | return VersionConfig.Get().appId.Equals(RequireVerifyAppid);
|
| | | }
|
| | | } |
| | | |
| | | static StringBuilder s_StringBuilder = new StringBuilder(); |
| | | |
| | | const string VerifyPlayerNameUrl = "https://api.maoergame.com/game/role/response?"; |
| | | /// <summary>
|
| | | /// 校验玩家名
|
| | | /// </summary>
|
| | | /// <param name="verifyName">需要检验的名字</param>
|
| | | /// <param name="playerId">玩家id</param>
|
| | | /// <param name="playerName">原来的角色名,创角传空</param>
|
| | | /// <param name="level">玩家等级</param>
|
| | | /// <param name="vipLv">玩家VIP等级</param>
|
| | | /// <param name="callback"></param> |
| | | public void VerifyPlayerName(string verifyName, int playerId, string playerName, int level, int vipLv, Action<bool, string> callback)
|
| | | {
|
| | | if (!requireVerify)
|
| | | {
|
| | | if (callback != null)
|
| | | {
|
| | | callback(true, verifyName);
|
| | | callback = null;
|
| | | }
|
| | | return;
|
| | | }
|
| | | NetLinkWin.Show();
|
| | | var tables = new Dictionary<string, string>();
|
| | | tables["game_code"] = "snxxz";
|
| | | tables["server_id"] = ServerListCenter.Instance.currentServer.region_flag.ToString();
|
| | | tables["server_name"] = StringUtility.Contact("s", ServerListCenter.Instance.currentServer.region_flag);
|
| | | tables["role_name"] = verifyName;
|
| | | tables["sender_uid"] = ModelCenter.Instance.GetModel<LoginModel>().sdkLoginResult.account;
|
| | | tables["sender_rid"] = playerId.ToString();
|
| | | tables["sender_name"] = playerName;
|
| | | tables["sender_level"] = level.ToString();
|
| | | tables["sender_vip_level"] = vipLv.ToString();
|
| | | tables["timestamp"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
| | | tables["key"] = ToMD5(StringUtility.Contact(Sercret, tables["timestamp"]));
|
| | | HttpRequest.Instance.RequestHttpPost(VerifyPlayerNameUrl, tables, HttpRequest.defaultHttpContentType, 3,
|
| | | (bool ok, string result) =>
|
| | | {
|
| | | if (ok)
|
| | | {
|
| | | var response = LitJson.JsonMapper.ToObject<VerifyResponse>(result);
|
| | | if (response != null)
|
| | | {
|
| | | if (response.result.Equals("success"))
|
| | | {
|
| | | if (callback != null)
|
| | | {
|
| | | callback(true, verifyName);
|
| | | callback = null;
|
| | | return;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | NetLinkWin.Hide();
|
| | | });
|
| | | } |
| | | |
| | | const string VerifyFairyUrl = "https://api.maoergame.com/game/sociaty/response?"; |
| | | public void VerifyFairy(string verifyContent, int op_type, string fairyName, int title, Action<bool, string> callback)
|
| | | {
|
| | | if (!requireVerify)
|
| | | {
|
| | | if (callback != null)
|
| | | {
|
| | | callback(true, verifyContent);
|
| | | callback = null;
|
| | | }
|
| | | return;
|
| | | }
|
| | |
|
| | | var account = ModelCenter.Instance.GetModel<LoginModel>().sdkLoginResult.account;
|
| | | var playerId = PlayerDatas.Instance.baseData.PlayerID;
|
| | | var playerName = PlayerDatas.Instance.baseData.PlayerName;
|
| | |
|
| | | var tables = new Dictionary<string, string>();
|
| | | tables["game_code"] = "snxxz";
|
| | | tables["server_id"] = ServerListCenter.Instance.currentServer.region_flag.ToString();
|
| | | tables["server_name"] = StringUtility.Contact("s", ServerListCenter.Instance.currentServer.region_flag);
|
| | | tables["op_type"] = op_type.ToString();
|
| | | tables["name"] = op_type == 1 ? fairyName : verifyContent;
|
| | |
|
| | | tables["leader_uid"] = title == 3 ? account : string.Empty;
|
| | | tables["leader_rid"] = title == 3 ? playerId.ToString() : string.Empty;
|
| | | tables["leader_name"] = title == 3 ? playerName : string.Empty;
|
| | |
|
| | | tables["vice_leader_uid"] = title == 2 ? account : string.Empty;
|
| | | tables["vice_leader_rid"] = title == 2 ? playerId.ToString() : string.Empty;
|
| | | tables["vice_leader_name"] = title == 2 ? playerName : string.Empty;
|
| | |
|
| | | tables["edit_uid"] = account;
|
| | | tables["edit_rid"] = playerId.ToString();
|
| | | tables["edit_name"] = playerName;
|
| | |
|
| | | tables["notice"] = op_type == 2 ? string.Empty : verifyContent;
|
| | | tables["timestamp"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
| | | tables["key"] = ToMD5(StringUtility.Contact(Sercret, tables["timestamp"]));
|
| | |
|
| | | HttpRequest.Instance.RequestHttpPost(VerifyFairyUrl, tables, HttpRequest.defaultHttpContentType, 3,
|
| | | (bool ok, string result) =>
|
| | | {
|
| | | if (ok)
|
| | | {
|
| | | var response = LitJson.JsonMapper.ToObject<VerifyResponse>(result);
|
| | | if (response != null)
|
| | | {
|
| | | if (response.result.Equals("success"))
|
| | | {
|
| | | if (callback != null)
|
| | | {
|
| | | callback(true, response.content);
|
| | | callback = null;
|
| | | return;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | | } |
| | | |
| | | public static uint toPlayer = 0; |
| | | public static string toPlayerName = string.Empty; |
| | | public static int toPlayerLevel = 0; |
| | | public static int toPlayerVipLv = 0; |
| | | const string VerifyChatUrl = "https://api.maoergame.com/game/chat/response?"; |
| | | public void VerifyChat(string content, ChatInfoType channelType, Action<bool, string> callback)
|
| | | {
|
| | | int channel = 0;
|
| | | if (!requireVerify || !GetChannel(channelType, out channel) || PlayerDatas.Instance.baseData.VIPLv >= 4)
|
| | | {
|
| | | if (callback != null)
|
| | | {
|
| | | callback(true, content);
|
| | | callback = null;
|
| | | }
|
| | | return;
|
| | | }
|
| | |
|
| | | var account = ModelCenter.Instance.GetModel<LoginModel>().sdkLoginResult.account;
|
| | | var playerId = PlayerDatas.Instance.baseData.PlayerID;
|
| | | var playerName = PlayerDatas.Instance.baseData.PlayerName;
|
| | |
|
| | | var tables = new Dictionary<string, string>();
|
| | | tables["game_code"] = "snxxz";
|
| | | tables["server_id"] = ServerListCenter.Instance.currentServer.region_flag.ToString();
|
| | | tables["server_name"] = StringUtility.Contact("s", ServerListCenter.Instance.currentServer.region_flag);
|
| | | tables["chat_type"] = 1.ToString();
|
| | | tables["chat_channel"] = channel.ToString();
|
| | | tables["chat_content"] = content;
|
| | | tables["sender_uid"] = account;
|
| | | tables["sender_rid"] = playerId.ToString();
|
| | | tables["sender_name"] = playerName;
|
| | | tables["sender_level"] = PlayerDatas.Instance.baseData.PlayerID.ToString();
|
| | | tables["sender_vip_level"] = PlayerDatas.Instance.baseData.VIPLv.ToString();
|
| | |
|
| | | tables["receiver_uid"] = string.Empty;
|
| | | tables["receiver_rid"] = toPlayer.ToString();
|
| | | tables["receiver_name"] = toPlayerName;
|
| | | tables["receiver_level"] = toPlayerLevel.ToString();
|
| | | tables["receiver_vip_level"] = toPlayerLevel.ToString();
|
| | |
|
| | | tables["timestamp"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
| | | tables["key"] = ToMD5(StringUtility.Contact(Sercret, tables["timestamp"]));
|
| | |
|
| | | HttpRequest.Instance.RequestHttpPost(VerifyChatUrl, tables, HttpRequest.defaultHttpContentType, 3,
|
| | | (bool ok, string result) =>
|
| | | {
|
| | | if (ok)
|
| | | {
|
| | | var response = LitJson.JsonMapper.ToObject<VerifyResponse>(result);
|
| | | if (response != null)
|
| | | {
|
| | | if (response.result.Equals("success"))
|
| | | {
|
| | | if (callback != null)
|
| | | {
|
| | | callback(true, response.content);
|
| | | callback = null;
|
| | | return;
|
| | | }
|
| | | }
|
| | | else if (response.result.Equals("verify_fail"))
|
| | | {
|
| | | switch (response.code)
|
| | | {
|
| | | case -1:
|
| | | MessageWin.Inst.ShowFixedTip(Language.Get("L1007"));
|
| | | break;
|
| | | case -2:
|
| | | SysNotifyMgr.Instance.ShowTip("VerifyErrorCode2");
|
| | | break;
|
| | | case -3:
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | });
|
| | | } |
| | | |
| | | bool GetChannel(ChatInfoType type, out int channel)
|
| | | {
|
| | | channel = 0;
|
| | | switch (type)
|
| | | {
|
| | | case ChatInfoType.World:
|
| | | channel = 0;
|
| | | break;
|
| | | case ChatInfoType.Team:
|
| | | channel = 4;
|
| | | break;
|
| | | case ChatInfoType.Area:
|
| | | case ChatInfoType.Trumpet:
|
| | | channel = 5;
|
| | | break;
|
| | | case ChatInfoType.Fairy:
|
| | | channel = 2;
|
| | | break;
|
| | | case ChatInfoType.Friend:
|
| | | channel = 3;
|
| | | break;
|
| | | default:
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | } |
| | | |
| | | static string ToMD5(string content)
|
| | | {
|
| | | byte[] bytes = Encoding.UTF8.GetBytes(content);
|
| | | MD5 md5 = new MD5CryptoServiceProvider();
|
| | | byte[] hash = md5.ComputeHash(bytes);
|
| | | s_StringBuilder.Length = 0;
|
| | | for (int i = 0; i < hash.Length; i++)
|
| | | {
|
| | | s_StringBuilder.Append(hash[i].ToString("X2"));
|
| | | }
|
| | | return s_StringBuilder.ToString();
|
| | | }
|
| | |
|
| | | public class VerifyResponse
|
| | | {
|
| | | public string result;
|
| | | public int code;
|
| | | public string content;
|
| | | }
|
| | | } |