| Core/NetworkPackage/DTCFile/ServerPack/H01_System/DTC0101_tagServerPrepared.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Core/NetworkPackage/DTCFile/ServerPack/H01_System/DTC0107_tagShowLoginFrm.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Core/NetworkPackage/DTCFile/ServerPack/H01_System/DTC0115_tagAskClientVersion.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Core/NetworkPackage/GameNetPackBasic.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Core/NetworkPackage/GameNetSystem.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Core/NetworkPackage/Socket/ClientSocket.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Lua/Gen/GameNetSystemWrap.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| Lua/Gen/SnxxzUILoginModelWrap.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Login/CrossServerLogin.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Login/CrossServerLogin.cs.meta | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| System/Login/LoginModel.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Core/NetworkPackage/DTCFile/ServerPack/H01_System/DTC0101_tagServerPrepared.cs
@@ -4,19 +4,24 @@ using System; //01 01 服务器InitOK#tagServerPrepared public class DTC0101_tagServerPrepared : DtcBasic { public class DTC0101_tagServerPrepared : DtcBasic { public static event Action<H0101_tagServerPrepared> onServerPreparedEvent; public override void Done(GameNetPackBasic vNetPack) { public override void Done(GameNetPackBasic vNetPack) { base.Done(vNetPack); var vNetData = vNetPack as H0101_tagServerPrepared; if (onServerPreparedEvent!=null) switch (vNetData.socketType) { onServerPreparedEvent(vNetData); case GameNetSystem.SocketType.Main: ModelCenter.Instance.GetModel<LoginModel>().AccessLogin(vNetData); break; case GameNetSystem.SocketType.CrossSever: CrossServerLogin.Instance.AccessLogin(vNetData); break; default: break; } } Core/NetworkPackage/DTCFile/ServerPack/H01_System/DTC0107_tagShowLoginFrm.cs
@@ -1,47 +1,29 @@ using UnityEngine; using System.Collections; using System; using Snxxz.UI; //01 07 客户端显示创建角色/选择角色界面#tagShowLoginFrm public class DTC0107_tagShowLoginFrm : DtcBasic { public static event Action<byte> OnLoginSucceed; public override void Done(GameNetPackBasic vNetPack) { base.Done(vNetPack); H0107_tagShowLoginFrm vNetData = vNetPack as H0107_tagShowLoginFrm; var vNetData = vNetPack as H0107_tagShowLoginFrm; if (vNetData == null) return; GameNetSystem.Instance.netState = GameNetSystem.NetState.CreateOrSelectRole; if (OnLoginSucceed != null) switch (vNetData.socketType) { OnLoginSucceed(vNetData.Type); case GameNetSystem.SocketType.Main: GameNetSystem.Instance.netState = GameNetSystem.NetState.CreateOrSelectRole; ModelCenter.Instance.GetModel<LoginModel>().OnGetPlayerLoginInfo(vNetData.Type); break; case GameNetSystem.SocketType.CrossSever: CrossServerLogin.Instance.OnGetPlayerLoginInfo(vNetData.Type); break; default: break; } //if (vNetData.Type == 1) { // //C0108_tagCRoleLoginAsk tagCRoleLoginAsk = new C0108_tagCRoleLoginAsk(); // //tagCRoleLoginAsk.Type = vNetData.Type; // //GameNetSystem.Inst.SendInfo(tagCRoleLoginAsk); // // //loginWindow.loginTips.SetActive(false); // //loginWindow.createRoleTips.SetActive(true); //} //else if (vNetData.Type == 2) { // //loginWindow.loginTips.SetActive(false); // //loginWindow.existingRoleTips.SetActive(true); // // // C0108_tagCRoleLoginAsk tagCRoleLoginAsk = new C0108_tagCRoleLoginAsk(); // tagCRoleLoginAsk.Type = 2; // GameNetSystem.Inst.SendInfo(tagCRoleLoginAsk); //} } Core/NetworkPackage/DTCFile/ServerPack/H01_System/DTC0115_tagAskClientVersion.cs
@@ -1,21 +1,27 @@ using UnityEngine; using System.Collections; using System; using Snxxz.UI; //01 15 请求客户端版本号#tagAskClientVersion public class DTC0115_tagAskClientVersion : DtcBasic { public static event Action onAskClientVersionEvent; public override void Done(GameNetPackBasic vNetPack) { base.Done(vNetPack); //H0115_tagAskClientVersion vNetData = vNetPack as H0115_tagAskClientVersion; if (onAskClientVersionEvent != null) switch (vNetPack.socketType) { onAskClientVersionEvent(); case GameNetSystem.SocketType.Main: ModelCenter.Instance.GetModel<LoginModel>().CheckClientVersion(); break; case GameNetSystem.SocketType.CrossSever: CrossServerLogin.Instance.CheckClientVersion(); break; default: break; } } } Core/NetworkPackage/GameNetPackBasic.cs
@@ -7,6 +7,8 @@ public class GameNetPackBasic { public GameNetSystem.SocketType socketType = GameNetSystem.SocketType.Main; /** 协议号 */ protected ushort _cmd = 0; /** 协议号引用 */ Core/NetworkPackage/GameNetSystem.cs
@@ -105,7 +105,7 @@ netState = NetState.NerverConnect; } public void BeginConnectGameServer(string ip, int port, Action onConnected) public void BeginConnectGameServer(string ip, int port, Action<bool> onConnected) { try { @@ -122,16 +122,16 @@ mainSocket = new ClientSocket(SocketType.Main); mainProtocolQueue.Clear(); mainSocket.Connect(ip, port, () => mainSocket.Connect(ip, port, (bool ok) => { if (onConnected != null) { onConnected(); onConnected(ok); } }); } public void BeginConnectCrossServer(string ip, int port, Action onConnected) public void BeginConnectCrossServer(string ip, int port, Action<bool> onConnected) { try { @@ -147,11 +147,11 @@ crossServerSocket = new ClientSocket(SocketType.CrossSever); crossSeverProtocolQueue.Clear(); this.crossServerSocket.Connect(ip, port, () => this.crossServerSocket.Connect(ip, port, (bool ok) => { if (onConnected != null) { onConnected(); onConnected(ok); } }); } Core/NetworkPackage/Socket/ClientSocket.cs
@@ -28,14 +28,14 @@ string ip; int port; Action onConnected = null; Action<bool> onConnected = null; public ClientSocket(GameNetSystem.SocketType type) { this.socketType = type; } public void Connect(string _ip, int _port, Action _onConnected) public void Connect(string _ip, int _port, Action<bool> _onConnected) { try { @@ -84,30 +84,45 @@ { DebugEx.Log("链接超时!"); CloseConnect(); } else { if (m_Socket != null && m_Socket.Connected) if (onConnected != null) { DebugEx.Log("确认的链接实现"); OnConnectSuccess(); if (onConnected != null) { onConnected(); onConnected = null; } } else { if (m_Socket != null) { m_Socket.Disconnect(true); } onConnected(false); onConnected = null; } } else { try { if (m_Socket != null && m_Socket.Connected) { DebugEx.Log("确认的链接实现"); OnConnectSuccess(); } else { if (m_Socket != null) { m_Socket.Disconnect(true); } } } catch (System.Exception ex) { DebugEx.Log(ex); } finally { if (onConnected != null) { onConnected(m_Socket != null && m_Socket.Connected); onConnected = null; } } } onConnected = null; } /// <summary> @@ -269,6 +284,7 @@ } m_LastPackageTime = DateTime.Now; vNetpack.socketType = this.socketType; GameNetSystem.Instance.PushPackage(vNetpack, this.socketType); } } Lua/Gen/GameNetSystemWrap.cs
@@ -104,9 +104,6 @@ int _port = LuaAPI.xlua_tointeger(L, 3); System.Action _onConnected = translator.GetDelegate<System.Action>(L, 4); gen_to_be_invoked.BeginConnectGameServer( _ip, _port, _onConnected ); return 0; } @@ -134,7 +131,6 @@ int _port = LuaAPI.xlua_tointeger(L, 3); System.Action _onConnected = translator.GetDelegate<System.Action>(L, 4); gen_to_be_invoked.BeginConnectCrossServer( _ip, _port, _onConnected ); Lua/Gen/SnxxzUILoginModelWrap.cs
@@ -276,7 +276,6 @@ string __password = LuaAPI.lua_tostring(L, 4); string __result = LuaAPI.lua_tostring(L, 5); gen_to_be_invoked.NofityResigerResult( __ok, __accountName, __password, __result ); System/Login/CrossServerLogin.cs
New file @@ -0,0 +1,269 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; using System; namespace Snxxz.UI { public class CrossServerLogin : Singleton<CrossServerLogin> { bool m_ReconnecBackGround = false; public bool reconnectBackGround { get { return m_ReconnecBackGround; } set { m_ReconnecBackGround = value; } } bool m_Busy = false; public bool busy { get { return m_Busy; } set { m_Busy = value; } } LoginModel loginModel { get { return ModelCenter.Instance.GetModel<LoginModel>(); } } public void Init() { SnxxzGame.Instance.AddApplicationOutAction(OnApplicationOut); } public void UnInit() { SnxxzGame.Instance.RemoveApplicationOutAction(OnApplicationOut); } public string ipBuf { get; private set; } public int portBuf { get; private set; } public int gamePortBuf { get; private set; } public string accountBuf { get; private set; } public string passwordBuf { get; private set; } public bool isLogined { get; private set; } public void AccountLogin(string account, string ip, int port, int gamePort) { isLogined = true; if (Application.internetReachability == NetworkReachability.NotReachable) { ConfirmCancel.ShowPopConfirm( Language.Get("Mail101"), Language.Get("L1116"), () => { } ); return; } if (busy) { return; } busy = true; try { reconnectBackGround = false; accountBuf = account; ipBuf = ip; portBuf = port; gamePortBuf = gamePort; GameNetSystem.Instance.BeginConnectCrossServer(ipBuf, gamePortBuf, OnGameServerConnected); } catch (Exception ex) { Debug.Log(ex); busy = false; } } public void ReAccountLogin() { if (busy) { return; } busy = true; reconnectBackGround = true; try { GameNetSystem.Instance.BeginConnectCrossServer(ipBuf, gamePortBuf, OnGameServerConnected); } catch (Exception ex) { Debug.Log(ex); busy = false; } } private void OnAccountLogin(bool _ok, string _result) { if (!_ok) { busy = false; DebugEx.LogError(_result); return; } if (string.IsNullOrEmpty(_result)) { busy = false; return; } var stringSet = _result.Split('|'); if (stringSet[0] != "OK") { busy = false; return; } try { GameNetSystem.Instance.BeginConnectCrossServer(ipBuf, gamePortBuf, OnGameServerConnected); } catch (Exception ex) { busy = false; Debug.Log(ex); } } private void OnGameServerConnected(bool ok) { if (ok) { var sendInfo = new C0123_tagCClientPackVersion(); sendInfo.Version = LoginModel.DwVersionNo; GameNetSystem.Instance.SendToCrossServer(sendInfo); } else { busy = false; } } public void AccessLogin(H0101_tagServerPrepared _serverInfo) { var send = new C0101_tagCPlayerLogin(); switch (VersionConfig.Get().versionAuthority) { case VersionAuthority.InterTest: send.IDType = 1; send.AccID = accountBuf; send.Password = "64e228993a2e7820004fec23251da204"; send.MAC = DeviceUtility.GetMac(); send.Version = _serverInfo.Version; send.LineNO = 255; send.AppID = VersionConfig.Get().appId; send.AccountID = 1000;// 内部登陆的时候的id send.TokenExpire = "1519750743000";// 内部登陆的时长,无所谓的 send.Phone = 0; send.ServerID = (uint)ServerListCenter.Instance.currentServer.region_flag; send.Adult = 1; send.ExtraLen = 0; send.Extra = ""; break; case VersionAuthority.Release: send.Extra = VersionConfig.Get().SpID; send.ExtraLen = (byte)send.Extra.Length; if (SDKUtility.Instance.ChannelPlatform == SDKUtility.E_ChannelPlatform.Free) { send.IDType = 1; } else if (SDKUtility.Instance.ChannelPlatform == SDKUtility.E_ChannelPlatform.Mr) { send.IDType = 2; } else if (SDKUtility.Instance.ChannelPlatform == SDKUtility.E_ChannelPlatform.Sp) { send.IDType = 3; send.Extra += ("|" + SDKUtility.Instance.FreePlatformInfo.sessionID); send.ExtraLen = (byte)send.Extra.Length; } else if (SDKUtility.Instance.ChannelPlatform == SDKUtility.E_ChannelPlatform.Js) { send.IDType = 4; send.Extra += ("|" + loginModel.sdkLoginResult.token); send.ExtraLen = (byte)send.Extra.Length; } else if (SDKUtility.Instance.ChannelPlatform == SDKUtility.E_ChannelPlatform.Yj) { send.IDType = 5; send.Extra += ("|" + SDKUtility.Yj_SpID + "|" + SDKUtility.Yj_AppID + "|" + SDKUtility.Instance.FreePlatformInfo.accountID); send.ExtraLen = (byte)send.Extra.Length; } send.AccID = loginModel.sdkLoginResult.account; send.Password = loginModel.sdkLoginResult.token; send.MAC = DeviceUtility.GetMac(); send.Version = _serverInfo.Version; send.LineNO = 255; send.AppID = VersionConfig.Get().appId; send.AccountID = (uint)loginModel.sdkLoginResult.accountID;// 内部登陆的时候的id send.TokenExpire = loginModel.sdkLoginResult.tokenExpire; if (SDKUtility.Instance.ChannelPlatform == SDKUtility.E_ChannelPlatform.Sp) { send.TokenExpire = SDKUtility.Instance.FreePlatformInfo.timeStamp; } send.Phone = (byte)loginModel.sdkLoginResult.phone; send.ServerID = (uint)ServerListCenter.Instance.currentServer.region_flag; if (loginModel.sdkIDCheckIDAuthentication.type == "1") { send.Adult = 1; } else if (loginModel.sdkIDCheckIDAuthentication.type == "2") { send.Adult = MathUtility.CheckAdult(loginModel.sdkIDCheckIDAuthentication.card_id) ? (byte)1 : (byte)0; } else { send.Adult = 0; } break; } GameNetSystem.Instance.SendInfo(send); // 登录 } public void CheckClientVersion() { var sendInfo = new C010D_tagCClientVersion(); sendInfo.Version = "10.1000.1"; GameNetSystem.Instance.SendToCrossServer(sendInfo); } public void OnGetPlayerLoginInfo(byte _type) { busy = false; if (Application.internetReachability == NetworkReachability.NotReachable) { ConfirmCancel.ShowPopConfirm( Language.Get("Mail101"), Language.Get("L1116"), () => { } ); return; } var tagCRoleLoginAsk = new C0108_tagCRoleLoginAsk(); tagCRoleLoginAsk.Type = (byte)_type;//进入游戏 tagCRoleLoginAsk.ClientID = SDKUtility.Instance.RegistrationID; GameNetSystem.Instance.SendToCrossServer(tagCRoleLoginAsk); } private void OnApplicationOut() { var sendInfo = new C0103_tagCPlayerLogOut(); sendInfo.Type = 1; GameNetSystem.Instance.SendToCrossServer(sendInfo); } } } System/Login/CrossServerLogin.cs.meta
New file @@ -0,0 +1,12 @@ fileFormatVersion: 2 guid: 2723e9c92a7c80843ac0fc06bd7dd77a timeCreated: 1544600638 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: System/Login/LoginModel.cs
@@ -16,8 +16,7 @@ public SDKUtility.FP_LoginOk sdkLoginResult; public SDKUtility.FP_CheckIDAuthentication sdkIDCheckIDAuthentication; public string localSaveAccountName { public string localSaveAccountName { get { return LocalSave.GetString(USER_ACCOUNT); } set { LocalSave.SetString(USER_ACCOUNT, value); } } @@ -26,22 +25,19 @@ public event Action accountBindOkEvent; bool m_ReconnecBackGround = false; public bool reconnectBackGround { public bool reconnectBackGround { get { return m_ReconnecBackGround; } set { m_ReconnecBackGround = value; } } bool m_OnCreateRole = false; public bool onCreateRole { public bool onCreateRole { get { return m_OnCreateRole; } set { m_OnCreateRole = value; } } bool m_Busy = false; public bool busy { public bool busy { get { return m_Busy; } set { m_Busy = value; } } @@ -53,10 +49,6 @@ SDKUtility.Instance.onFreePlatformBindOk += OnSDKAccountBindOk; SDKUtility.Instance.onFreePlatfromCheckIDOK += OnGetIDAuthenticationInfo; DTC0101_tagServerPrepared.onServerPreparedEvent += AccessLogin; DTC0115_tagAskClientVersion.onAskClientVersionEvent += CheckClientVersion; DTC0107_tagShowLoginFrm.OnLoginSucceed += OnGetPlayerLoginInfo; SnxxzGame.Instance.AddApplicationOutAction(OnApplicationOut); } @@ -66,10 +58,6 @@ SDKUtility.Instance.onFreePlatformLogoutOk -= OnSDKAccountLoginOutOk; SDKUtility.Instance.onFreePlatfromCheckIDOK -= OnGetIDAuthenticationInfo; SDKUtility.Instance.onFreePlatformBindOk -= OnSDKAccountBindOk; DTC0101_tagServerPrepared.onServerPreparedEvent -= AccessLogin; DTC0115_tagAskClientVersion.onAskClientVersionEvent -= CheckClientVersion; DTC0107_tagShowLoginFrm.OnLoginSucceed -= OnGetPlayerLoginInfo; SnxxzGame.Instance.RemoveApplicationOutAction(OnApplicationOut); } @@ -256,14 +244,21 @@ GameNetSystem.Instance.BeginConnectGameServer(_ip, _port, OnGameServerConnected); } private void OnGameServerConnected() private void OnGameServerConnected(bool ok) { var sendInfo = new C0123_tagCClientPackVersion(); sendInfo.Version = DwVersionNo; GameNetSystem.Instance.SendInfo(sendInfo); if (ok) { var sendInfo = new C0123_tagCClientPackVersion(); sendInfo.Version = DwVersionNo; GameNetSystem.Instance.SendInfo(sendInfo); } else { busy = false; } } private void AccessLogin(H0101_tagServerPrepared _serverInfo) public void AccessLogin(H0101_tagServerPrepared _serverInfo) { var send = new C0101_tagCPlayerLogin(); @@ -348,14 +343,14 @@ GameNetSystem.Instance.SendInfo(send); // 登录 } private void CheckClientVersion() public void CheckClientVersion() { var sendInfo = new C010D_tagCClientVersion(); sendInfo.Version = "10.1000.1"; GameNetSystem.Instance.SendInfo(sendInfo); } private void OnGetPlayerLoginInfo(byte _type) public void OnGetPlayerLoginInfo(byte _type) { busy = false; switch (_type) @@ -407,39 +402,6 @@ { GameNetSystem.Instance.OnEnterWorld(); } } public void NofityResigerResult(bool _ok, string _accountName, string _password, string _result) { if (!_ok) { DebugEx.Log("AccountPadGet Error:" + _result); if (registerResultEvent != null) { registerResultEvent(false); } } else { string[] resultArray = _result.Split('|'); if (string.Equals(resultArray[0], "OK")) { localSaveAccountName = _accountName; if (registerResultEvent != null) { registerResultEvent(true); } } else { if (registerResultEvent != null) { registerResultEvent(false); } } } } private void OnApplicationOut()