-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClientSock.cs
58 lines (54 loc) · 1.72 KB
/
ClientSock.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
namespace Terraria
{
using System;
using System.Diagnostics;
using System.Net.Sockets;
public class ClientSock
{
public bool active = false;
public bool locked = false;
public NetworkStream networkStream;
public byte[] readBuffer;
public int state = 0;
public int statusCount;
public int statusMax;
public string statusText;
public TcpClient tcpClient = new TcpClient();
public int timeOut = 0;
public byte[] writeBuffer;
public void ClientReadCallBack(IAsyncResult ar)
{
int streamLength = 0;
if (!Netplay.disconnect)
{
streamLength = this.networkStream.EndRead(ar);
if (streamLength == 0)
{
Netplay.disconnect = true;
Main.statusText = "Lost connection";
}
else if (Main.ignoreErrors)
{
try
{
NetMessage.RecieveBytes(this.readBuffer, streamLength, 0x100);
}
catch
{
Debug.WriteLine(string.Concat(new object[] { "Error: NetMessage.RecieveBytes(", this.readBuffer, ", ", streamLength, ")" }));
}
}
else
{
NetMessage.RecieveBytes(this.readBuffer, streamLength, 0x100);
}
}
this.locked = false;
}
public void ClientWriteCallBack(IAsyncResult ar)
{
messageBuffer buffer1 = NetMessage.buffer[0x100];
buffer1.spamCount--;
}
}
}