aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/TRPC
diff options
context:
space:
mode:
authorJeff Ames2008-03-04 04:11:37 +0000
committerJeff Ames2008-03-04 04:11:37 +0000
commitcd6f4a57e7586ffd5c6dae91633e61e293272def (patch)
tree880c9199b13ae75e428c878f5857f9cef886cf73 /OpenSim/Region/ScriptEngine/Common/TRPC
parentthink I finally fixed this hg sync issue (diff)
downloadopensim-SC-cd6f4a57e7586ffd5c6dae91633e61e293272def.zip
opensim-SC-cd6f4a57e7586ffd5c6dae91633e61e293272def.tar.gz
opensim-SC-cd6f4a57e7586ffd5c6dae91633e61e293272def.tar.bz2
opensim-SC-cd6f4a57e7586ffd5c6dae91633e61e293272def.tar.xz
Added copyright heaaders. Minor cleanup.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/TRPC')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/TRPC/TCPClient.cs18
-rw-r--r--OpenSim/Region/ScriptEngine/Common/TRPC/TCPCommon.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Common/TRPC/TCPServer.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Common/TRPC/TCPSocket.cs8
4 files changed, 13 insertions, 29 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/TRPC/TCPClient.cs b/OpenSim/Region/ScriptEngine/Common/TRPC/TCPClient.cs
index 1fd7a25..236b685 100644
--- a/OpenSim/Region/ScriptEngine/Common/TRPC/TCPClient.cs
+++ b/OpenSim/Region/ScriptEngine/Common/TRPC/TCPClient.cs
@@ -1,4 +1,4 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
@@ -37,21 +37,19 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
37{ 37{
38 public class TCPClient : TCPCommon.ClientInterface 38 public class TCPClient : TCPCommon.ClientInterface
39 { 39 {
40
41 public TCPClient() 40 public TCPClient()
42 { 41 {
43 } 42 }
43
44 private readonly Dictionary<int, TCPSocket> Clients = new Dictionary<int, TCPSocket>(); 44 private readonly Dictionary<int, TCPSocket> Clients = new Dictionary<int, TCPSocket>();
45 private int ClientCount = 0; 45 private int ClientCount = 0;
46 46
47
48 public event TCPCommon.ClientConnectedDelegate ClientConnected; 47 public event TCPCommon.ClientConnectedDelegate ClientConnected;
49 public event TCPCommon.DataReceivedDelegate DataReceived; 48 public event TCPCommon.DataReceivedDelegate DataReceived;
50 public event TCPCommon.DataSentDelegate DataSent; 49 public event TCPCommon.DataSentDelegate DataSent;
51 public event TCPCommon.CloseDelegate Close; 50 public event TCPCommon.CloseDelegate Close;
52 public event TCPCommon.ConnectErrorDelegate ConnectError; 51 public event TCPCommon.ConnectErrorDelegate ConnectError;
53 52
54
55 /// <summary> 53 /// <summary>
56 /// Creates client connection 54 /// Creates client connection
57 /// </summary> 55 /// </summary>
@@ -62,6 +60,7 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
62 //newsock.BeginConnect(ipe, new AsyncCallback(asyncConnected), newsock); 60 //newsock.BeginConnect(ipe, new AsyncCallback(asyncConnected), newsock);
63 newsock.Connect(ipe); 61 newsock.Connect(ipe);
64 } 62 }
63
65 public int ConnectAndReturnID(string RemoteHost, int RemotePort) 64 public int ConnectAndReturnID(string RemoteHost, int RemotePort)
66 { 65 {
67 Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); 66 Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
@@ -71,7 +70,6 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
71 return ProcessConnection(newsock); 70 return ProcessConnection(newsock);
72 } 71 }
73 72
74
75 public void Disconnect(int ID) 73 public void Disconnect(int ID)
76 { 74 {
77 Clients[ID].Disconnect(); 75 Clients[ID].Disconnect();
@@ -88,9 +86,6 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
88 { 86 {
89 try 87 try
90 { 88 {
91
92
93
94 int id = ClientCount++; 89 int id = ClientCount++;
95 TCPSocket S = new TCPSocket(id, client); 90 TCPSocket S = new TCPSocket(id, client);
96 91
@@ -121,9 +116,6 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
121 return -1; 116 return -1;
122 } 117 }
123 118
124
125
126
127 void S_DataSent(int ID, int length) 119 void S_DataSent(int ID, int length)
128 { 120 {
129 if (DataSent != null) 121 if (DataSent != null)
@@ -147,7 +139,5 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
147 { 139 {
148 Clients[clientID].Send(clientID, data, offset, len); 140 Clients[clientID].Send(clientID, data, offset, len);
149 } 141 }
150
151
152 } 142 }
153} \ No newline at end of file 143}
diff --git a/OpenSim/Region/ScriptEngine/Common/TRPC/TCPCommon.cs b/OpenSim/Region/ScriptEngine/Common/TRPC/TCPCommon.cs
index f3a55ba..c0e402a 100644
--- a/OpenSim/Region/ScriptEngine/Common/TRPC/TCPCommon.cs
+++ b/OpenSim/Region/ScriptEngine/Common/TRPC/TCPCommon.cs
@@ -1,4 +1,4 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
@@ -36,7 +36,6 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
36 public delegate void CloseDelegate(int ID); 36 public delegate void CloseDelegate(int ID);
37 public delegate void ConnectErrorDelegate(string Reason); 37 public delegate void ConnectErrorDelegate(string Reason);
38 38
39
40 public interface ServerAndClientInterface 39 public interface ServerAndClientInterface
41 { 40 {
42 void Send(int clientID, byte[] data, int offset, int len); 41 void Send(int clientID, byte[] data, int offset, int len);
@@ -45,17 +44,18 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
45 event DataSentDelegate DataSent; 44 event DataSentDelegate DataSent;
46 event CloseDelegate Close; 45 event CloseDelegate Close;
47 } 46 }
47
48 public interface ClientInterface : ServerAndClientInterface 48 public interface ClientInterface : ServerAndClientInterface
49 { 49 {
50 event TCPCommon.ConnectErrorDelegate ConnectError; 50 event TCPCommon.ConnectErrorDelegate ConnectError;
51 void Connect(string RemoteHost, int RemotePort); 51 void Connect(string RemoteHost, int RemotePort);
52 void Disconnect(int ID); 52 void Disconnect(int ID);
53 } 53 }
54
54 public interface ServerInterface : ServerAndClientInterface 55 public interface ServerInterface : ServerAndClientInterface
55 { 56 {
56 void StartListen(); 57 void StartListen();
57 void StopListen(); 58 void StopListen();
58 } 59 }
59
60 } 60 }
61} \ No newline at end of file 61}
diff --git a/OpenSim/Region/ScriptEngine/Common/TRPC/TCPServer.cs b/OpenSim/Region/ScriptEngine/Common/TRPC/TCPServer.cs
index da16da8..b1e6a82 100644
--- a/OpenSim/Region/ScriptEngine/Common/TRPC/TCPServer.cs
+++ b/OpenSim/Region/ScriptEngine/Common/TRPC/TCPServer.cs
@@ -1,4 +1,4 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
@@ -68,7 +68,6 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
68 private readonly Dictionary<int, TCPSocket> Clients = new Dictionary<int, TCPSocket>(); 68 private readonly Dictionary<int, TCPSocket> Clients = new Dictionary<int, TCPSocket>();
69 private int ClientCount = 0; 69 private int ClientCount = 0;
70 70
71
72 public event TCPCommon.ClientConnectedDelegate ClientConnected; 71 public event TCPCommon.ClientConnectedDelegate ClientConnected;
73 public event TCPCommon.DataReceivedDelegate DataReceived; 72 public event TCPCommon.DataReceivedDelegate DataReceived;
74 public event TCPCommon.DataSentDelegate DataSent; 73 public event TCPCommon.DataSentDelegate DataSent;
@@ -127,8 +126,5 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
127 { 126 {
128 Clients[clientID].Send(clientID, data, offset, len); 127 Clients[clientID].Send(clientID, data, offset, len);
129 } 128 }
130
131
132
133 } 129 }
134} \ No newline at end of file 130}
diff --git a/OpenSim/Region/ScriptEngine/Common/TRPC/TCPSocket.cs b/OpenSim/Region/ScriptEngine/Common/TRPC/TCPSocket.cs
index 1e47439..a14f245 100644
--- a/OpenSim/Region/ScriptEngine/Common/TRPC/TCPSocket.cs
+++ b/OpenSim/Region/ScriptEngine/Common/TRPC/TCPSocket.cs
@@ -1,4 +1,4 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
@@ -33,7 +33,6 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
33{ 33{
34 public class TCPSocket 34 public class TCPSocket
35 { 35 {
36
37 public readonly Socket Client; 36 public readonly Socket Client;
38 public readonly int ID; 37 public readonly int ID;
39 38
@@ -52,6 +51,7 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
52 ID = id; 51 ID = id;
53 Client = client; 52 Client = client;
54 } 53 }
54
55 public void Start() 55 public void Start()
56 { 56 {
57 // Start listening 57 // Start listening
@@ -85,10 +85,8 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
85 85
86 // Start new receive 86 // Start new receive
87 BeginReceive(); 87 BeginReceive();
88
89 } 88 }
90 89
91
92 public void Send(int clientID, byte[] data, int offset, int len) 90 public void Send(int clientID, byte[] data, int offset, int len)
93 { 91 {
94 Client.BeginSend(data, offset, len, SocketFlags.None, new AsyncCallback(asyncDataSent), Client); 92 Client.BeginSend(data, offset, len, SocketFlags.None, new AsyncCallback(asyncDataSent), Client);
@@ -111,4 +109,4 @@ namespace OpenSim.Region.ScriptEngine.Common.TRPC
111 Close(ID); 109 Close(ID);
112 } 110 }
113 } 111 }
114} \ No newline at end of file 112}