changeset 10:5f726dc31874

add Connection class
author riono <e165729@ie.u-ryukyu.ac.jp>
date Tue, 17 Nov 2020 19:34:44 +0900
parents ce6906edcbf4
children 1f7d4f168b89
files daemon/Connection.cs datagear/command/CommandType.cs
diffstat 2 files changed, 44 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/daemon/Connection.cs	Tue Nov 17 19:34:44 2020 +0900
@@ -0,0 +1,43 @@
+using System;
+using System.Collections.Concurrent;
+using System.IO;
+using System.Net.Sockets;
+using Christie_net.datagear.command;
+
+namespace Christie_net.daemon {
+public class Connection {
+    public Socket socket;
+    public string name;
+    public CodeGearManager cgm;
+    public ConcurrentQueue<Command> sendQueue = new ConcurrentQueue<Command>();
+    public bool sendManager = true;
+    private object syncObject = new object();
+    
+    public Connection(Socket socket, CodeGearManager cgm) {
+        this.socket = socket;
+        this.cgm = cgm;
+    }
+    
+    public Connection(){}
+
+    public void SendCommand(Command cmd) {
+        sendQueue.Enqueue(cmd);
+    }
+
+    public string GetInfoString() {
+        return socket.
+    }
+
+    public void Close() {
+        socket
+    }
+
+    public void Write(Command cmd) {
+        MemoryStream stream = cmd.Convert();
+
+        while (stream.) {
+            
+        }
+    }
+}
+}
\ No newline at end of file
--- a/datagear/command/CommandType.cs	Tue Nov 17 18:46:22 2020 +0900
+++ b/datagear/command/CommandType.cs	Tue Nov 17 19:34:44 2020 +0900
@@ -13,6 +13,7 @@
     FINISH
 }
 
+// C#ではenumに関数は生やせないためヘルパークラスを実装
 public class CommandTypeEtx {
     public CommandType commandType;
     public int id; // command ID