fix(core): Core cleanup, adds event loop synchronization, and fixes gumps (#429)
- [X] Cleans up gump packets
- [X] Adds event loop task synchronization
- [X] Moves timer pause and cleans up the delay task timer class
- [X] Cleans up the conserve cpu
- [X] Renames variables to make them consistent with the new style
- [X] Removes process delta recursion checking.
- [X] Properly diposes net states. This fixes edge cases that may cause hanging connections to stay open longer than they should.
- [X] Fixes an issue with gump items not compiling properly
Users can now utilize `Timer.Pause()` since the code will be executed on the proper thread.
```cs
public void async void Talk()
{
_canTalk = false;
await Timer.Pause(Utility.RandomMinMax(5000, 8000)); // Talk after 5-8 seconds
DoTalk();
await Timer.Pause(Utility.RandomMinMax(12000, 25000)); // Reset ability to talk after 12-25 seconds
_canTalk = true;
}
```
This commit is contained in:
parent
07751654b7
commit
6f0e1a22f9
24 changed files with 763 additions and 449 deletions
|
|
@ -17,24 +17,48 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
public class NetworkSocket : ISocket
|
||||
{
|
||||
public Socket Connection { get; }
|
||||
public EndPoint LocalEndPoint => Connection.LocalEndPoint;
|
||||
public EndPoint RemoteEndPoint => Connection.RemoteEndPoint;
|
||||
private Socket _connection;
|
||||
|
||||
public NetworkSocket(Socket connection) => Connection = connection;
|
||||
public Socket Connection
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _connection;
|
||||
}
|
||||
|
||||
public EndPoint LocalEndPoint
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _connection.LocalEndPoint;
|
||||
}
|
||||
|
||||
public EndPoint RemoteEndPoint
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _connection.RemoteEndPoint;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public NetworkSocket(Socket connection) => _connection = connection;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Task<int> SendAsync(IList<ArraySegment<byte>> buffers, SocketFlags flags) =>
|
||||
Connection.SendAsync(buffers, flags);
|
||||
_connection.SendAsync(buffers, flags);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Task<int> ReceiveAsync(IList<ArraySegment<byte>> buffers, SocketFlags flags) =>
|
||||
Connection.ReceiveAsync(buffers, flags);
|
||||
_connection.ReceiveAsync(buffers, flags);
|
||||
|
||||
public void Shutdown(SocketShutdown how) => Connection.Shutdown(how);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Shutdown(SocketShutdown how) => _connection.Shutdown(how);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Close() => _connection.Close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue