Esempio n. 1
0
    IEnumerator CoSetupSlack()
    {
        secretData = new Kayac.SecretData();
        yield return(secretData.CoLoad());

        var token = secretData.Get("slackToken");

        if (token != null)
        {
            slack = new Kayac.DebugSlack(token, "unity-debug");
        }
    }
Esempio n. 2
0
    void Start()
    {
        // ログ蓄積クラス初期化
        _logHandler = new Kayac.MemoryLogHandler(lineCapacity: 100);         // 最新N個のログを保存

        /*
         * slackのtokenをコードに直打ちすると漏れそうで怖いですね。
         * 実用にする場合はいろいろ考えておくのが良いと思います。
         * このサンプルでは.gitignoreでgitに入らなくしたテキストファイルをStreamingAssetsから読んでいます。
         */
        var tokenFilePath = Application.streamingAssetsPath + "/slackToken.txt";
        var tokenFile     = new System.IO.StreamReader(tokenFilePath);     // 暗号化しといた方がいいよ!
        var token         = tokenFile.ReadToEnd();

        tokenFile.Close();
        _slack = new Kayac.DebugSlack(token, _defaultChannel);
    }
Esempio n. 3
0
    IEnumerator CoSetupSlack()
    {
        var tokenFilePath = Application.streamingAssetsPath + "/slackToken.txt";

        if (tokenFilePath.IndexOf("file:///") < 0)
        {
            tokenFilePath = "file://" + tokenFilePath;
        }
        var req = UnityEngine.Networking.UnityWebRequest.Get(tokenFilePath);

        req.SendWebRequest();
        yield return(req);

        if (req.error != null)
        {
            Debug.LogError(req.error);
        }
        else
        {
            var encodedToken = req.downloadHandler.text;                                                     // DebugSlack.EncryptXorで暗号化したものが入っている。もっとマシな暗号があってもいいと思う。
            var token        = Kayac.DebugSlack.DecryptXor("kodHUuU79PZDZ2U4cktSbuYpaBd5siH", encodedToken); // 復号化が鍵がコード直打ちという手抜き
            _slack = new Kayac.DebugSlack(token, "unity-debug");
        }
    }