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); }
/// <summary> /// Prepares and Connects the Socket to the Machinations Backend. /// </summary> /// <param name="mnService">MachinationsService to interact with for data transactions.</param> /// <param name="socketURL">The URL where the Machinations API resides.</param> /// <param name="userKey">User Key (API key) to use when connecting to the back-end.</param> /// <param name="diagramToken">Diagram Token to make requests to.</param> /// <param name="gameName">OPTIONAL. Game name.</param> public SocketIOClient(MnService mnService, string socketURL, string userKey, string diagramToken, string gameName = null) { _socketURL = socketURL; _userKey = userKey; _gameName = gameName; _diagramToken = diagramToken; _mnService = mnService; _socketPulse = new System.Timers.Timer(1000); _socketPulse.Elapsed += SocketPulse_OnElapsed; _socketPulse.Start(); InitSocket(); }