コード例 #1
0
    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);
    }
コード例 #2
0
    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));
        }
    }
コード例 #3
0
    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);
        }
    }