public void LoadConfig() { softGetawayServiceState serviceState = (softGetawayServiceState)objectFromFile(strStateFileName + "config", typeof(softGetawayServiceState)); if (serviceState != null) { // Set SSID and Password SetPrivateConnectionSettings(new ConnectionSettings() { SSID = serviceState.wifiSSID, MaxPeerCount = serviceState.limitClientsCount, Password = serviceState.wifiPassword }); SetIP(serviceState.privateIP); softGetawayPeersStorage peersState; peersState = (softGetawayPeersStorage)objectFromFile(strStateFileName + "peers", typeof(softGetawayPeersStorage)); if ((peersState != null) && (peersState.peers != null)) { foreach (var p in peersState.peers) { privateManager.AddPeerFromStorage(p); } } this.currentSharedConnectionGuid = serviceState.publicConnectionGuid; shouldStart_ = serviceState.active; } }
public void SaveConfig() { Trace.TraceInformation("Getaway saving config"); var serviceState = new softGetawayServiceState(); serviceState.active = shouldStart_; var connGuid = GetSharedConnection(); if (connGuid != null) { serviceState.publicConnectionGuid = connGuid; } var connSettings = GetPrivateConnectionSettings(); serviceState.wifiSSID = connSettings.SSID; serviceState.limitClientsCount = connSettings.MaxPeerCount; serviceState.wifiPassword = connSettings.Password; serviceState.privateIP = GetIP(); objectToFile(strStateFileName + "config", serviceState); var peersState = new softGetawayPeersStorage(); foreach (var peerService in GetPeers()) { NetworkPeerStorage storage = (NetworkPeerStorage)peerService.storage.Clone(); if (!peerService.isSetHostName) { storage.HostName = null; } if (!peerService.isSetIP) { storage.IPAddress = null; } peersState.peers.Add(storage); } objectToFile(strStateFileName + "peers", peersState); Trace.TraceInformation("Getaway config saved"); }
public void SaveConfig() { Trace.TraceInformation("Getaway saving config"); var serviceState = new softGetawayServiceState(); serviceState.active = shouldStart_; var connGuid = GetSharedConnection(); if (connGuid != null) { serviceState.publicConnectionGuid = connGuid; } var connSettings = GetPrivateConnectionSettings(); serviceState.wifiSSID = connSettings.SSID; serviceState.limitClientsCount = connSettings.MaxPeerCount; serviceState.wifiPassword = connSettings.Password; serviceState.privateIP = GetIP(); objectToFile(strStateFileName + "config", serviceState); var peersState = new softGetawayPeersStorage(); foreach (var peerService in GetPeers()) { NetworkPeerStorage storage = (NetworkPeerStorage)peerService.storage.Clone(); if (!peerService.isSetHostName) storage.HostName = null; if (!peerService.isSetIP) storage.IPAddress = null; peersState.peers.Add(storage); } objectToFile(strStateFileName + "peers", peersState); Trace.TraceInformation("Getaway config saved"); }