Mercurial > hg > Database > Christie-sharp
changeset 24:58858657a0e0
fix PutCommand
author | riono <e165729@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 15 Dec 2020 22:30:06 +0900 |
parents | 46cfeb0609c5 |
children | 52cb63c37218 |
files | daemon/IncomingTcpConnection.cs datagear/command/PutCommand.cs |
diffstat | 2 files changed, 10 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/daemon/IncomingTcpConnection.cs Tue Dec 15 22:11:40 2020 +0900 +++ b/daemon/IncomingTcpConnection.cs Tue Dec 15 22:30:06 2020 +0900 @@ -25,20 +25,20 @@ } public void Run() { - byte[] deserializeData = null; + byte[] deserializeCommand = new byte[4096]; while (true) { try { - // データはType, length, dataの順で入っているっぽい - connection.socket.Receive(deserializeData); - RemoteMessage msg = MessagePackSerializer.Deserialize<RemoteMessage>(deserializeData); + // データはRemotemessage(Command), length, dataの順で入っている + connection.socket.Receive(deserializeCommand); + RemoteMessage msg = MessagePackSerializer.Deserialize<RemoteMessage>(deserializeCommand); CommandType type = CommandTypeExt.GetCommandTypeFormId(msg.type); byte[] data; switch (type) { case CommandType.PUT: - data = new byte[MessagePackSerializer.Deserialize<int>(deserializeData)]; + data = new byte[MessagePackSerializer.Deserialize<int>(deserializeCommand)]; connection.socket.Receive(data); try { @@ -63,7 +63,7 @@ break; case CommandType.REPLY: // 待っていたwaitlistに渡してcsにセット - data = new byte[MessagePackSerializer.Deserialize<int>(deserializeData)]; + data = new byte[MessagePackSerializer.Deserialize<int>(deserializeCommand)]; connection.socket.Receive(data); try {
--- a/datagear/command/PutCommand.cs Tue Dec 15 22:11:40 2020 +0900 +++ b/datagear/command/PutCommand.cs Tue Dec 15 22:30:06 2020 +0900 @@ -21,9 +21,10 @@ byte[] data = new MessagePackDataGear<object>(dg.GetData()).GetMessagePack(); byte[] dataSize = MessagePackSerializer.Serialize(data.Length); - stream.Write(command, 0, command.Length); - stream.Write(data, 0, data.Length); - stream.Write(dataSize, 0, dataSize.Length); + stream.Write(command); + stream.Write(dataSize); + stream.Write(data); + stream.Position = 0; } catch (IOException e) { Console.WriteLine(e.StackTrace);