Example #1
0
    //创建请求vo
    public SnapRequestVO createRequestVO(SnapAppApiInterface requestInterTypestring, string apiName,
                                         string requestMethod, JsonData jsonData = null, Action <SnapRpcDataVO> callBackAction = null,
                                         int priority = 0, SnapAppApiThirdRequestFace third = SnapAppApiThirdRequestFace.No_Third)
    {
        SnapRequestVO requestVO = new SnapRequestVO(jsonData, callBackAction);

        requestVO.requestActionId = requestInterTypestring;
        requestVO.requestAction   = apiName;
        requestVO.requestMethod   = requestMethod;
        requestVO.requestId       = ++requestIndex;
        requestVO.requestPriority = priority;
        requestVO.thirdType       = third;

        if (jsonData != null)
        {
            requestVO.urlTypeExt = jsonData.TryGetString("urlTypeExt", "?");
        }

        if (priority == int.MaxValue)
        {
            requestVOList.Insert(0, requestVO);
        }
        else
        {
            requestVOList.Add(requestVO);
        }
        return(requestVO);
    }
Example #2
0
 public void Request_SnapAppApi(SnapAppApiInterface requestInterType, string apiName,
                                string requestMethod, JsonData jsonData = null,
                                Action <SnapRpcDataVO> callBackAction   = null, int priority = 0,
                                SnapAppApiThirdRequestFace third        = SnapAppApiThirdRequestFace.No_Third)
 {
     createRequestVO(requestInterType, apiName, requestMethod, jsonData, callBackAction, priority, third);
     sendHttpRequest();
 }
Example #3
0
    public static HttpErrorCodeDelegate RequestErrorCodeBack = null;    //登录回调


    /// <summary>
    /// 请求App新版本的api
    /// </summary>
    /// <param name="requestInterType">请求接口名称,枚举值</param>
    /// <param name="requestMethod">请求接口方法SnapHttpConfig.NET_REQUEST_GET/SnapHttpConfig.NET_REQUEST_POST</param>
    /// <param name="jsonData">发送请求的数据</param>
    /// <param name="callBackAction">服务器返回数据的callback事件</param>
    /// <param name="priority">发送请求的优先级</param>
    static public void Request_SnapAppApi(SnapAppApiInterface requestInterType, string requestMethod,
                                          JsonData jsonData = null, Action <SnapRpcDataVO> callBackAction = null,
                                          int priority      = 0, SnapAppApiThirdRequestFace third = SnapAppApiThirdRequestFace.No_Third)
    {
        string apiName = "";

        switch (requestInterType)
        {
        case SnapAppApiInterface.Request_LoginApp:
            apiName = User_Service_Login;
            break;

        case SnapAppApiInterface.Request_GetUserInfo:
            apiName = User_Service_Get_Info;
            break;

        case SnapAppApiInterface.Request_RegisterApp:
            apiName = User_Service_Register;
            break;

        case SnapAppApiInterface.Request_RegisterGuestApp:
            apiName = Guest_Service_Register;
            break;

        case SnapAppApiInterface.Request_CheckUserNameApp:
            apiName = User_Service_CheckUserName;
            break;

        case SnapAppApiInterface.Request_ModifyPwdApp:
            apiName = User_Service_ModifyPwd;
            break;

        case SnapAppApiInterface.Request_AliyunOSSApp:
            apiName = Request_Aliyun_OSS;
            break;

        case SnapAppApiInterface.Request_ThirdWebToApp:
            //第三方的都走这个,需要什么数据自己封装
            apiName = jsonData.TryGetString("apiName");
            break;

        case SnapAppApiInterface.Request_WeChatShareGame:
            apiName = User_Service_WeChatShare;
            break;

        case SnapAppApiInterface.Request_UploadGameInfo:
            apiName = User_Service_UploadGame_Info + "/" + jsonData.TryGetString("uid");
            break;

        case SnapAppApiInterface.Request_UpdateUserInfo:
            apiName = User_Service_UpdateUserInfo;
            break;

        case SnapAppApiInterface.Request_GetGuestUserInfoByDeviceId:
            apiName = Guest_Service_GetInfoByDeviceId;
            break;

        case SnapAppApiInterface.Request_GetLevelScore:
            apiName = User_Service_GetLevelScore;
            break;

        case SnapAppApiInterface.Request_GetRankScoresByLevelID:
            apiName = User_Service_GetRankScores + "/" + jsonData.TryGetString("levelID");
            break;

        case SnapAppApiInterface.Request_GetRankOfTenByIDs:
            apiName = User_Service_GetRankOfTenByID;
            break;

        case SnapAppApiInterface.Request_UploadGameScores:
            apiName = User_Service_UploadGameScores + "/";
            break;

        case SnapAppApiInterface.Request_IAPGetGoodsInfo:
            apiName = User_IAP_GetGoodsInfo;
            break;

        case SnapAppApiInterface.Request_IAPGetGoodsVerify:
            apiName = User_IAP_Verify;
            break;

        case SnapAppApiInterface.Request_CurAppVersion:
            apiName = App_GetCurrentVersion;
            break;

        case SnapAppApiInterface.Request_UploadLevelVoices:
            apiName = User_Service_UploadLevelVoices;
            break;

        case SnapAppApiInterface.Request_GetLevelVoices:
            apiName = User_Service_UploadLevelVoices;
            break;
        }
        //SnapHttpConfig.REQUEST_APP_API_TOKEN = (apiName.IndexOf (User_Anonymous_Header) != -1) ?
        //SnapHttpConfig.NOT_LOGINED_APP_TOKEN : SnapHttpConfig.LOGINED_APP_TOKEN;

        SnapHttpManager.getInstance().Request_SnapAppApi(requestInterType, apiName, requestMethod, jsonData, callBackAction, priority, third);
    }