public static IFullNodeBuilder UseMessagingHost(this IFullNodeBuilder fullNodeBuilder) { LoggingConfiguration.RegisterFeatureNamespace <MessagingHostFeature>(nameof(MessagingHostFeature)); var fStoreConfig = new FStoreConfig { DefaultStoreName = "FStore", StoreLocation = new DirectoryInfo(Path.Combine(fullNodeBuilder.NodeSettings.DataDir, "messaging")), Initializer = FStoreInitializer.InitFStore }; FStoreInitializer.InitFStore(fStoreConfig); fullNodeBuilder.ConfigureFeature(features => { features .AddFeature <MessagingHostFeature>() .FeatureServices(services => { services.AddSingleton(fStoreConfig); services.AddSingleton <IMessageNodeRepository, MessageNodeRepository>(); services.AddTransient <CommandProcessor>(); services.AddSingleton <IRequestHandler, NoTLSRequestHandler>(); services.AddTransient <TcpAsyncServer>(); }); }); return(fullNodeBuilder); }
public static void InitFStore(FStoreConfig fStoreConfig) { var fStore = new FStoreMono(fStoreConfig); if (!fStore.StoreExists()) { fStore.CreateStore(); } var profilesTable = new FSTable(nameof(Profile), IdMode.UserGenerated); // Single item, Id does not matter but speeds things up if (!fStore.TableExists(profilesTable, null)) { fStore.CreateTable(profilesTable); } FStoreTables.TableConfig[typeof(Profile)] = profilesTable; var contactsTable = new FSTable(nameof(Identity), IdMode.UserGenerated); // Id is necessary to retrieve an item if (!fStore.TableExists(contactsTable, null)) { fStore.CreateTable(contactsTable); } FStoreTables.TableConfig[typeof(Identity)] = contactsTable; var messagesTable = new FSTable(nameof(Message), IdMode.Auto, true, true); // e.g. /tbl_Message/1234567890/999999 if (!fStore.TableExists(messagesTable, null)) // /[page: recipientId]/[auto-id] { fStore.CreateTable(messagesTable); } FStoreTables.TableConfig[typeof(Message)] = messagesTable; }
public static void InitFStore(FStoreConfig fStoreConfig) { var fStore = new FStoreMono(fStoreConfig); var identitiesTable = new FSTable(nameof(XIdentity), IdMode.UserGenerated); // Id is necessary to retrieve an item if (!fStore.TableExists(identitiesTable, null)) { fStore.CreateTable(identitiesTable); } FStoreTables.TableConfig[typeof(XIdentity)] = identitiesTable; var messagesTable = new FSTable(nameof(XMessage), IdMode.UserGenerated, true, false); // e.g. /tbl_XMessage/1234567890/ac59f6f8-6e93-e185-d01a-94220b30d216 if (!fStore.TableExists(messagesTable, null)) { fStore.CreateTable(messagesTable); } FStoreTables.TableConfig[typeof(XMessage)] = messagesTable; var resendRequestsTable = new FSTable(nameof(XResendRequest), IdMode.UserGenerated, false, false); // e.g. /tbl_XMessage/1234567890/ac59f6f8-6e93-e185-d01a-94220b30d216 if (!fStore.TableExists(resendRequestsTable, null)) { fStore.CreateTable(resendRequestsTable); } FStoreTables.TableConfig[typeof(XResendRequest)] = resendRequestsTable; }
public AppRepository(FStoreConfig fStoreConfig, IXDSSecService xdsSecService) { this.profiles = new FStoreRepository <Profile>(new FStoreMono(fStoreConfig), RepositorySerializer.Serialize, RepositorySerializer.Deserialize <Profile>); this.contacts = new FStoreRepository <Identity>(new FStoreMono(fStoreConfig), RepositorySerializer.Serialize, RepositorySerializer.Deserialize <Identity>); this.messages = new FStoreRepository <Message>(new FStoreMono(fStoreConfig), RepositorySerializer.Serialize, RepositorySerializer.Deserialize <Message>); RepositorySerializer.XDSSecService = xdsSecService; }
public MessageNodeRepository(ILoggerFactory loggerFactory, FStoreConfig fStoreConfig) { this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.identitiesRepository = new FStoreRepository <XIdentity>(new FStoreMono(fStoreConfig), XIdentityExtensions.SerializeXIdentity, XIdentityExtensions.DeserializeXIdentityCore); this.messagesRepository = new FStoreRepository <XMessage>(new FStoreMono(fStoreConfig), XMessageExtensions.SerializeCore, XMessageExtensions.DeserializeMessage); this.resendRequestsRepository = new FStoreRepository <XResendRequest>(new FStoreMono(fStoreConfig), XResendRequestExtensions.Serialize, XResendRequestExtensions.DeserializeResendRequest); this.statsWatch = new Stopwatch(); }
public Cancellation(ILoggerFactory loggerFactory, DeviceVaultService deviceVaultService, FStoreConfig fStoreConfig) { this.logger = loggerFactory.CreateLogger <Cancellation>(); this.deviceVaultService = deviceVaultService; this.fStoreConfig = fStoreConfig; this.cts = new CancellationTokenSource(); this.cts.Token.Register(Shutdown); this.workers = new List <IWorker>(); this.workers.Add(new InfoWorker(this.workers, loggerFactory, this.cts.Token)); }
static void AddRequiredServices(IServiceCollection services, DirectoryInfo dataDirRoot) { if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { services.AddLogging(loggingBuilder => { loggingBuilder.AddConsole(); }); } else { services.AddLogging(loggingBuilder => { loggingBuilder.ClearProviders(); }); } services.InjectClipboard(); services.AddSingleton(GetConfiguration()); services.AddSingleton <ICancellation, Cancellation>(); services.AddSingleton <PeerManager>(); var fStoreConfig = new FStoreConfig { DefaultStoreName = "FStore", StoreLocation = dataDirRoot, Initializer = FStoreInitializer.EnsureFStore }; services.AddSingleton(fStoreConfig); services.AddSingleton <AppRepository>(); services.AddSingleton <MessageRelayRecordRepository>(); services.AddSingleton <PeerRepository>(); BootstrapperCommon.RegisterServices(services); services.AddSingleton <IDispatcher, ConsoleDispatcher>(); services.AddSingleton <IAssemblyInfoProvider>(new AssemblyInfoProvider { Assembly = typeof(Program).GetTypeInfo().Assembly }); var crypto = new XDSSecService(); crypto.Init(new Platform_NetStandard()); services.AddSingleton <IXDSSecService>(crypto); services.AddSingleton <IMessageBoxService>(new MessageBoxService()); services.AddSingleton <IFileService, FileService>(); services.AddSingleton <MessageRelayConnectionFactory>(); services.AddSingleton <ITcpConnection>(x => x.GetRequiredService <MessageRelayConnectionFactory>()); services.AddSingleton <IMessageRelayAddressReceiver>(x => x.GetRequiredService <MessageRelayConnectionFactory>()); services.AddSingleton <IUdpConnection, MockUdpConnection>(); services.AddSingleton <INotificationService, NotificationService>(); }
public MessageRelayRecordRepository(FStoreConfig fStoreConfig) { this.messageNodeRecords = new FStoreRepository <MessageRelayRecord>(new FStoreMono(fStoreConfig), MessageRelayRecordSerializer.Serialize, MessageRelayRecordSerializer.Deserialize); }
public PeerRepository(FStoreConfig fStoreConfig) { this.peers = new FStoreRepository <Peer>(new FStoreMono(fStoreConfig), PeerSerializer.SerializeCore, PeerSerializer.Deserialize); }