diff options
Diffstat (limited to 'OpenSim.Servers/OpenGridProtocol.cs')
-rw-r--r-- | OpenSim.Servers/OpenGridProtocol.cs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/OpenSim.Servers/OpenGridProtocol.cs b/OpenSim.Servers/OpenGridProtocol.cs new file mode 100644 index 0000000..8c91b9a --- /dev/null +++ b/OpenSim.Servers/OpenGridProtocol.cs | |||
@@ -0,0 +1,74 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Net; | ||
4 | using System.Net.Sockets; | ||
5 | using System.Text; | ||
6 | using System.Text.RegularExpressions; | ||
7 | using System.Threading; | ||
8 | using Nwc.XmlRpc; | ||
9 | using System.Collections; | ||
10 | |||
11 | namespace OpenSim.Servers | ||
12 | { | ||
13 | public class OpenGridProtocolServer | ||
14 | { | ||
15 | |||
16 | private Thread m_workerThread; | ||
17 | private TcpListener m_tcpListener; | ||
18 | private int m_port; | ||
19 | private ArrayList m_clients; | ||
20 | |||
21 | private class ClientHandler { | ||
22 | private Thread m_clientThread; | ||
23 | private TcpClient m_socketHandle; | ||
24 | |||
25 | public ClientHandler(TcpClient clientSocketHandle) { | ||
26 | m_socketHandle=clientSocketHandle; | ||
27 | m_clientThread = new Thread(new ThreadStart(DoWork)); | ||
28 | m_clientThread.IsBackground = true; | ||
29 | m_clientThread.Start(); | ||
30 | } | ||
31 | |||
32 | private void DoWork() { | ||
33 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenGridProtocol.cs: ClientHandler.DoWork() - Got new client"); | ||
34 | } | ||
35 | } | ||
36 | |||
37 | public OpenGridProtocolServer(int port) | ||
38 | { | ||
39 | m_port = port; | ||
40 | } | ||
41 | |||
42 | public void Start() | ||
43 | { | ||
44 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenGridProtocol.cs: Start() - Opening server socket"); | ||
45 | |||
46 | m_workerThread = new Thread(new ThreadStart(StartServerSocket)); | ||
47 | m_workerThread.IsBackground = true; | ||
48 | m_workerThread.Start(); | ||
49 | } | ||
50 | |||
51 | private void StartServerSocket() | ||
52 | { | ||
53 | try | ||
54 | { | ||
55 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("OpenGridProtocol.cs: StartServerSocket() - Spawned main thread OK"); | ||
56 | |||
57 | |||
58 | m_tcpListener = new TcpListener(m_port); | ||
59 | m_tcpListener.Start(); | ||
60 | |||
61 | TcpClient sockethandle; | ||
62 | while (true) | ||
63 | { | ||
64 | sockethandle = m_tcpListener.AcceptTcpClient(); | ||
65 | m_clients.Add(new OpenGridProtocolServer.ClientHandler(sockethandle)); | ||
66 | } | ||
67 | } | ||
68 | catch (Exception e) | ||
69 | { | ||
70 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.Message); | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 | } | ||