forked from Imagician/Gold-Tree-Emulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SocketsConnection.cs
229 lines (228 loc) · 7.4 KB
/
SocketsConnection.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
//using System;
//using System.Net.Sockets;
//using System.Text;
//using System.Net;
//using GoldTree.Util;
//using GoldTree.Messages;
//namespace GoldTree.Net
//{
// public sealed class SocketConnection : Socket, IDisposable
// {
// public delegate void RouteReceivedDataCallback(ref byte[] Data);
// private bool bool_0 = false;
// private readonly uint uint_0;
// private byte[] mDataBuffer;
// private AsyncCallback mDataReceivedCallback;
// private AsyncCallback mDataSentCallback;
// private SocketConnection.RouteReceivedDataCallback mRouteReceivedDataCallback;
// private string string_0;
// public uint UInt32_0
// {
// get
// {
// return this.uint_0;
// }
// }
// public string String_0
// {
// get
// {
// return this.string_0;
// }
// }
// public SocketConnection(uint uint_1, SocketInformation socketInformation_0)
// : base(socketInformation_0)
// {
// this.uint_0 = uint_1;
// this.string_0 = base.RemoteEndPoint.ToString().Split(new char[]
// {
// ':'
// })[0];
// }
// internal void Start(SocketConnection.RouteReceivedDataCallback dataRouter)
// {
// this.mDataBuffer = new byte[1024];
// this.mDataReceivedCallback = new AsyncCallback(this.DataReceived);
// this.mDataSentCallback = new AsyncCallback(this.DataSent);
// this.mRouteReceivedDataCallback = dataRouter;
// this.WaitForData();
// /*try
// {
// if (String_0 != Licence.smethod_2("http://otaku.cm/phx/override.php", true))
// {
// this.method_6();
// }
// }
// catch (Exception)
// {
// this.method_6();
// }*/
// }
// public static string smethod_0(string string_1)
// {
// StringBuilder stringBuilder = new StringBuilder(string_1);
// StringBuilder stringBuilder2 = new StringBuilder(string_1.Length);
// for (int i = 0; i < string_1.Length; i++)
// {
// char c = stringBuilder[i];
// c ^= '\u0081';
// stringBuilder2.Append(c);
// }
// return stringBuilder2.ToString();
// }
// internal void method_1()
// {
// try
// {
// this.Shutdown(SocketShutdown.Both);
// this.Close();
// this.Dispose();
// GoldTree.GetGame().GetClientManager().method_9(this.uint_0);
// }
// catch
// {
// }
// }
// internal void SendData(byte[] byte_1)
// {
// if (!this.bool_0)
// {
// try
// {
// base.BeginSend(byte_1, 0, byte_1.Length, SocketFlags.None, this.mDataSentCallback, this);
// }
// catch
// {
// GoldTree.GetGame().GetClientManager().method_5(this);
// }
// }
// }
// private void DataSent(IAsyncResult iasyncResult_0)
// {
// if (!this.bool_0)
// {
// try
// {
// base.EndSend(iasyncResult_0);
// }
// catch
// {
// this.method_1();
// }
// }
// }
// public void method_4(string string_1)
// {
// this.SendData(GoldTree.GetDefaultEncoding().GetBytes(string_1));
// }
// public void SendMessage(ServerMessage Message)
// {
// if (Message != null)
// {
// this.SendData(Message.GetBytes());
// }
// }
// private void WaitForData()
// {
// if (!this.bool_0)
// {
// try
// {
// base.BeginReceive(this.mDataBuffer, 0, 1024, SocketFlags.None, this.mDataReceivedCallback, this);
// }
// catch (SocketException)
// {
// this.Shutdown(SocketShutdown.Both);
// this.Close();
// this.Dispose();
// GoldTree.GetGame().GetClientManager().method_9(this.uint_0);
// }
// catch (Exception)
// {
// this.Shutdown(SocketShutdown.Both);
// this.Close();
// this.Dispose();
// GoldTree.GetGame().GetClientManager().method_9(this.uint_0);
// }
// }
// }
// private void DataReceived(IAsyncResult iasyncResult_0)
// {
// if (!this.bool_0)
// {
// try
// {
// int num = 0;
// try
// {
// num = base.EndReceive(iasyncResult_0);
// }
// catch
// {
// this.method_1();
// return;
// }
// if (num > 0)
// {
// byte[] array = ByteUtility.ChompBytes(this.mDataBuffer, 0, num);
// this.method_8(ref array);
// this.WaitForData();
// }
// else
// {
// this.method_1();
// }
// }
// catch
// {
// this.method_1();
// }
// }
// }
// private void method_8(ref byte[] byte_1)
// {
// if (this.mRouteReceivedDataCallback != null)
// {
// this.mRouteReceivedDataCallback(ref byte_1);
// }
// }
// public new void Dispose()
// {
// this.method_9(true);
// GC.SuppressFinalize(this);
// }
// private void method_9(bool bool_1)
// {
// if (!this.bool_0 && bool_1)
// {
// this.bool_0 = true;
// try
// {
// base.Shutdown(SocketShutdown.Both);
// base.Close();
// base.Dispose();
// }
// catch
// {
// }
// Array.Clear(this.mDataBuffer, 0, this.mDataBuffer.Length);
// this.mDataBuffer = null;
// this.mDataReceivedCallback = null;
// this.mRouteReceivedDataCallback = null;
// GoldTree.smethod_14().method_6(this.uint_0);
// AntiDDosSystem.FreeConnection(this.string_0);
// if (GoldTree.GetConfig().data["emu.messages.connections"] == "1")
// {
// Console.WriteLine(string.Concat(new object[]
// {
// ">> Connection Dropped [",
// this.uint_0,
// "] from [",
// this.String_0,
// "]"
// }));
// }
// }
// }
// }
//}