changeset 70:0f4fa15e5bcb

add new example
author riono <e165729@ie.u-ryukyu.ac.jp>
date Fri, 04 Feb 2022 19:38:19 +0900
parents 959096e8786b
children 1169915705ab
files Test/Example/CountUp/CountObject.cs Test/Example/CountUp/CountUpper.cs Test/Example/CountUp/StartCountUp.cs datagear/command/PutCommand.cs
diffstat 4 files changed, 50 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Test/Example/CountUp/CountObject.cs	Fri Feb 04 19:38:19 2022 +0900
@@ -0,0 +1,12 @@
+using MessagePack;
+
+namespace Christie_net.Test.Example.CountUp {
+[MessagePackObject]
+public class CountObject {
+    public int number;
+
+    public CountObject(int number) {
+        this.number = number;
+    }
+}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Test/Example/CountUp/CountUpper.cs	Fri Feb 04 19:38:19 2022 +0900
@@ -0,0 +1,20 @@
+using System;
+using Christie_net.annotation;
+using Christie_net.codegear;
+
+namespace Christie_net.Test.Example.CountUp {
+public class CountUpper : CodeGear {
+    [Take] public CountObject count;
+    public override void Run(CodeGearManager cgm) {
+        Console.WriteLine(count.number);
+
+        if (count.number < 10) {
+            cgm.Setup(new CountUpper());
+            count.number += 1;
+            Put("count", count);
+        } else {
+            cgm.GetLocalDGM().Finish();
+        }
+    }
+}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Test/Example/CountUp/StartCountUp.cs	Fri Feb 04 19:38:19 2022 +0900
@@ -0,0 +1,17 @@
+using Christie_net.codegear;
+
+namespace Christie_net.Test.Example.CountUp {
+public class StartCountUp : StartCodeGear {
+    public StartCountUp(CodeGearManager cgm) : base(cgm) { }
+
+    public static void Main(string[] args) {
+        StartCountUp start = new StartCountUp(CreateCgm(10001));
+    }
+    
+    public override void Run(CodeGearManager cgm) {
+        cgm.Setup(new CountUpper());
+        CountObject count = new CountObject(1);
+        Put("count", count);
+    }
+}
+}
\ No newline at end of file
--- a/datagear/command/PutCommand.cs	Wed Feb 02 16:39:38 2022 +0900
+++ b/datagear/command/PutCommand.cs	Fri Feb 04 19:38:19 2022 +0900
@@ -29,7 +29,7 @@
 
             byte[] data = new MessagePackDataGear<object>(dg.GetData()).GetMessagePack();
             byte[] datasize = MessagePackSerializer.Serialize(data.Length);
-            
+
             if (datasize.Length < 5) {
                 byte[] newDatasize = new byte[5];
                 Array.Copy(datasize, newDatasize, datasize.Length);