Added SQLite storage backend.
This commit is contained in:
parent
999ce86a27
commit
3f6007922c
21 changed files with 665 additions and 245 deletions
SharpChat
|
@ -1,9 +1,10 @@
|
|||
using SharpChat;
|
||||
using SharpChat.Configuration;
|
||||
using SharpChat.Messages;
|
||||
using SharpChat.Flashii;
|
||||
using System.Text;
|
||||
using SharpChat.MariaDB;
|
||||
using SharpChat.Messages;
|
||||
using SharpChat.SQLite;
|
||||
using System.Text;
|
||||
|
||||
const string CONFIG = "sharpchat.cfg";
|
||||
|
||||
|
@ -124,18 +125,23 @@ FlashiiClient flashii = new(httpClient, config.ScopeTo("msz"));
|
|||
|
||||
if(hasCancelled) return;
|
||||
|
||||
MessageStorage msgStore;
|
||||
if(string.IsNullOrWhiteSpace(config.SafeReadValue("mariadb:host", string.Empty))) {
|
||||
msgStore = new VirtualMessageStorage();
|
||||
} else {
|
||||
MariaDBMessageStorage mdbes = new(MariaDBMessageStorage.BuildConnString(config.ScopeTo("mariadb")));
|
||||
msgStore = mdbes;
|
||||
await mdbes.RunMigrations();
|
||||
Storage storage = string.IsNullOrWhiteSpace(config.SafeReadValue("mariadb:host", string.Empty))
|
||||
? new SQLiteStorage(SQLiteStorage.BuildConnectionString(config.ScopeTo("sqlite")))
|
||||
: new MariaDBStorage(MariaDBStorage.BuildConnectionString(config.ScopeTo("mariadb")));
|
||||
|
||||
try {
|
||||
if(hasCancelled) return;
|
||||
|
||||
await storage.UpgradeStorage();
|
||||
|
||||
if(hasCancelled) return;
|
||||
|
||||
using SockChatServer scs = new(flashii, flashii, storage.CreateMessageStorage(), config.ScopeTo("chat"));
|
||||
scs.Listen(mre);
|
||||
|
||||
mre.WaitOne();
|
||||
} finally {
|
||||
if(storage is IDisposable disp)
|
||||
disp.Dispose();
|
||||
}
|
||||
|
||||
if(hasCancelled) return;
|
||||
|
||||
using SockChatServer scs = new(flashii, flashii, msgStore, config.ScopeTo("chat"));
|
||||
scs.Listen(mre);
|
||||
|
||||
mre.WaitOne();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue