public RPCConsole() { if (m_kCB != null) { m_kCB.Release(); m_kCB = null; } if (m_kCB == null) { m_kCB = new IxMagnaChainBridge(); } m_bCBInited = m_kCB.Initialize(RPC_HOST, RPC_PORT, RPC_USERNAME, RPC_PASSWORD, RPC_NET_TYPE); if (m_bCBInited == false) { if (EditorUtility.DisplayDialog("Erorr", "Initialize RCP client failed.", "OK")) { return; } } if (!string.IsNullOrEmpty(ms_strImportMasterKeyName) && !string.IsNullOrEmpty(ms_strMasterKey)) { m_kCB.ImportMasterExtKey(ms_strImportMasterKeyName, ms_strMasterKey); } InitCommand(); }
void OnDestroy() { if (m_kCB != null) { m_kCB.Release(); m_kCB = null; } }
private void InitializeRPCClient() { m_kCLB = new IxMagnaChainBridge(); string strHost = "http://127.0.0.1"; int iPort = 8332; string strUser = "******"; string strPwd = "pwd"; NETWORK_TYPE eNT = NETWORK_TYPE.MAIN; bool bRet = m_kCLB.Initialize(strHost, iPort, strUser, strPwd, eNT); }
public void Initialize(IxMagnaChainBridge kCLB, string strMasterKey, string strAddress, string strDestAddress, Role kOther, int iID) { m_kCLB = kCLB; m_kOtherRole = kOther; m_iID = iID; m_strMasterKey = strMasterKey; m_strAddress = strAddress; if (m_strDestAddress == null) { m_strDestAddress = strDestAddress; } string strSaveName = SAVE_ADDRESS_NAME_PREFIX + m_iID; if (PlayerPrefs.HasKey(strSaveName)) { m_strAddress = PlayerPrefs.GetString(strSaveName); m_kOtherRole.SetDestCLAddress(m_strAddress); } //string strName; string strPath; m_kCLB.DecodeMCLAddress(m_strAddress, out m_strMasterKeyName, out strPath, out m_strBTAddress); List <string> listAddress = new List <string>(); listAddress.Add(strAddress); m_kCLB.ImportMasterExtKey(strMasterKey, listAddress); if (m_txtAddress != null) { m_txtAddress.text = strAddress; } if (m_txtBTAddress != null) { m_txtBTAddress.text = m_strBTAddress; } if (m_ifDestAddress != null) { m_ifDestAddress.text = m_strDestAddress; } m_fUpdateTick = m_fUpdateTime; UpdateBalance(); }
private void InitializeRPCClient() { m_kCLB = new IxMagnaChainBridge(); string strHost = "http://127.0.0.1"; int iPort = 8332; string strUser = "******"; string strPwd = "pwd"; NETWORK_TYPE eNT = NETWORK_TYPE.MAIN; TextOut("Initialize RPC client: " + strHost + ":" + iPort.ToString()); bool bRet = m_kCLB.Initialize(strHost, iPort, strUser, strPwd, eNT); if (bRet == false) { TextOut("Initialize RPC client failed!", "red"); } else { TextOut("Initialize RPC client succeed."); } }
private void DrawSettingsUI(float fYOffset) { if (m_bNeedResetFocus) { GUI.FocusControl(null); m_bNeedResetFocus = false; } GUILayout.Space(10); RPC_HOST = DrawFileChooser("RHLabe", "RHInput", "RHBtn", 20.0f, false, "Rpc Host:", 120.0f, RPC_HOST, 330.0f, "", false, true); GUILayout.Space(10); string strRpcPort = RPC_PORT.ToString(); strRpcPort = DrawFileChooser("RPLabe", "RPInput", "RPBtn", 20.0f, false, "Rpc port:", 120.0f, strRpcPort, 330.0f, @"8332", false, true); try { RPC_PORT = Convert.ToInt32(strRpcPort); } catch (Exception e) { RPC_PORT = 8332; } GUILayout.Space(10); RPC_USERNAME = DrawFileChooser("RUNLabe", "RUNInput", "RUNBtn", 20.0f, false, "Rpc user name:", 120.0f, RPC_USERNAME, 330.0f, "", false, true); GUILayout.Space(10); RPC_PASSWORD = DrawFileChooser("RPSLabe", "RPSInput", "RPSBtn", 20.0f, false, "Rpc password:"******"", true, true); GUILayout.Space(10); GUILayout.BeginHorizontal(); GUILayout.Space(20.0f); GUILayout.Label("Network:", GUILayout.Width(120.0f)); //GUILayout.Space(10.0f); string[] arrNetType = new string[3]; arrNetType[0] = "MAIN"; arrNetType[1] = "TEST_NET"; arrNetType[2] = "REG_TEST"; RPC_NET_TYPE = (NETWORK_TYPE)EditorGUILayout.Popup((int)RPC_NET_TYPE, arrNetType, GUILayout.Width(90)); GUILayout.EndHorizontal(); GUILayout.Space(25); GUILayout.BeginHorizontal(); float fBtnWidth = 150.0f; float fX = ms_kSig.position.width * 0.5f - fBtnWidth * 0.5f; GUILayout.Space(fX); GUILayoutOption[] arrLO = new GUILayoutOption[2]; arrLO[0] = GUILayout.Width(fBtnWidth); arrLO[1] = GUILayout.Height(40); GUI.SetNextControlName("SaveBtn"); if (GUILayout.Button("Save", arrLO)) { string strKeyPrefix = Application.dataPath; if (!string.IsNullOrEmpty(RPC_HOST)) { PlayerPrefs.SetString(strKeyPrefix + "#RPC_HOST", RPC_HOST); } if (RPC_PORT > 0) { PlayerPrefs.SetInt(strKeyPrefix + "#RPC_PORT", RPC_PORT); } if (!string.IsNullOrEmpty(RPC_USERNAME)) { PlayerPrefs.SetString(strKeyPrefix + "#RPC_USERNAME", RPC_USERNAME); } if (!string.IsNullOrEmpty(RPC_PASSWORD)) { PlayerPrefs.SetString(strKeyPrefix + "#RPC_PASSWORD", RPC_PASSWORD); } PlayerPrefs.SetInt(strKeyPrefix + "#RPC_NET_TYPE", (int)RPC_NET_TYPE); PlayerPrefs.Save(); if (m_kCB != null) { m_kCB.Release(); m_kCB = null; } m_kCB = new IxMagnaChainBridge(); m_bCBInited = m_kCB.Initialize(RPC_HOST, RPC_PORT, RPC_USERNAME, RPC_PASSWORD, RPC_NET_TYPE); if (m_bCBInited == false) { if (EditorUtility.DisplayDialog("Erorr", "Initialize RCP client failed.", "OK")) { return; } } if (!string.IsNullOrEmpty(ms_strImportMasterKeyName) && !string.IsNullOrEmpty(ms_strMasterKey)) { m_kCB.ImportMasterExtKey(ms_strImportMasterKeyName, ms_strMasterKey); } } //GUI.FocusControl("SaveBtn"); GUILayout.EndHorizontal(); GUILayout.Space(40); ms_strImportMasterKeyName = DrawFileChooser("IMKNLabe", "IMKNInput", "IMKNBtn", 20.0f, false, "Master key name:", 120.0f, ms_strImportMasterKeyName, 330.0f, "", false, true); GUILayout.Space(10); ms_strMasterKey = DrawFileChooser("MKLabe", "MKInput", "MKBtn", 20.0f, false, "Master key:", 120.0f, ms_strMasterKey, 330.0f, "", false, true); GUILayout.Space(20); GUILayout.BeginHorizontal(); fBtnWidth = 180.0f; fX = ms_kSig.position.width * 0.5f - fBtnWidth * 0.5f; GUILayout.Space(fX); arrLO[0] = GUILayout.Width(fBtnWidth); arrLO[1] = GUILayout.Height(30); GUI.SetNextControlName("ImportMasterKey"); if (GUILayout.Button("Import Master Key", arrLO)) { if (m_kCB == null) { if (EditorUtility.DisplayDialog("Prompt", "MagnaChain has not initialized.", "OK")) { return; } } if (string.IsNullOrEmpty(ms_strImportMasterKeyName)) { if (EditorUtility.DisplayDialog("Prompt", "Please input master key name.", "OK")) { return; } } if (string.IsNullOrEmpty(ms_strMasterKey)) { if (EditorUtility.DisplayDialog("Prompt", "Please input master key.", "OK")) { return; } } if (m_kCB.IsMasterExtKeyExist(ms_strImportMasterKeyName)) { if (EditorUtility.DisplayDialog("Prompt", "The master key has imported: " + ms_strImportMasterKeyName, "OK")) { return; } } if (m_kCB.ImportMasterExtKey(ms_strImportMasterKeyName, ms_strMasterKey) == false) { if (EditorUtility.DisplayDialog("Error", "Import master key failed!", "OK")) { return; } } else { string strKeyPrefix = Application.dataPath; PlayerPrefs.SetString(strKeyPrefix + "#ms_strImportMasterKeyName", ms_strImportMasterKeyName); PlayerPrefs.SetString(strKeyPrefix + "#ms_strMasterKey", ms_strMasterKey); PlayerPrefs.Save(); if (EditorUtility.DisplayDialog("Done", "Import master key succeed.", "OK")) { return; } } } GUILayout.EndHorizontal(); }