예제 #1
0
 /// <summary>
 /// Saves any setting changed.
 /// </summary>
 private void SaveMachinationsConfig()
 {
     //Only saving settings if there are any.
     if (!_restoredFromSettings && MnConfig.HasSettings)
     {
         return;
     }
     //Create Settings instance if none exists.
     if (MnConfig.Instance == null)
     {
         MnConfig.Instance = new MnConfig();
     }
     //Connection details changed. Must reconnect.
     if (MnConfig.Instance.APIURL != _APIURL || MnConfig.Instance.UserKey != _userKey || MnConfig.Instance.DiagramToken != _diagramToken)
     {
         L.D("Reconnecting socket due to connection changes");
         MnDataLayer.Service?.Restart(_APIURL, _userKey, _diagramToken);
     }
     //Save details.
     MnConfig.Instance.APIURL       = _APIURL;
     MnConfig.Instance.UserKey      = _userKey;
     MnConfig.Instance.GameName     = _gameName;
     MnConfig.Instance.DiagramToken = _diagramToken;
     MnConfig.SaveSettings();
 }
예제 #2
0
        static public void InitMachinations()
        {
            L.Level       = LogLevel.Debug;
            L.LogFilePath = Application.dataPath + "//MachinationsService-Error.log";

            //Since Application.dataPath cannot be accessed from other threads (and we need that), storing it in MDL.
            MnDataLayer.AssetsPath = Application.dataPath;

            //Cannot operate until settings have been defined for Machinations.
            if (!MnConfig.LoadSettings())
            {
                MnConfig.HasSettings = false;
                L.W("Machinations Settings do not exist. Please configure Machinations using Tools -> Machinations -> Open Machinations.io Control Panel.");
                return;
            }

            //Bootstrap.
            _mnService    = MnDataLayer.Service = new MnService();
            _socketClient = new SocketIOClient(
                _mnService,
                MnConfig.Instance.APIURL,
                MnConfig.Instance.UserKey,
                MnConfig.Instance.DiagramToken,
                MnConfig.Instance.GameName);
            _mnService.UseSocket(_socketClient);
        }