private Room(IServerController server) { if (server == null) throw new ArgumentNullException(nameof(server)); this.Id = Guid.NewGuid().ToString(); this.server = server; }
public Room(IServerController server, IRoomDeserialiser deserialiser) : this(server) { if (deserialiser == null) throw new ArgumentNullException(nameof(deserialiser)); // load state from deserialiser }
/// <summary> /// Creating a new room /// </summary> /// <param name="server"></param> /// <param name="creator"></param> /// <param name="name"></param> public Room(IServerController server, IUser creator, string name) : this(server) { if (creator == null) throw new ArgumentNullException(nameof(creator)); if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("no name", nameof(name)); Creator = creator; Name = name; }
/// <summary> /// method used to initialize the Model module /// </summary> /// <param name="handlers"></param> public void IntializeModel(ControllerEventHandlers handlers) { try { _identity = new Identity(SystemConfiguration.Instance.FriendlyName); SystemConfiguration.Instance.MyIdentity = _identity.GenerateIdentity(SystemConfiguration.Instance.MyAddress, SystemConfiguration.Instance.Port, SystemConfiguration.Instance.ServicePath); //_dvContacts = _contactsDAL.LoadContacts(SystemConfiguration.Instance.DataBasePath); _contactsDAL.LoadContacts(SystemConfiguration.Instance.DataBasePath); ContactEndpoint myEndpoint = IdentityResolver.ResolveIdentity(((Identity)Identity).MyIdentity ); _serverController = new ServerController(myEndpoint, ((Identity)Identity).MyIdentity, handlers, _useSecurity); } catch (Exception ex) { Tools.Instance.Logger.LogError(ex.ToString()); } }
public MainViewModel(IServerController serverController) { this._serverController = serverController; _info = new InfoPanelViewModel(); _info.Initialize(); _manageModel = new ActionsViewModel(this._serverController); _statusBar = new StatusBarViewModel(); _statusBar.CurrentStatus = "Ready."; _connections = new ConnectionsViewModel(this._serverController); _preferences = new PreferencesViewModel(); _preferences.PropertyChanged += _preferences_PropertyChanged; ServerEventHandlers handlers = new ServerEventHandlers(this); handlers.Register(ServerEventsGateway.Instance); _tray = new SystemTray(Application.Current.MainWindow, Zenith.Assets.Properties.Resources.chart_bubble); }
public Station(IServerController controller) { _controller = controller; }
protected void UpdateSharesList_NoLock(bool create) { lock (_syncObj) if (create) { _sharesList = new ItemsList(); } else { _sharesList.Clear(); } try { IServerConnectionManager scm = ServiceRegistration.Get <IServerConnectionManager>(); IContentDirectory cd = scm.ContentDirectory; IServerController sc = scm.ServerController; if (cd == null || sc == null) { return; } IRemoteResourceInformationService rris = ServiceRegistration.Get <IRemoteResourceInformationService>(); ICollection <Share> allShares = cd.GetShares(null, SharesFilter.All); IDictionary <string, ICollection <Share> > systems2Shares = new Dictionary <string, ICollection <Share> >(); foreach (Share share in allShares) { ICollection <Share> systemShares; if (systems2Shares.TryGetValue(share.SystemId, out systemShares)) { systemShares.Add(share); } else { systems2Shares[share.SystemId] = new List <Share> { share } }; } ICollection <Guid> importingShares = cd.GetCurrentlyImportingShares() ?? new List <Guid>(); ICollection <string> onlineSystems = sc.GetConnectedClients(); onlineSystems = onlineSystems == null ? new List <string> { scm.HomeServerSystemId } : new List <string>(onlineSystems) { scm.HomeServerSystemId }; foreach (KeyValuePair <string, ICollection <Share> > system2Shares in systems2Shares) { string systemId = system2Shares.Key; ICollection <Share> systemShares = system2Shares.Value; string systemName; string hostName; if (systemId == scm.HomeServerSystemId) { systemName = scm.LastHomeServerName; hostName = scm.LastHomeServerSystem.HostName; } else { MPClientMetadata clientMetadata = ServerCommunicationHelper.GetClientMetadata(systemId); if (clientMetadata == null) { systemName = null; hostName = null; } else { systemName = clientMetadata.LastClientName; hostName = clientMetadata.LastSystem.HostName; } } ListItem systemSharesItem = new ListItem(Consts.KEY_NAME, systemName); systemSharesItem.AdditionalProperties[Consts.KEY_SYSTEM] = systemId; systemSharesItem.AdditionalProperties[Consts.KEY_HOSTNAME] = hostName; bool isConnected = onlineSystems.Contains(systemId); systemSharesItem.AdditionalProperties[Consts.KEY_IS_CONNECTED] = isConnected; ItemsList sharesItemsList = new ItemsList(); foreach (Share share in systemShares) { ListItem shareItem = new ListItem(Consts.KEY_NAME, share.Name); shareItem.AdditionalProperties[Consts.KEY_SHARE] = share; string resourcePathName; try { bool isFileSystemResource; bool isFile; string resourceName; DateTime lastChanged; long size; if (!rris.GetResourceInformation(share.SystemId, share.BaseResourcePath, out isFileSystemResource, out isFile, out resourcePathName, out resourceName, out lastChanged, out size)) { // Error case: The path is invalid resourcePathName = LocalizationHelper.Translate(Consts.RES_INVALID_PATH, share.BaseResourcePath); } } catch (Exception) // NotConnectedException when remote system is not connected at all, UPnPDisconnectedException when remote system gets disconnected during the call { resourcePathName = share.BaseResourcePath.ToString(); } shareItem.SetLabel(Consts.KEY_PATH, resourcePathName); string categories = StringUtils.Join(", ", share.MediaCategories); shareItem.SetLabel(Consts.KEY_MEDIA_CATEGORIES, categories); UpdateShareImportState_NoLock(shareItem, importingShares.Contains(share.ShareId)); Share shareCopy = share; shareItem.Command = new MethodDelegateCommand(() => ReImportShare(shareCopy)); shareItem.AdditionalProperties[Consts.KEY_REIMPORT_ENABLED] = isConnected; sharesItemsList.Add(shareItem); } systemSharesItem.AdditionalProperties[Consts.KEY_SYSTEM_SHARES] = sharesItemsList; lock (_syncObj) _sharesList.Add(systemSharesItem); } } finally { _sharesList.FireChange(); } }
public ActionsViewModel(IServerController serverController) { this._serverController = serverController; }
public static string LocalAddress(this IServerController controller) { return(controller.LocalAddress ?? Global.Settings.LocalAddress); }
public static ushort Socks5LocalPort(this IServerController controller) { return(controller.Socks5LocalPort ?? Global.Settings.Socks5LocalPort); }
public override IServerView CreateServerView(IServerController p_ServerController, string p_ServerName) { return(new ServerTabUserControl(p_ServerController, p_ServerName)); }