Mercurial > hg > Database > Christie-sharp
comparison datagear/RemoteDataGearManager.cs @ 26:45ff08d59fda
update CGM
author | riono <e165729@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 12 Jan 2021 21:23:23 +0900 |
parents | datagear/command/RemoteDataGearManager.cs@3aaa77e12493 |
children | efb06874a34e |
comparison
equal
deleted
inserted
replaced
25:52cb63c37218 | 26:45ff08d59fda |
---|---|
1 using System; | |
2 using System.Net; | |
3 using System.Net.Sockets; | |
4 using System.Threading.Tasks; | |
5 using Christie_net.codegear; | |
6 using Christie_net.daemon; | |
7 using Christie_net.datagear.command; | |
8 using Christie_net.datagear.dg; | |
9 | |
10 namespace Christie_net.datagear { | |
11 public class RemoteDataGearManager : DataGearManager { | |
12 private Connection connection; | |
13 private CodeGearManager cgm; | |
14 private bool connect = false; | |
15 private object lockObj = new object(); | |
16 | |
17 public RemoteDataGearManager (string address, int port, CodeGearManager cgm) { | |
18 this.cgm = cgm; | |
19 RemoteDataGearManager manager = this; | |
20 Task.Factory.StartNew(() => { | |
21 do { | |
22 try { | |
23 IPHostEntry host = Dns.GetHostEntry(address); | |
24 IPAddress ipAddress = host.AddressList[0]; | |
25 IPEndPoint remoteEndPoint = new IPEndPoint(ipAddress, port); | |
26 Socket socket = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp); | |
27 socket.Bind(remoteEndPoint); | |
28 socket.Listen((int) SocketOptionName.MaxConnections); | |
29 socket.NoDelay = true; | |
30 | |
31 Socket listener = socket.Accept(); | |
32 connection = new Connection(listener, cgm); | |
33 } catch { } | |
34 } while (!connect); | |
35 | |
36 IncomingTcpConnection incoming = new IncomingTcpConnection(connection); | |
37 incoming.SetManager(manager); | |
38 Task.Factory.StartNew( | |
39 () => incoming.Run(), | |
40 TaskCreationOptions.LongRunning); | |
41 OutboundTcpConnection outbound = new OutboundTcpConnection(connection); | |
42 Task.Factory.StartNew( | |
43 () => outbound.Run(), | |
44 TaskCreationOptions.LongRunning); | |
45 }); | |
46 } | |
47 | |
48 public override void Put(string key, object data) { | |
49 throw new NotImplementedException(); | |
50 } | |
51 | |
52 public override void RunCommand(Command cm) { | |
53 throw new NotImplementedException(); | |
54 } | |
55 | |
56 public override void ResolveWaitCommand(string key, DataGear<Type> dg) { | |
57 throw new NotImplementedException(); | |
58 } | |
59 | |
60 public override void Finish() { | |
61 throw new NotImplementedException(); | |
62 } | |
63 | |
64 public override void Close() { | |
65 throw new NotImplementedException(); | |
66 } | |
67 | |
68 public override void Shutdown() { | |
69 throw new NotImplementedException(); | |
70 } | |
71 } | |
72 } |