// Copyright 2013-2022 AFI,Inc. All rights reserved

using System.Collections.Generic;
using UnityEngine;
using BackEnd;

public class BackendManager : MonoBehaviour {
    
    public static BackendManager Instance { get; private set; }

    void Awake() {
        if (Instance == null) {
            Instance = this;
        }
    }
    
    // Start is called before the first frame update
    void Start()
    {

        var settings = Resources.Load<TheBackendSettings>("TheBackendSettings");
        
        BackendCustomSetting customSetting = new BackendCustomSetting();
        customSetting.clientAppID = settings.clientAppID;
        customSetting.signatureKey = settings.signatureKey;
        customSetting.functionAuthKey = settings.functionAuthKey;

        customSetting.networkType = NetworkType.HTTP_CLIENT;
        
        var bro = Backend.Initialize(customSetting);

        if (bro.IsSuccess()) {
            LogManager.Log("초기화가 성공하였습니다.");
        } else {
            UIManager.Instance.OpenConfig();
            AlertUI.Instance.OpenUI("초기화중 에러가 발생하였습니다", bro);
        }
    }
}