コード例 #1
0
 public int set_security_info(eEncryptMethod enc_method, eKeyMaking key_mode, string dh_p_hex)
 {
     return(tgcpapi_csharp_set_security_info(handle_, enc_method, key_mode, dh_p_hex));
 }
コード例 #2
0
 private static extern int tgcpapi_csharp_init(IntPtr handle, int service_id, ePlatformID platform_id,
                                               ushort auth_type, eEncryptMethod enc_method, eKeyMaking key_mode, int buff_len);
コード例 #3
0
 private static extern int tgcpapi_csharp_set_security_info(IntPtr handle, eEncryptMethod enc_method, eKeyMaking key_mode, [MarshalAs(UnmanagedType.LPStr)] String dh_p_hex);
コード例 #4
0
 public int Init(int service_id, ePlatformID platform_id, UInt16 auth_type, eEncryptMethod enc_method, eKeyMaking key_mode, int buff_len)
 {
     return(tgcpapi_csharp_init(handle_, service_id, platform_id, auth_type, enc_method, key_mode, buff_len));
 }
コード例 #5
0
ファイル: NetworkConnect.cs プロジェクト: ghrguse/ss
    //连接
    private int ConnectInternal()
    {
        int    ret        = 0;
        int    iSerivceID = 123;
        int    iBuffLen   = 1024 * 1024;
        string appid      = "appId123456";

        eAccountType   AccountType = eAccountType.TGCP_ACCOUNT_TYPE_PC_OPENID;
        eEncryptMethod iEncMethod  = eEncryptMethod.TGCP_ENCRYPT_METHOD_AES;
        eKeyMaking     iKeyMode    = eKeyMaking.TGCP_KEY_MAKING_INSVR;

//        if (this.m_loginInfo == null)
//        {
//#if !UNITY_EDITOR
//            m_loginInfo = MSDK.Instance.getLoginRecord();
//            GlobalData.system.SaveLoginRetInfo(m_loginInfo);

//            appid = (PlatformType.Weixin == m_loginInfo.platform) ? NetConfig.wx_appid : NetConfig.qq_appid;
//#endif
//        }

        if (null != m_TgcpHandle)
        {
            Log.info("有旧的tcp handler", "NetConnector.connectInternal");
        }
        m_TgcpHandle = new TGCPAPI();

#if UNITY_STANDALONE_WIN
        m_TgcpHandle.WSAStartUp(2, 0);
#endif

        //switch (this.m_loginInfo.platform)
        //{
        //    case PlatformType.Weixin:
        //        AccountType = eAccountType.TGCP_ACCOUNT_TYPE_WX_OPENID;
        //        break;
        //    case PlatformType.QQ:
        //        AccountType = eAccountType.TGCP_ACCOUNT_TYPE_QQ_OPENID;
        //        break;
        //    case PlatformType.Guest:
        //        AccountType = eAccountType.TGCP_ACCOUNT_TYPE_IOS_GUEST;
        //        break;
        //    default:
        //        Log.info("AccountType 末赋值");
        //        break;
        //}

        Log.info("appid: " + appid);
        Log.info("openid: " + m_openid);
        Log.info("accesstoken: " + "");
        Log.info("AccountType: " + AccountType);
        Log.info("iEncMethod: " + iEncMethod);
        Log.info("iKeyMode: " + iKeyMode);
        Log.info("iSerivceID: " + iSerivceID);

        //if (string.IsNullOrEmpty(m_loginInfo.openid))
        //{
        //    Log.info("openid为空,须重新登录");
        //    //openid为空操作待补
        //    OnOpenIdIsEmptyHandler();
        //    return ret;
        //}
        // 发送更新鉴权信息
        //EventManager.Send(EventType_DataReport.QQ_REPORT_UPDATE_AUTH_INFO, new object[] { accesstoken, openid });

        byte[] byteid    = TDRTools.strToByte(appid);
        byte[] bytetoken = TDRTools.strToByte("access tokey");

        ret = m_TgcpHandle.create_and_init_string(iSerivceID, byteid, byteid.Length, iBuffLen, AccountType, m_openid, bytetoken, bytetoken.Length);
        if (0 != ret)
        {
            Log.info("m_TgcpHandle.create_and_init_string failed: " + ret);
            return(ret);
        }

        ret = m_TgcpHandle.set_security_info(iEncMethod, iKeyMode, "");
        if (0 != ret)
        {
            Log.info("m_TgcpHandle.set_security_info failed: " + ret);
            return(ret);
        }

        ret = m_TgcpHandle.set_refresh_token_expire(0);
        if (0 != ret)
        {
            Log.info("m_TgcpHandle.set_refresh_token_expire failed: " + ret);
            return(ret);
        }

        // #if UNITY_EDITOR
        //         ret = m_TgcpHandle.set_authtype(eAuthType.TGCP_AUTH_NONE);
        // #endif
        //暂时都关闭鉴权
        ret = m_TgcpHandle.set_authtype(eAuthType.TGCP_AUTH_NONE);

        Log.info("m_TgcpHandle init success");

        try
        {
            Log.info("ip: " + m_ipAddress);
            Log.info("port: " + GlobalData.system.serverData.port);
            ret = AsynConnectServer(m_ipAddress, m_port);
            if (0 != ret)
            {
                Log.infoWarning("Could not connect!");
                NotifyDisconnected((TGCP_ERROR)ret);
            }
            Log.info("Net_initConned");
        }
        catch (Exception ex)
        {
            Log.info(ex.ToString());
        }

        return(ret);
    }