diff options
Diffstat (limited to '')
-rw-r--r-- | ThirdParty/3Di/LoadBalancer/TcpClient.cs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/ThirdParty/3Di/LoadBalancer/TcpClient.cs b/ThirdParty/3Di/LoadBalancer/TcpClient.cs index af678a0..e9e019c 100644 --- a/ThirdParty/3Di/LoadBalancer/TcpClient.cs +++ b/ThirdParty/3Di/LoadBalancer/TcpClient.cs | |||
@@ -34,8 +34,8 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
34 | { | 34 | { |
35 | public class AsynchronousClient | 35 | public class AsynchronousClient |
36 | { | 36 | { |
37 | private static ManualResetEvent connectDone = new ManualResetEvent(false); | 37 | private static readonly ManualResetEvent connectDone = new ManualResetEvent(false); |
38 | private static ManualResetEvent sendDone = new ManualResetEvent(false); | 38 | private static readonly ManualResetEvent sendDone = new ManualResetEvent(false); |
39 | 39 | ||
40 | public static Socket StartClient(string hostname, int port) | 40 | public static Socket StartClient(string hostname, int port) |
41 | { | 41 | { |
@@ -46,7 +46,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
46 | IPEndPoint remoteEP = new IPEndPoint(ipAddress, port); | 46 | IPEndPoint remoteEP = new IPEndPoint(ipAddress, port); |
47 | 47 | ||
48 | Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); | 48 | Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); |
49 | client.BeginConnect(remoteEP, new AsyncCallback(ConnectCallback), client); | 49 | client.BeginConnect(remoteEP, ConnectCallback, client); |
50 | connectDone.WaitOne(); | 50 | connectDone.WaitOne(); |
51 | /* | 51 | /* |
52 | Send(client,"This is a test<EOF>"); | 52 | Send(client,"This is a test<EOF>"); |
@@ -71,7 +71,7 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
71 | { | 71 | { |
72 | Socket client = (Socket) ar.AsyncState; | 72 | Socket client = (Socket) ar.AsyncState; |
73 | client.EndConnect(ar); | 73 | client.EndConnect(ar); |
74 | Console.WriteLine("Socket connected to {0}", client.RemoteEndPoint.ToString()); | 74 | Console.WriteLine("Socket connected to {0}", client.RemoteEndPoint); |
75 | connectDone.Set(); | 75 | connectDone.Set(); |
76 | } | 76 | } |
77 | catch (Exception e) | 77 | catch (Exception e) |
@@ -138,8 +138,8 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
138 | 138 | ||
139 | public class InternalPacketHeader | 139 | public class InternalPacketHeader |
140 | { | 140 | { |
141 | private readonly byte[] buffer = new byte[32]; | ||
141 | public Guid agent_id; | 142 | public Guid agent_id; |
142 | private byte[] buffer = new byte[32]; | ||
143 | public int numbytes; | 143 | public int numbytes; |
144 | public int region_port; | 144 | public int region_port; |
145 | public int throttlePacketType; | 145 | public int throttlePacketType; |
@@ -150,16 +150,16 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
150 | int i = 0; // offset | 150 | int i = 0; // offset |
151 | try | 151 | try |
152 | { | 152 | { |
153 | type = (int) (bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); | 153 | type = (bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); |
154 | throttlePacketType = (int) (bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); | 154 | throttlePacketType = (bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); |
155 | numbytes = (int) (bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); | 155 | numbytes = (bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); |
156 | agent_id = new Guid( | 156 | agent_id = new Guid( |
157 | bytes[i++] | (bytes[i++] << 8) | (bytes[i++] << 16) | bytes[i++] << 24, | 157 | bytes[i++] | (bytes[i++] << 8) | (bytes[i++] << 16) | bytes[i++] << 24, |
158 | (short) (bytes[i++] | (bytes[i++] << 8)), | 158 | (short) (bytes[i++] | (bytes[i++] << 8)), |
159 | (short) (bytes[i++] | (bytes[i++] << 8)), | 159 | (short) (bytes[i++] | (bytes[i++] << 8)), |
160 | bytes[i++], bytes[i++], bytes[i++], bytes[i++], | 160 | bytes[i++], bytes[i++], bytes[i++], bytes[i++], |
161 | bytes[i++], bytes[i++], bytes[i++], bytes[i++]); | 161 | bytes[i++], bytes[i++], bytes[i++], bytes[i++]); |
162 | region_port = (int) (bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); | 162 | region_port = (bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); |
163 | } | 163 | } |
164 | catch (Exception) | 164 | catch (Exception) |
165 | { | 165 | { |
@@ -201,10 +201,10 @@ namespace OpenSim.ApplicationPlugins.LoadBalancer | |||
201 | public class TcpClient | 201 | public class TcpClient |
202 | { | 202 | { |
203 | public static int internalPacketHeaderSize = 4 * 4 + 16 * 1; | 203 | public static int internalPacketHeaderSize = 4 * 4 + 16 * 1; |
204 | private Socket mConnection; | ||
205 | 204 | ||
206 | private string mHostname; | 205 | private readonly string mHostname; |
207 | private int mPort; | 206 | private readonly int mPort; |
207 | private Socket mConnection; | ||
208 | 208 | ||
209 | public TcpClient(string hostname, int port) | 209 | public TcpClient(string hostname, int port) |
210 | { | 210 | { |