public void QueryTargetFromQuerySourceTest() { using (var Server = new ObjectServer("SopBin\\OServer.dta")) { IStoreFactory sf = new StoreFactory(); var store = sf.Get <int, string>(Server, "People1"); var nameStore = sf.Get <string, int>(Server, "People2"); const int IterationCount = 100; int[] array = new int[IterationCount]; for (int i = 0; i < IterationCount; i++) { store.Add(i, string.Format("Value {0}.", i)); nameStore.Add(string.Format("Joe {0}.", i), i); array[i] = i; } store.Add(9, string.Format("Value {0}.", 9)); var names = nameStore.Query(new string[] { "Joe 9.", "Joe 21." }); var qry = from a in store.Query(names) select a; int ctr = 0; foreach (var itm in qry) { Assert.IsTrue(itm.Key == 9 || itm.Key == 21); ctr++; } Assert.IsTrue(ctr == 3); } }
/// <summary> /// Manage 250K records with Blobs (7,000 byte sized array). /// </summary> public void Run() { Console.WriteLine("{0}: PeopleDirectoryWithBigData demo started...", DateTime.Now); // create Server (open the data file) and begin a transaction... using (var Server = new ObjectServer("SopBin\\OServer.dta", false, // increase the Store's segment size so we can fit in one segment more than one Blob Big data (1 Blob = 500MB!). new Preferences { StoreSegmentSizeInKb = 524288 * 4 })) { IStoreFactory sf = new StoreFactory(); // set last parameter (IsDataInKeySegment) to false as we'll store Blob data of 16 KB size each. PeopleStore = sf.GetPersistent <Person, PersonBlob>(Server.SystemFile.Store, "People", new PersonComparer(), true, false); // Set the Store to AutoFlush so inserted Blob data will get mapped to disk right away // and not buffered in Store's MRU cache (a.k.a. - streaming). PeopleStore.AutoFlush = true; if (PeopleStore.Count == 0) { Populate(); } else { Console.WriteLine("Processing {0} records", PeopleStore.Count); ReadAll(); } Server.Commit(); } Console.WriteLine("{0}: PeopleDirectoryWithBigData demo ended...", DateTime.Now); }
public void StressTest() { using (var Server = new ObjectServer("SopBin\\OServer.dta")) { IStoreFactory sf = new StoreFactory(); var store = sf.Get <int, string>(Server, "People2"); // insert 10,000 records, query all of it in an ascending order, // then verify whether Query result contains each of the records in the set, // and is in ascending order. const int IterationCount = 10000; int[] array = new int[IterationCount]; for (int i = 0; i < IterationCount; i++) { store.Add(i, string.Format("Value {0}.", i)); array[i] = i; } // NOTE: in reality, "Query" is not needed because anyways the array specifies // all records, so, might as well just Ling it directly from the "store". // But this is a good stress test for the Query IEnumerator. var qry = from a in store.Query(array) select a; int index = 0; foreach (var itm in qry) { Assert.IsTrue(itm.Key == index++); } } }
public void Run() { Console.WriteLine("{0}: ObjectDirectoryLINQ demo started...", DateTime.Now); // create Server (open the data file) and begin a transaction... using (var Server = new ObjectServer("SopBin\\OServer.dta", commitOnDispose: true)) { // get a Store with string as key and object as value, for saving these object types: // Person, Address, Department, PersonBlob. var Store = Server.StoreNavigator.GetStore <string, object>("SystemFile/People"); if (Store.Count == 0) { Populate(Store); } else { Console.WriteLine("Processing {0} records", Store.Count); var result2 = from a in Store where (a.Key.StartsWith("Person")) select new { key = a.Key }; foreach (var r in result2) { Console.WriteLine("LINQ found entity {0}.", r); } //ReadAll(ref Store); } // no need to commit as "commitOnDispose" is set to true. //Server.Commit(); } // when Server goes out of scope, it will auto commit or rollback (default) a pending transaction. Console.WriteLine("{0}: ObjectDirectoryLINQ demo ended...", DateTime.Now); }
/// <summary> /// Sample code for managing "high volume (5,000,000: 2.5 mil people & 2.5 mil people names)" /// in a very decent amount of time... Inserts: around 20 minutes on a fairly equipped 2 yr old laptop. /// </summary> public void Run() { Console.WriteLine("{0}: PeopleDirectoryLargeDB demo started...", DateTime.Now); // create Server (open the data file) and begin a transaction... using (var Server = new ObjectServer("SopBin\\OServer.dta", true)) { IStoreFactory sf = new StoreFactory(); PeopleStore = sf.Get <long, Person>(Server.SystemFile.Store, "People"); PeopleStoreByName = sf.Get <PersonKey, long>(Server.SystemFile.Store, "PeopleByName", new PersonComparer()); if (PeopleStore.Count == 0) { Populate(Server); } else { Console.WriteLine("Processing {0} records", PeopleStore.Count * 2); ReadAll(); } Server.Commit(); } Console.WriteLine("{0}: PeopleDirectoryLargeDB demo ended...", DateTime.Now); }
/// <summary> /// Disposes the data store, and if specified, also closes the data store and clears it from state. /// </summary> public void Dispose(bool fullDisposal) { if (fullDisposal) { // If the container is initialized if (IsContainerInitialized) { // Roll back to the last commit // This roll back is important. The data store must not commit the latest data unless commit call is explicit. // If rollback is not called then the latest data will be automatically committed // The ability to dispose without committing is necessary for unit testing, transactions, etc. ObjectContainer.Rollback(); // TODO: Add a property to specify whether or not to automatically roll back // Dispose the container ObjectContainer.Dispose(); } // Dispose the server if (IsServerInitialized) { ObjectServer.Close(); // ObjectServer must be closed to unlock files. ObjectServer.Dispose(); ObjectServer = null; } StateAccess.State.SetApplication(ObjectContainerKey, null); StateAccess.State.SetApplication(ObjectServerKey, null); } }
/// <summary> /// Initialize this File /// </summary> /// <param name="server"></param> /// <param name="name">Name of the File Object</param> /// <param name="filename"></param> /// <param name="accessMode"></param> /// <param name="profile"></param> public void Initialize(ObjectServer server, string name, string filename, AccessMode accessMode, Profile profile) { this.Server = server; if (profile != null) { this._profile = profile; } else if (server != null && server.Profile != null) { this._profile = new Profile(server.Profile); } this.Name = name; if (string.IsNullOrEmpty(filename)) { filename = string.Format("{0}{1}.{2}", server.Path, name, ObjectServer.DefaultFileExtension); } this.Filename = filename; this.AccessMode = accessMode; var fi = new FileInfo(filename); if (!System.IO.Directory.Exists(fi.DirectoryName)) { System.IO.Directory.CreateDirectory(fi.DirectoryName); } }
/// <summary> /// Sample code for managing People and their Addresses /// </summary> public void Run() { Console.WriteLine("{0}: PeopleDirectory demo started...", DateTime.Now); string filename = null; // create Server (open the data file) and begin a transaction... using (var Server = new ObjectServer("SopBin\\OServer.dta", true)) { filename = Server.Filename; IStoreFactory sf = new StoreFactory(); for (int i = 0; i < 10; i++) { ISortedDictionary <long, Person> PeopleStore; PeopleStore = sf.Get <long, Person>(Server.SystemFile.Store, string.Format("People{0}", i)); Populate(Server, PeopleStore, 21308, 0); } // when code reaches here, 'no exception happened, 'just commit the transaction. Server.CycleTransaction(); } // if error occurred, transaction will be rolled back automatically. // create Server (open the data file) and begin a transaction... using (var Server = new ObjectServer("SopBin\\OServer.dta", true)) { IStoreFactory sf = new StoreFactory(); for (int i = 0; i < 10; i++) { ISortedDictionary <long, Person> PeopleStore; PeopleStore = sf.Get <long, Person>(Server.SystemFile.Store, string.Format("People{0}", i)); Populate(Server, PeopleStore, 21308 + 30002, 21308); } // when code reaches here, 'no exception happened, 'just commit the transaction. Server.CycleTransaction(); } // if error occurred, transaction will be rolled back automatically. Console.WriteLine("{0}: PeopleDirectory demo ended...", DateTime.Now); }
public void TestEnumeratorDispose() { using (var Server = new ObjectServer("SopBin\\OServer.dta")) { IStoreFactory sf = new StoreFactory(); var store = sf.Get <long, int>(Server, "People"); store.Add(123, 123); int ctr = 0; foreach (var kv in store) { ctr++; } Assert.IsTrue(ctr == store.Count); ctr = 0; foreach (var kv in store) { ctr++; } Assert.IsTrue(ctr == store.Count); store.MoveFirst(); ctr = 0; for (int i = 0; i < store.Count; i++) { var ky = store.CurrentKey; ctr++; store.MoveNext(); } Assert.IsTrue(ctr == store.Count); } }
public void RemoveItemNoCommitTest() { ObjectServer server = ObjectServer.OpenWithTransaction("c:\\SopBin\\OServer.dta"); var df = new StoreFactory(); int ItemCount = 5000; string s = string.Format("Collection{0}", 0); var sortDict = df.Get <int, int>(server.SystemFile.Store, s, isDataInKeySegment: false); int loopCount = 25; for (int i = 0; i < loopCount; i++) { for (int i2 = 0; i2 < ItemCount; i2++) { sortDict.Add(i2, i2); } for (int i2 = 0; i2 < 500; i2++) { sortDict.Remove(i2); } } //for (int i = 0; i < loopCount; i++) //{ // //for (int i2 = 0; i2 < ItemCount; i2++) // // Assert.AreEqual(i2, sortDict[i2]); // for (int i2 = 0; i2 < 500; i2++) // sortDict.Remove(i2); //} //sortDict.Dispose(); server.Commit(); }
/// <summary> /// Sample code for managing People and their Addresses /// </summary> public void Run() { Console.WriteLine("{0}: PeopleDirectory demo started...", DateTime.Now); // create Server (open the data file) and begin a transaction... using (var Server = new ObjectServer("SopBin\\OServer.dta", true)) { IStoreFactory sf = new StoreFactory(); PeopleStore = sf.Get <long, Person>(Server.SystemFile.Store, "People"); PeopleStoreByName = sf.Get <PersonKey, long>(Server.SystemFile.Store, "PeopleByName", new PersonComparer()); string AddressFilename = "oFile2"; Sop.IFile f = Server.GetFile(AddressFilename); if (f == null) { f = Server.FileSet.Add(AddressFilename); } AddressStore = sf.Get <long, Address>(f.Store, "Addresses"); AddressStoreByAddress = sf.Get <AddressKey, long>(f.Store, "AddressesByAddress", new AddressComparer()); if (PeopleStore.Count == 0) { Populate(); } else { Console.WriteLine("Processing {0} records", PeopleStore.Count * 4); ReadAll(); } // when code reaches here, 'no exception happened, 'just commit the transaction. Server.Commit(); } // if error occurred, transaction will be rolled back automatically. Console.WriteLine("{0}: PeopleDirectory demo ended...", DateTime.Now); }
/// <summary> /// Manage 250K records with Blobs (7,000 byte sized array). /// </summary> public void Run() { Console.WriteLine("{0}: PeopleDirectoryXmlSer demo started...", DateTime.Now); // create Server (open the data file) and begin a transaction... using (var Server = new ObjectServer(ServerFilename)) { var PeopleStore = Server.StoreNavigator.GetStore <object, object>("SystemFile/People", new StoreParameters <object> { StoreKeyComparer = new PersonComparer(), AutoFlush = true }); if (PeopleStore.Count == 0) { Populate(PeopleStore); } else { Console.WriteLine("Processing {0} records", PeopleStore.Count); ReadAll(ref PeopleStore); } // Commit the transaction explicitly. NOTE: pls. see the ObjectServer ctor "commitOnDispose" parameter. // Transaction finalization can be automatically handled as needed. Default is to rollback on ObjectServer dispose. Server.Commit(); } // when Server goes out of scope, it will auto commit or rollback (default) a pending transaction. Console.WriteLine("{0}: PeopleDirectoryXmlSer demo ended...", DateTime.Now); }
public void Run() { Console.WriteLine("Start One Hundred Million Inserts demo."); var time1 = DateTime.Now; using (var Server = new ObjectServer(ServerFilename, true, new Preferences { StoreSegmentSizeInKb = 1024 * 15, MemoryLimitInPercent = 75, MaxStoreCount = 1, BTreeSlotLength = 500, IsDataInKeySegment = true })) // set store segment size to 5MB & RAM utilization up to 70%. { // Pre-populate store to simulate production store with existing items. if (Insert) { AddItems(Server); Console.WriteLine("Insertion of {0} key/value pairs took {1} mins.", ItemCount, DateTime.Now.Subtract(time1).TotalMinutes); } else { ReadItems(Server); } Console.WriteLine("End of One Hundred Million Inserts demo."); } }
public void Run() { Console.WriteLine("{0}: ObjectDirectory demo started...", DateTime.Now); // create Server (open the data file) and begin a transaction... using (var Server = new ObjectServer("SopBin\\OServer.dta")) { // get a Store with string as key and object as value, for saving these object types: // Person, Address, Department, PersonBlob. var Store = Server.StoreNavigator.GetStore <string, object>("SystemFile/People", // specify data Values to get stored in data segment as we're intending to save // XML serialized different types of Objects where data can be somewhat bigger than usual. // Use Key segment if data Values are somewhat small in size. new StoreParameters <string> { IsDataInKeySegment = false }); if (Store.Count == 0) { Populate(Store); } else { Console.WriteLine("Processing {0} records", Store.Count); ReadAll(ref Store); } // Commit the transaction explicitly. NOTE: pls. see the ObjectServer ctor "commitOnDispose" parameter. // Transaction finalization can be automatically handled as needed. Default is to rollback on ObjectServer dispose. Server.Commit(); } // when Server goes out of scope, it will auto commit or rollback (default) a pending transaction. Console.WriteLine("{0}: ObjectDirectory demo ended...", DateTime.Now); }
/// <summary> /// Constructor /// </summary> /// <param name="server"></param> /// <param name="name"> </param> /// <param name="filename"></param> /// <param name="accessMode"></param> /// <param name="profile"></param> public File(ObjectServer server, string name = null, string filename = null, AccessMode accessMode = AccessMode.ReadWrite, Profile profile = null) { Initialize(server, name, filename, accessMode, profile); }
static void Main(string[] args) { var server = new ObjectServer(); server.Start(2617); System.Threading.Thread.CurrentThread.Join(); }
/// <summary> /// Constructor expecting File parameter /// </summary> /// <param name="f"></param> public FileSet(IFile f) { bool b = f.Profile.IsDataInKeySegment; f.Profile.IsDataInKeySegment = true; Btree = f.Transaction != null ? ((Transaction.TransactionBase)f.Transaction.GetOuterChild()).CreateCollection(f) : ObjectServer.CreateDictionaryOnDisk(f); f.Profile.IsDataInKeySegment = b; }
/// <summary> /// Sample code to show how to create nested Sorted Dictionaries. /// I.e. - Collections within Collection scenario. /// </summary> public void Run() { Console.WriteLine("{0}: NestedSortedDictionary demo started...", DateTime.Now); const int CollCount = 50; using (var Server = new ObjectServer("SopBin\\OServer.dta")) { bool readStore = false; for (int i = 0; i < CollCount; i++) { string CollectionName = string.Format("SystemFile/People{0}", i); var store = Server.StoreNavigator.GetStore <long, Person>(CollectionName); if (store.Count == 0) { Populate(store); Server.CycleTransaction(); } else { readStore = true; } if (i >= 10) { //** get the table 5 tables "ago" store = Server.StoreNavigator.GetStore <long, Person>(string.Format("SystemFile/People{0}", i - 5)); //** delete the table retrieved... //store.Clear(); store.Rename("foo"); var fooStore = Server.StoreNavigator.GetStore <long, Person>("SystemFile/foo"); //store.Delete(); } Server.CycleTransaction(); } if (readStore) { for (int i = 0; i < CollCount; i++) { string CollectionName = string.Format("SystemFile/People{0}", i); var store = Server.StoreNavigator.GetStore <long, Person>(CollectionName, new StoreParameters <long> { CreateStoreIfNotExist = false }); if (store != null) { ReadAll(store); } else { Console.WriteLine("Warning: Store {0} not found!", CollectionName); } } } } Console.WriteLine("{0}: NestedSortedDictionary demo ended...", DateTime.Now); }
public override void Run() { _objectServer = new ObjectServer<int>(); _consumerGuid = _objectServer.RegisterConsumer(); _producerGuid = _objectServer.RegisterProducer(); _objectServer.UnregisterProducer(_producerGuid); }
/// <summary> /// Shows how to use two Object Servers with separate transaction for each. /// </summary> public static void Run() { string CacheFilename = "OFile.dta"; //** ObjectServer1 is to be physically stored in ...\Sop1 folder string ServerPath1 = "SopBin\\Sop1\\"; //** ObjectServer2 is to be physically stored in ...\Sop2 folder string ServerPath2 = "SopBin\\Sop2\\"; string ServerFilename = "OServer.dta"; //** create 1st ObjectServer & its transaction ObjectServer server = Sop.ObjectServer.OpenWithTransaction(string.Format("{0}{1}", ServerPath1, ServerFilename), new Preferences()); //** create 2nd ObjectServer & its transaction string ServerFilename2 = "OServer2.dta"; string sfullpath2 = string.Format("{0}{1}", ServerPath2, ServerFilename2); ObjectServer server2 = Sop.ObjectServer.OpenWithTransaction(sfullpath2); string fn = string.Format("{0}{1}{2}", ServerPath1, 1, CacheFilename); string fn2 = string.Format("{0}{1}{2}", ServerPath2, 2, CacheFilename); Sop.IFile f = server.FileSet[CacheFilename]; if (f == null) { f = server.FileSet.Add(CacheFilename, fn); } IStoreFactory sf = new StoreFactory(); ISortedDictionary <int, Person> store = sf.Get <int, Person>(f.Store, "VirtualCache"); Sop.IFile f2 = server2.FileSet[CacheFilename]; if (f2 == null) { f2 = server2.FileSet.Add(CacheFilename, fn2); } ISortedDictionary <int, Person> store2 = sf.Get <int, Person>(f2.Store, "VirtualCache"); //** insert records Console.WriteLine("Start Insertion then Validation of records & their sequence..."); object o = store.Transaction; object o2 = store2.Transaction; InsertRecords(store, 20003, "Store1"); ReadRecords(store, 20003, "Store1"); store.Transaction.Rollback(); InsertRecords(store2, 20501, "Store2"); ReadRecords(store2, 20501, "Store2"); store2.Transaction.Rollback(); Console.WriteLine("Done..."); }
/// <summary> /// Closes the data store. /// </summary> public override void Close() { if (IsContainerInitialized) { ObjectContainer.Close(); ObjectContainer = null; } if (IsServerInitialized) { ObjectServer.Close(); ObjectServer = null; } }
void ReadAll(ObjectServer server, ISortedDictionary <long, Person> PeopleStore, int maxCount ) { for (int i = 0; i < maxCount; i++) { var v = PeopleStore.CurrentValue; if (!PeopleStore.MoveNext()) { break; } } }
void Populate(ObjectServer server, ISortedDictionary <long, Person> PeopleStore, int maxCount, int seed ) { int ZipCodeCtr = 5000; for (int i = seed; i < maxCount; i++) { if (i == maxCount - 2) { object o = 90; } int aid = i; Address addr = new Address() { AddressID = aid, Key = new AddressKey() { Street = string.Format("143{0} LoveLane", aid), City = "Fremont", Country = "USA", State = "California", ZipCode = ZipCodeCtr.ToString() } }; int pid = (int)PeopleStore.GetNextSequence(); Person p = new Person() { PersonID = pid, AddressID = addr.AddressID, Key = new PersonKey() { FirstName = string.Format("Joe{0}", pid), LastName = string.Format("Peter{0}", pid) }, PhoneNumber = "510-555-9999" }; PeopleStore.Add(p.PersonID, p); if (i % 5000 == 0) { ZipCodeCtr++; PeopleStore.Flush(); } } }
/// <summary> /// DeSerialize /// </summary> /// <param name="parent"></param> /// <param name="reader"></param> public void Unpack(IInternalPersistent parent, System.IO.BinaryReader reader) { if (Btree == null) { if (((CollectionOnDisk)parent).Transaction != null) { Btree = ((Transaction.TransactionBase)((CollectionOnDisk)parent).Transaction).CreateCollection ( ((CollectionOnDisk)parent).File); } else { Btree = ObjectServer.CreateDictionaryOnDisk(((CollectionOnDisk)parent).File); } } Locker.Invoke(() => { Btree.Unpack(parent, reader); }); }
public void LargeNumberOfStoresStressTest() { using (ObjectServer server = ObjectServer.OpenWithTransaction("c:\\SopBin\\OServer.dta")) { var sf = new StoreFactory(); // create/open 350! stores or tables... const int ItemCount = 350; int StoreItemCount = 0; for (int i = 0; i < ItemCount; i++) { string s = string.Format("Collection{0}", i); var sortDict = sf.Get <int, int>(server.SystemFile.Store, s); if (StoreItemCount == 0) { StoreItemCount = sortDict.Count; } else if (sortDict.Count != StoreItemCount) { Assert.Fail(string.Format("sortDict.Count {0}, expected {1}", sortDict.Count, StoreItemCount)); } for (int i2 = 0; i2 < 50; i2++) { sortDict.Add(i2, i2 + i); } } StoreItemCount = 0; for (int i = 0; i < ItemCount; i++) { string s = string.Format("Collection{0}", i); var sortDict = sf.Get <int, int>(server.SystemFile.Store, s, createIfNotExist: false); if (StoreItemCount == 0) { StoreItemCount = sortDict.Count; } else if (sortDict.Count != StoreItemCount) { Assert.Fail(string.Format("sortDict.Count {0}, expected {1}", sortDict.Count, StoreItemCount)); } for (int i2 = 0; i2 < 10; i2++) { sortDict.Remove(i2); } } server.Commit(); } }
public void ListAllStoresAndEnumeratorTests() { using (ObjectServer server = ObjectServer.OpenWithTransaction("c:\\SopBin\\OServer.dta")) { // set TrackStoreTypes true because it is false by default for MinimalDevice profile scheme (default scheme). server.Profile.TrackStoreTypes = true; if (server.StoreTypes != null) { foreach (var de in server.StoreTypes) { Console.WriteLine("Store UNC Name: {0}, info: {1}", de.Key, de.Value); } } bool fooBarFound = false; server.StoreTypes.Add("foo", "bar"); foreach (var de in server.StoreTypes) { if (de.Key == "foo") { fooBarFound = true; } Console.WriteLine("Store UNC Name: {0}, info: {1}", de.Key, de.Value); } Assert.AreEqual(fooBarFound, true); server.StoreTypes.Add("foo2", "bar2"); fooBarFound = false; bool foo2Found = false; foreach (var de in server.StoreTypes) { if (de.Key == "foo2") { foo2Found = true; } if (de.Key == "foo") { fooBarFound = true; } Console.WriteLine("Store UNC Name: {0}, info: {1}", de.Key, de.Value); } Assert.AreEqual(foo2Found, true); Assert.AreEqual(fooBarFound, true); } // NOTE: intentionally left transaction uncommitted to see rollback to work... }
public void QueryUniqueRecordsTest() { using (var Server = new ObjectServer("SopBin\\OServer.dta")) { IStoreFactory sf = new StoreFactory(); var storeB = sf.Get <int, string>(Server, "People2"); storeB.Add(1, "11"); storeB.Add(2, "221"); storeB.Add(3, "331"); storeB.Add(4, "44"); var qry = from a in storeB.Query(new int[] { 1, 2, 3, 4, 5 }) select a; foreach (var itm in qry) { Assert.IsTrue(itm.Key == 1 || itm.Key == 2 || itm.Key == 3 || itm.Key == 4); } } }
public override void Start(int port) { base.Start(port); //Start our Object Server Websocket. ObjectServer.Start("http://localhost:2620/"); try { ServerContext.Running = true; UpdateServer(); } catch (ThreadAbortException ex) { ServerContext.Logger(ex.Message, Microsoft.Extensions.Logging.LogLevel.Error); ServerContext.Logger(ex.StackTrace, Microsoft.Extensions.Logging.LogLevel.Error); ServerContext.Running = false; } }
public void SimpleLinqTest() { using (var Server = new ObjectServer("SopBin\\OServer.dta")) { IStoreFactory sf = new StoreFactory(); var store = sf.Get <int, string>(Server, "People2"); store.Add(3, "331"); store.Add(2, "221"); store.Add(1, "11"); store.Add(4, "44"); var qry = from a in store select a; int i = 1; foreach (var itm in qry) { Assert.IsTrue(itm.Key == i++); } } }
protected internal override void Update(TimeSpan elapsedTime) { if (Timer.Update(elapsedTime)) { lock (Server.Clients) { foreach (var client in Server.Clients.Where(client => client != null && client.Aisling != null)) { client.Send(new ServerFormat3B()); client.LastPing = DateTime.UtcNow; } } ObjectServer.Broadcast($"[System]: Server Up Time: {DateTime.UtcNow - ServerContext.TimeServerStarted}"); ObjectServer.Broadcast($"[System]: Connected Players: {GetObjects<Aisling>(null, n => n.LoggedIn).Count()}"); ObjectServer.Broadcast($"[System]: Game Objects: {GetObjects(null, n => n != null, Get.All).Count()}"); ObjectServer.Broadcast($"[System]: Active Maps: {string.Join(", ", GetObjects<Aisling>(null, n => n != null && (n.Map != null && n.Map.ActiveMap != null)).Select(n => n?.Map.ActiveMap).GroupBy(n => n).Select(o => o.Key).ToArray())}"); } }
static void Main(string[] args) { try { ObjectServer <Animals> objectServer = new ObjectServer <Animals>(16059, 16, true); objectServer.Init(); while (true) { Animals animals = new Animals(); animals.name = "dog"; animals.height = 100; animals.sex = true; objectServer.SendObjectToAll(animals); Thread.Sleep(1500); } } catch (Exception e) { Console.WriteLine(e.Message); } }
public ReaModel() { this.PropertyChanged += ReaModel_PropertyChanged; _objectServer = new ObjectServer<Movement>(); _thresholdControls = new BindingList<ThresholdControl>(); _movementMetadata = new MovementMetadata(); }