# HG changeset patch # User riono # Date 1638268464 -32400 # Node ID 98ee1ee1efb702eda2b8bbf7570702198f20f24b # Parent 132f56edd10cdda061b440602c42d35989e96190 error message is change diff -r 132f56edd10c -r 98ee1ee1efb7 Christie_net.csproj --- a/Christie_net.csproj Tue Sep 21 18:53:34 2021 +0900 +++ b/Christie_net.csproj Tue Nov 30 19:34:24 2021 +0900 @@ -3,7 +3,7 @@ Exe netcoreapp3.1 - Christie_net.Test.Example.RemoteTake.StartRemoteTake + Christie_net.Test.Example.FizzBuzz.StartFizzBuzz diff -r 132f56edd10c -r 98ee1ee1efb7 Test/Example/FizzBuzz/Counter.cs --- a/Test/Example/FizzBuzz/Counter.cs Tue Sep 21 18:53:34 2021 +0900 +++ b/Test/Example/FizzBuzz/Counter.cs Tue Nov 30 19:34:24 2021 +0900 @@ -7,9 +7,11 @@ [Take] private int num; public override void Run(CodeGearManager cgm) { + Console.WriteLine("call"); if (num <= 100) { GetDgm("FizzBuzz").Put("num", num); cgm.GetLocalDGM().Put("num", num+1); + Console.WriteLine("num;" + num); cgm.Setup(new Counter()); } else { GetDgm("FizzBuzz").Put("num", -1); diff -r 132f56edd10c -r 98ee1ee1efb7 Test/Example/RemoteTake/StartRemoteTake.cs --- a/Test/Example/RemoteTake/StartRemoteTake.cs Tue Sep 21 18:53:34 2021 +0900 +++ b/Test/Example/RemoteTake/StartRemoteTake.cs Tue Nov 30 19:34:24 2021 +0900 @@ -1,3 +1,4 @@ +using System.Threading; using Christie_net.codegear; namespace Christie_net.Test.Example.RemoteTake { @@ -12,6 +13,8 @@ RTCommand cmd = new RTCommand("insert", "line", 0); cgm.GetDGM("remote").Put("command", cmd); + + Thread.Sleep(9999); } } diff -r 132f56edd10c -r 98ee1ee1efb7 Test/RewritingTest/MessagepackTest.cs --- a/Test/RewritingTest/MessagepackTest.cs Tue Sep 21 18:53:34 2021 +0900 +++ b/Test/RewritingTest/MessagepackTest.cs Tue Nov 30 19:34:24 2021 +0900 @@ -1,10 +1,13 @@ using System; +using System.Collections.Generic; +using System.Linq; using Christie_net.datagear; using Christie_net.datagear.dg; +using Christie_net.Test.Example.RemoteTake; using MessagePack; namespace Christie_net { -[MessagePackObject()] +[MessagePackObject] public class MessagepackTest { [Key("key")] @@ -13,26 +16,44 @@ [Key("foo")] public int foo; - [Key("ms")] + [Key("data")] public byte[] data; - public MessagepackTest() { - + public MessagepackTest(string key, int foo, byte[] data) { + this.key = key; + this.foo = foo; + this.data = data; } public static void Main() { - var message = new MessagepackTest(); - message.key = "fuga"; - message.foo = 10; - message.data = MessagePackSerializer.Serialize(100); + RTCommand cmd = new RTCommand("line", "cmd", 12); + + byte[] serializeData = MessagePackSerializer.Serialize(cmd); + var message = new MessagepackTest("fuga", 10, serializeData); + + + byte[] slie = MessagePackSerializer.Serialize(message); + + var desli = MessagePackSerializer.Deserialize(slie); + + Type dataTypes = typeof(RTCommand); + var args = new object[] {"line", "cmd", 12}; - SerializeObj obj = new SerializeObj(); - byte[] slie = obj.SerializeFunc(message); + var deseriData = MessagePackSerializer.Deserialize(desli.data); + + Dictionary test = (Dictionary) deseriData; + List array = new List(); + foreach (var VARIABLE in test) { + array.Add(VARIABLE.Value); + + } - var desli = obj.DeserializeFunc(slie); + object[] convertArray = array.ToArray(); + - MessagepackTest test = (MessagepackTest) desli; - Console.WriteLine("varl;" + test.foo); + var instance = Activator.CreateInstance(dataTypes, convertArray); + + Console.WriteLine("varl;" + instance.GetType()); // byte[] bytes = MessagePackSerializer.Serialize(message); // MessagepackTest mes = MessagePackSerializer.Deserialize(bytes); @@ -41,16 +62,17 @@ // int data = MessagePackSerializer.Deserialize(mes.data); //Console.WriteLine(data); } - } +} + -public class SerializeObj { - - public byte[] SerializeFunc(T data) { - return MessagePackSerializer.Serialize(data); - } - - public object DeserializeFunc(byte[] data) { - return MessagePackSerializer.Deserialize(data); - } -} +// public class SerializeObj { +// +// public byte[] SerializeFunc(T data) { +// return MessagePackSerializer.Serialize(data); +// } +// +// public object DeserializeFunc(byte[] data) { +// return MessagePackSerializer.Deserialize(data); +// } +// } } \ No newline at end of file diff -r 132f56edd10c -r 98ee1ee1efb7 daemon/AcceptThread.cs --- a/daemon/AcceptThread.cs Tue Sep 21 18:53:34 2021 +0900 +++ b/daemon/AcceptThread.cs Tue Nov 30 19:34:24 2021 +0900 @@ -28,6 +28,7 @@ Console.WriteLine("Accept " + hostEntry.HostName + ":" + endPoint.Port); Connection connection = new Connection(client.Client, cgm); + Console.WriteLine("connection:" + connection.GetInfoString()); string key = "accept" + counter; IncomingTcpConnection incoming = new IncomingTcpConnection(connection); diff -r 132f56edd10c -r 98ee1ee1efb7 daemon/Connection.cs --- a/daemon/Connection.cs Tue Sep 21 18:53:34 2021 +0900 +++ b/daemon/Connection.cs Tue Nov 30 19:34:24 2021 +0900 @@ -54,8 +54,8 @@ /// public void Write(Command cmd) { // Debug - RTCommand rtcmd = (RTCommand)cmd.dg.GetData(); - Console.WriteLine("length:" + rtcmd.line); + //RTCommand rtcmd = (RTCommand)cmd.dg.GetData(); + //Console.WriteLine("length:" + rtcmd.line); byte[] buffer = cmd.Convert(); diff -r 132f56edd10c -r 98ee1ee1efb7 daemon/IncomingTcpConnection.cs --- a/daemon/IncomingTcpConnection.cs Tue Sep 21 18:53:34 2021 +0900 +++ b/daemon/IncomingTcpConnection.cs Tue Nov 30 19:34:24 2021 +0900 @@ -64,21 +64,21 @@ data = msg.data; try { - MessagePackDataGear dg = - new MessagePackDataGear(data, Type.GetType(msg.clazz)); + MessagePackDataGear dg = + new MessagePackDataGear(data, Type.GetType(msg.clazz)); // Debug - var ty = Type.GetType(msg.clazz); - var obj = MessagePackSerializer.Deserialize(msg.data); + // var ty = Type.GetType(msg.clazz); + // var obj = MessagePackSerializer.Deserialize(msg.data); - Console.WriteLine("obj type: "+ obj); - Dictionary test = (Dictionary) obj; - foreach (var VARIABLE in test) { - Console.WriteLine("key:" + VARIABLE.Key + " val:" + VARIABLE.Value); - } + //Console.WriteLine("obj type: "+ obj); + //Dictionary test = (Dictionary) obj; + // foreach (var VARIABLE in test) { + // Console.WriteLine("key:" + VARIABLE.Key + " val:" + VARIABLE.Value); + // } //RTCommand cmd = (RTCommand) obj; - Console.WriteLine("***type:" + msg.type + " key:" + msg.key + " fromDgm:" + msg.fromDmgName + " class:" + msg.clazz); + //Console.WriteLine("***type:" + msg.type + " key:" + msg.key + " fromDgm:" + msg.fromDmgName + " class:" + msg.clazz); //Console.WriteLine("data :" + cmd.line); cgm.GetLocalDGM().Put(msg.key, dg); diff -r 132f56edd10c -r 98ee1ee1efb7 datagear/RemoteDataGearManager.cs --- a/datagear/RemoteDataGearManager.cs Tue Sep 21 18:53:34 2021 +0900 +++ b/datagear/RemoteDataGearManager.cs Tue Nov 30 19:34:24 2021 +0900 @@ -73,9 +73,8 @@ } // Debug - Console.WriteLine("connect:" + connection); - RTCommand cmd = (RTCommand) data; - Console.WriteLine("data:" + cmd.command); + Console.WriteLine("connect:" + connection.name); + //Console.WriteLine("data:" + cmd.command); connection.Write(cm); } diff -r 132f56edd10c -r 98ee1ee1efb7 datagear/dg/MessagePackDataGear.cs --- a/datagear/dg/MessagePackDataGear.cs Tue Sep 21 18:53:34 2021 +0900 +++ b/datagear/dg/MessagePackDataGear.cs Tue Nov 30 19:34:24 2021 +0900 @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Christie_net.Test.Example.RemoteTake; using MessagePack; @@ -24,8 +25,8 @@ return messagePack; try { // Debug - Console.WriteLine("data:" + data); - Console.WriteLine(); + // Console.WriteLine("data:" + data); + // Console.WriteLine(); messagePack = MessagePackSerializer.Serialize(data); @@ -42,9 +43,14 @@ if (data == null) try { var dataObj = MessagePackSerializer.Deserialize(messagePack); - var dataCast = Convert.ChangeType(dataObj, clazz); - Console.WriteLine("MSP data: " + dataCast); - SetData(dataObj); + + // Debug + //Console.WriteLine("MSP data: " + clazz); + + var convertData = MessagePackDataFormed(dataObj); + + + SetData(convertData); } catch (Exception e) { Console.WriteLine(e.StackTrace); } @@ -56,5 +62,17 @@ public void SetDataSize(int dataSize) { this.dataSize = dataSize; } + + public T MessagePackDataFormed(dynamic deserializedData) { + Dictionary dataDictionary = (Dictionary) deserializedData; + List valueArray = new List(); + foreach (var VARIABLE in dataDictionary) { + valueArray.Add(VARIABLE.Value); + } + object[] convertArray = valueArray.ToArray(); + + T instance = (T) Activator.CreateInstance(clazz, convertArray); + return instance; + } } } \ No newline at end of file