关于unity www传入cookie的过程

WWWForm wWWForm = new WWWForm();
wWWForm.AddField(KeyTypes.imgFile,Encoding.UTF8.GetString(global.PhotoByte));
wWWForm.AddField(KeyTypes.mbInStoOdId, InputField_Text[1].text);
StartCoroutine(Www_KeyValueCookie(PathTypes.UploadStoInGoodsPicturePath, wWWForm));
 
public IEnumerator Www_KeyValueCookie(string pt, WWWForm wWWForm)
    {
        Dictionary headers = new Dictionary();
        headers["Content-Type"] = "application/x-www-form-urlencoded;charset=UTF-8";
        headers[KeyTypes.cookie] = KeyTypes.token + global.VipToken + ";";
        byte[] bs = wWWForm.data;

        WWW wWW = new WWW(PathTypes.IP + pt, bs, headers);
        yield return wWW;
        if (wWW.error != null)
        {
            Debug.Log(wWW.error);
            yield return null;
        }
        OnMessage(wWW.text);
    }

/// 
    /// 回调
    /// 
    /// 
    private void OnMessage(string text)
    {
        JsonData jsonData = JsonMapper.ToObject(text);
        //操作失败
        if (jsonData[OnMessageKey.status].ToString() == OnMessageValueError.statuError)
        {
            switch (jsonData[OnMessageKey.msg].ToString())
            {
                case OnMessageValueError.infoError:
                    break;   
            }
        }
        //操作成功
        else if (jsonData[OnMessageKey.status].ToString() == OnMessageValueSuccess.statuSuccess)
        {
            switch (jsonData[OnMessageKey.msg].ToString())
            {
                //上传成功
                case OnMessageValueSuccess.uploadSuccess:
                    break;

            }
        }
    }

 

你可能感兴趣的:(unity功能,unity,cookie,www)