diff --git a/TShock.sln b/TShock.sln
index 03fbbe2b..b26d5ef2 100644
--- a/TShock.sln
+++ b/TShock.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.30501.0
+# Visual Studio Express 2013 for Windows Desktop
+VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{755F5B05-0924-47E9-9563-26EB20FE3F67}"
EndProject
@@ -9,7 +9,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TShockAPI", "TShockAPI\TSho
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TShockRestTestPlugin", "TShockRestTestPlugin\TShockRestTestPlugin.csproj", "{F2FEDAFB-58DE-4611-9168-A86112C346C7}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TerrariaServer", "TerrariaServerAPI\TerrariaServer.csproj", "{549A7941-D9C9-4544-BAC8-D9EEEAB4D777}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TerrariaServer", "TerrariaServerAPI\TerrariaServer.csproj", "{6877506E-ADC6-4142-98A6-79E4FA02855A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -41,16 +41,16 @@ Global
{F2FEDAFB-58DE-4611-9168-A86112C346C7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{F2FEDAFB-58DE-4611-9168-A86112C346C7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{F2FEDAFB-58DE-4611-9168-A86112C346C7}.Release|x86.ActiveCfg = Release|Any CPU
- {549A7941-D9C9-4544-BAC8-D9EEEAB4D777}.Debug|Any CPU.ActiveCfg = Debug|x86
- {549A7941-D9C9-4544-BAC8-D9EEEAB4D777}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
- {549A7941-D9C9-4544-BAC8-D9EEEAB4D777}.Debug|Mixed Platforms.Build.0 = Debug|x86
- {549A7941-D9C9-4544-BAC8-D9EEEAB4D777}.Debug|x86.ActiveCfg = Debug|x86
- {549A7941-D9C9-4544-BAC8-D9EEEAB4D777}.Debug|x86.Build.0 = Debug|x86
- {549A7941-D9C9-4544-BAC8-D9EEEAB4D777}.Release|Any CPU.ActiveCfg = Release|x86
- {549A7941-D9C9-4544-BAC8-D9EEEAB4D777}.Release|Mixed Platforms.ActiveCfg = Release|x86
- {549A7941-D9C9-4544-BAC8-D9EEEAB4D777}.Release|Mixed Platforms.Build.0 = Release|x86
- {549A7941-D9C9-4544-BAC8-D9EEEAB4D777}.Release|x86.ActiveCfg = Release|x86
- {549A7941-D9C9-4544-BAC8-D9EEEAB4D777}.Release|x86.Build.0 = Release|x86
+ {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Any CPU.ActiveCfg = Debug|x86
+ {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
+ {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|Mixed Platforms.Build.0 = Debug|x86
+ {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x86.ActiveCfg = Debug|x86
+ {6877506E-ADC6-4142-98A6-79E4FA02855A}.Debug|x86.Build.0 = Debug|x86
+ {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Any CPU.ActiveCfg = Release|x86
+ {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Mixed Platforms.ActiveCfg = Release|x86
+ {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|Mixed Platforms.Build.0 = Release|x86
+ {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x86.ActiveCfg = Release|x86
+ {6877506E-ADC6-4142-98A6-79E4FA02855A}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/TShockAPI/PacketBufferer.cs b/TShockAPI/PacketBufferer.cs
index 5d420618..fbbec6e7 100644
--- a/TShockAPI/PacketBufferer.cs
+++ b/TShockAPI/PacketBufferer.cs
@@ -36,7 +36,7 @@ namespace TShockAPI
private readonly TShock plugin;
- private PacketBuffer[] buffers = new PacketBuffer[Netplay.serverSock.Length];
+ private PacketBuffer[] buffers = new PacketBuffer[Netplay.Clients.Length];
private int[] Bytes = new int[52];
private int[] Packets = new int[52];
@@ -117,29 +117,32 @@ namespace TShockAPI
public void FlushAll()
{
- for (int i = 0; i < Netplay.serverSock.Length; i++)
+ for (int i = 0; i < Netplay.Clients.Length; i++)
{
- Flush(Netplay.serverSock[i]);
+ Flush(Netplay.Clients[i]);
}
}
- public bool Flush(ServerSock socket)
+ public bool Flush(RemoteClient client)
{
try
{
- if (socket == null || !socket.active)
+ if (client == null || !client.IsActive)
return false;
- if (buffers[socket.whoAmI].Count < 1)
+ if (!client.Socket.IsConnected())
+ return false;
+
+ if (buffers[client.Id].Count < 1)
return false;
- byte[] buff = buffers[socket.whoAmI].GetBytes(BytesPerUpdate);
+ byte[] buff = buffers[client.Id].GetBytes(BytesPerUpdate);
if (buff == null)
return false;
- if (SendBytes(socket, buff))
+ if (SendBytes(client, buff))
{
- buffers[socket.whoAmI].Pop(buff.Length);
+ buffers[client.Id].Pop(buff.Length);
return true;
}
}
@@ -153,22 +156,22 @@ namespace TShockAPI
private void ServerHooks_SocketReset(SocketResetEventArgs args)
{
- buffers[args.Socket.whoAmI] = new PacketBuffer();
+ buffers[args.Socket.Id] = new PacketBuffer();
}
- public bool SendBytes(ServerSock socket, byte[] buffer)
+ public bool SendBytes(RemoteClient client, byte[] buffer)
{
- return SendBytes(socket, buffer, 0, buffer.Length);
+ return SendBytes(client, buffer, 0, buffer.Length);
}
- public void BufferBytes(ServerSock socket, byte[] buffer)
+ public void BufferBytes(RemoteClient client, byte[] buffer)
{
- BufferBytes(socket, buffer, 0, buffer.Length);
+ BufferBytes(client, buffer, 0, buffer.Length);
}
- public void BufferBytes(ServerSock socket, byte[] buffer, int offset, int count)
+ public void BufferBytes(RemoteClient client, byte[] buffer, int offset, int count)
{
- lock (buffers[socket.whoAmI])
+ lock (buffers[client.Id])
{
#if DEBUG_NET
int size = (count - offset);
@@ -180,27 +183,27 @@ namespace TShockAPI
#endif
using (var ms = new MemoryStream(buffer, offset, count))
{
- buffers[socket.whoAmI].AddRange(ms.ToArray());
+ buffers[client.Id].AddRange(ms.ToArray());
}
- if (TShock.Config.EnableMaxBytesInBuffer && buffers[socket.whoAmI].Count > TShock.Config.MaxBytesInBuffer)
+ if (TShock.Config.EnableMaxBytesInBuffer && buffers[client.Id].Count > TShock.Config.MaxBytesInBuffer)
{
- buffers[socket.whoAmI].Clear();
- socket.kill = true;
+ buffers[client.Id].Clear();
+ client.PendingTermination = true;
}
}
}
- public bool SendBytes(ServerSock socket, byte[] buffer, int offset, int count)
+ public bool SendBytes(RemoteClient client, byte[] buffer, int offset, int count)
{
try
{
- if (socket.tcpClient.Client != null && socket.tcpClient.Client.Poll(0, SelectMode.SelectWrite))
+ if (client.Socket != null && client.Socket.IsConnected())
{
- if (ServerApi.RunningMono && !ServerApi.UseAsyncSocketsInMono)
- socket.networkStream.Write(buffer, offset, count);
- else
- socket.networkStream.BeginWrite(buffer, offset, count, socket.ServerWriteCallBack, socket.networkStream);
+ //if (ServerApi.RunningMono && !ServerApi.UseAsyncSocketsInMono)
+ client.Socket.AsyncSend(buffer, offset, count, null);
+ //else
+ //client.networkStream.BeginWrite(buffer, offset, count, socket.ServerWriteCallBack, socket.networkStream);
return true;
}
}
diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj
index 19d2265b..ec9b6549 100644
--- a/TShockAPI/TShockAPI.csproj
+++ b/TShockAPI/TShockAPI.csproj
@@ -177,9 +177,9 @@
-
- {549A7941-D9C9-4544-BAC8-D9EEEAB4D777}
- TerrariaAPI-Server
+
+ {6877506e-adc6-4142-98a6-79e4fa02855a}
+ TerrariaServer
@@ -193,7 +193,7 @@
-
+