public static GameinHeader GetHeader(WWW ws) { var res = new GameinHeader(); ws.responseHeaders.TryGetValue("GAMEIN_USERDATA", out res.userdata); ws.responseHeaders.TryGetValue("GAMEIN_ERROR", out res.error); ws.responseHeaders.TryGetValue("GAMEIN_ACCESS", out res.access); return(res); }
IEnumerator RequestAuthenCode() { // request authentication ticket byte[] secretKey = AuthenService.SecretKey(32); byte[] publicKey = AuthenService.PublicKey(secretKey, 7, 23); var ws = PostWWW(serverAddress + uriCode, "63", "", publicKey); yield return(ws); Debug.Log("received: " + ws.text); gameinHeader = GetHeader(ws); if (gameinHeader.userdata == "63") { byte[] rcvd_key = System.Text.Encoding.ASCII.GetBytes(ws.text); finalKey = AuthenService.FinalKey(secretKey, rcvd_key, 23); Debug.Log("Key: " + System.Text.ASCIIEncoding.ASCII.GetString(finalKey)); } }
IEnumerator LoginWithDevice() { if (gameinHeader.userdata == "63") { var msg = "{" + "\"ver\":1" + ",\"game\":" + gameKey + ",\"device\":" + deviceId + "}"; Debug.Log("sending: " + msg); byte[] authencode = System.Text.Encoding.ASCII.GetBytes(gameinHeader.access); byte[] endata = AuthenService.Encrypt(System.Text.Encoding.ASCII.GetBytes(msg), finalKey); var ws = PostWWW(serverAddress + uriDevice, gameinHeader.userdata, gameinHeader.access, endata); yield return(ws); gameinHeader = GetHeader(ws); Debug.Log("received: " + ws.text); } }