public DistributedResourceQueueItem(DistributedResource resource, DistributedResourceQueueItemType type, object value, byte index) { this.resource = resource; this.index = index; this.type = type; this.value = value; }
static void TestObjectProps(IResource local, DistributedResource remote) { foreach (var pt in local.Instance.Template.Properties) { var lv = pt.PropertyInfo.GetValue(local); object v; var rv = remote.TryGetPropertyValue(pt.Index, out v); if (!rv) { Console.WriteLine($" ** {pt.Name } Failed"); } else { Console.WriteLine($"{pt.Name } {GetString(lv)} == {GetString(v)}"); } } }
private static void TestClient() { //return; // Create a new client var client = new DistributedConnection(new TCPSocket("localhost", 5000), "localhost", "demo", "1234"); // Put the client in our memory store var remote = Warehouse.GetStore("remote"); Warehouse.Put(client, "Endpoint", remote); client.OnReady += async(c) => { // Get remote object from the server. remoteObject = await client.Get("db/my").Task as DistributedResource; dynamic x = remoteObject; Console.WriteLine("My Name is: " + x.Name); x.Name = "Hamoo"; x.LevelUp += new DistributedResourceEvent((sender, parameters) => { Console.WriteLine("LevelUp " + parameters[0] + " " + parameters[1]); }); x.LevelDown += new DistributedResourceEvent((sender, parameters) => { Console.WriteLine("LevelUp " + parameters[0] + " " + parameters[1]); }); (x.Stream(10) as AsyncReply).Then(r => { Console.WriteLine("Stream ended: " + r); }).Chunk(r => { Console.WriteLine("Chunk..." + r); }).Progress((t, v, m) => Console.WriteLine("Processing {0}/{1}", v, m)); var rt = await x.Subtract(10).Task; //var rt2 = await x.Add(10).Task; Console.WriteLine(rt); /* * (x.Subtract(10) as AsyncReply).Then((r) => * { * Console.WriteLine("Subtracted: " + r + " " + x.Level); * }).Error((ex) => * { * Console.WriteLine("Exception " + ex.Code + " " + ex.Message); * }); * * // Getting object record * client.GetRecord(remoteObject, DateTime.Now - TimeSpan.FromDays(1), DateTime.Now).Then(record => * { * Console.WriteLine("Records received: " + record.Count); * }); * * var t = new Timer(T_Elapsed, null, 5000, 5000); */ }; }