public NetParam GetUserRecord() { string username = PlayerPrefs.GetString("username"); string password = PlayerPrefs.GetString("password"); NetParam param = new NetParam(); param.SetParam((byte)LoginType.NETWORK_LOGIN, "", username, password); return(param); }
/// <summary>解析数据</summary> private void PraseData(NetData data) { NetParam n = null; if (!NetDataMgr.Instance.Mrgs.TryGetValue(data.m_serverRespone, out n)) { Debug.LogError(data.m_serverRespone.ToString() + ": not register class like xxxS2C"); return; } System.Object obj = ProtoBuf.Meta.RuntimeTypeModel.Default.Deserialize(m_protoms, null, n.mType); Debug.Log("接收数据:" + data.m_serverRespone + " len:" + data.m_data.Length); n.mfun(obj); }
public void HttpSuccess(WWW p_www) { string data = p_www.text; if (readerResponse.Count <= 0) { return; } NetParam param = readerResponse[0]; byte type = (byte)param.type; string username = param.usrname; string password = param.password; readerResponse.RemoveAt(0); NetTools.Log(data); JsonData jsonData = JsonMapper.ToObject(data); if (jsonData["code"].ToString() != "1") { HttpFailed(jsonData["msg"].ToString()); return; } if (type == (byte)LoginType.NETWORK_LOGIN) { Uid = long.Parse(jsonData["datas"]["id"].ToString()); UName = jsonData["datas"]["uname"].ToString(); Token = jsonData["datas"]["token"].ToString(); //ServerConnection.Instance.serverTime = long.Parse(jsonData["datas"]["tokentime"].ToString()); //这里记录一下用户帐号密码,用于下次自动登录或者填充输入框 PlayerPrefs.SetString(USERNAME_FIELD, param.usrname); PlayerPrefs.SetString(PASSWORD_FIELD, param.password); NetTools.Log("NETWORK_LOGIN : "******"NETWORK_REGIST : " + data); //直接调用登录接口 Login(username, password); } }
//登录 public void Login(string username, string password) { //发起http请求获得token,user id string uri = HTTP_LOGIN_SERVER_ADDRESS; NetParam param = new NetParam(); param.SetParam((byte)LoginType.NETWORK_LOGIN, uri, username, password); readerResponse.Add(param); Dictionary <string, string> post = new Dictionary <string, string>(); post.Add("logic", "0"); post.Add("uname", username); post.Add("pw", password); //by te on 20170616 HttpConnection.Instance.Connect(uri, post, HttpSuccess); //StartCoroutine(HttpGet(uri,post)); }
public CSMethod CompileMethod(FunctionDeclaration func, CSUsingPackages packs, string libraryPath, string mangledName, string functionName, bool isPinvoke, bool isFinal, bool isStatic) { isStatic = isStatic || func.IsExtension; var extraProtoArgs = new CSGenericTypeDeclarationCollection(); var extraProtoConstraints = new CSGenericConstraintCollection(); var args = typeMap.MapParameterList(func, func.ParameterLists.Last(), isPinvoke, false, extraProtoArgs, extraProtoConstraints); if (isPinvoke && func.ParameterLists.Count > 1) { var metaTypeBundle = new NetTypeBundle("SwiftRuntimeLibrary", "SwiftMetatype", false, false, EntityType.None); NetParam p = new NetParam("metaClass", metaTypeBundle); args.Add(p); } NetTypeBundle returnType = null; if (func.ReturnTypeSpec is ProtocolListTypeSpec plitem && !isPinvoke) { returnType = new NetTypeBundle("System", "object", false, false, EntityType.ProtocolList); }