aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.Servers/OpenGridProtocol.cs
diff options
context:
space:
mode:
authorgareth2007-04-21 17:36:03 +0000
committergareth2007-04-21 17:36:03 +0000
commit1dfda8f7440122486a51f5353807571160106656 (patch)
tree5f5113a6b9bc765d5c161f61f2d93fdd490fe27b /OpenSim.Servers/OpenGridProtocol.cs
parentPart 1/2: Comments (other part will come later) (diff)
downloadopensim-SC-1dfda8f7440122486a51f5353807571160106656.zip
opensim-SC-1dfda8f7440122486a51f5353807571160106656.tar.gz
opensim-SC-1dfda8f7440122486a51f5353807571160106656.tar.bz2
opensim-SC-1dfda8f7440122486a51f5353807571160106656.tar.xz
Added OpenGridProtocol class - start of the new TCP-based intersim protocol, very basic skeleton
First commit since we lost JesseMalt - Dedicated to their memory
Diffstat (limited to 'OpenSim.Servers/OpenGridProtocol.cs')
-rw-r--r--OpenSim.Servers/OpenGridProtocol.cs74
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 @@
1using System;
2using System.Collections.Generic;
3using System.Net;
4using System.Net.Sockets;
5using System.Text;
6using System.Text.RegularExpressions;
7using System.Threading;
8using Nwc.XmlRpc;
9using System.Collections;
10
11namespace 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}