-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
351 changed files
with
8,134 additions
and
3,724 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System.Net.Sockets; | ||
using Chaos.Cryptography.Abstractions; | ||
using Chaos.Networking.Entities.Server; | ||
using Chaos.Packets; | ||
using Chaos.Packets.Abstractions; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Chaos.Networking.Abstractions; | ||
|
||
/// <summary> | ||
/// Represents a client that is connected to an <see cref="IServer{T}" />. This class defines the methods used to | ||
/// communicate with the client. | ||
/// </summary> | ||
public abstract class ConnectedClientBase : SocketClientBase, IConnectedClient | ||
{ | ||
/// <inheritdoc /> | ||
protected ConnectedClientBase( | ||
Socket socket, | ||
ICrypto crypto, | ||
IPacketSerializer packetSerializer, | ||
ILogger<ConnectedClientBase> logger) | ||
: base( | ||
socket, | ||
crypto, | ||
packetSerializer, | ||
logger) { } | ||
|
||
/// <inheritdoc /> | ||
public virtual void SendAcceptConnection(string message) | ||
{ | ||
var args = new AcceptConnectionArgs | ||
{ | ||
Message = message | ||
}; | ||
|
||
Send(args); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public virtual void SendHeartBeat(byte first, byte second) | ||
{ | ||
var args = new HeartBeatResponseArgs | ||
{ | ||
First = first, | ||
Second = second | ||
}; | ||
|
||
Send(args); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public virtual void SendRedirect(IRedirect redirect) | ||
{ | ||
var args = new RedirectArgs | ||
{ | ||
EndPoint = redirect.EndPoint, | ||
Seed = redirect.Seed, | ||
Key = redirect.Key, | ||
Name = redirect.Name, | ||
Id = redirect.Id | ||
}; | ||
|
||
Send(args); | ||
} | ||
|
||
/// <inheritdoc /> | ||
public override void Encrypt(ref Packet packet) => Crypto.ServerEncrypt(ref packet.Buffer, packet.OpCode, packet.Sequence); | ||
|
||
/// <inheritdoc /> | ||
public override bool IsEncrypted(byte opCode) => Crypto.IsServerEncrypted(opCode); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Chaos.Networking.Entities.Server; | ||
using Chaos.Packets.Abstractions.Definitions; | ||
|
||
namespace Chaos.Networking.Abstractions; | ||
|
||
/// <summary> | ||
/// Defines a pattern for an object that represents a client connected to a lobby server. | ||
/// </summary> | ||
public interface ILobbyClient : IConnectedClient | ||
{ | ||
/// <summary> | ||
/// Sends the connection information to the client. | ||
/// </summary> | ||
/// <remarks> | ||
/// Opcode: <see cref="ServerOpCode.ConnectionInfo" /> | ||
/// </remarks> | ||
void SendConnectionInfo(ConnectionInfoArgs args); | ||
|
||
/// <summary> | ||
/// Sends the server table response to the client. | ||
/// </summary> | ||
/// <remarks> | ||
/// Opcode: <see cref="ServerOpCode.ServerTableResponse" /> | ||
/// </remarks> | ||
void SendServerTableResponse(ServerTableResponseArgs args); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Chaos.Networking.Entities.Server; | ||
using Chaos.Packets.Abstractions.Definitions; | ||
|
||
namespace Chaos.Networking.Abstractions; | ||
|
||
/// <summary> | ||
/// Represents a client that is connected to the login server. | ||
/// </summary> | ||
public interface ILoginClient : IConnectedClient | ||
{ | ||
/// <summary> | ||
/// Sends a login control message to the client. | ||
/// </summary> | ||
/// <remarks> | ||
/// Opcode: <see cref="ServerOpCode.LoginControl" /> | ||
/// </remarks> | ||
void SendLoginControl(LoginControlArgs args); | ||
|
||
/// <summary> | ||
/// Sends a login message to the client. | ||
/// </summary> | ||
/// <remarks> | ||
/// Opcode: <see cref="ServerOpCode.LoginMessage" /> | ||
/// </remarks> | ||
void SendLoginMessage(LoginMessageArgs args); | ||
|
||
/// <summary> | ||
/// Sends a login notice to the client. | ||
/// </summary> | ||
/// <remarks> | ||
/// Opcode: <see cref="ServerOpCode.LoginNotice" /> | ||
/// </remarks> | ||
void SendLoginNotice(LoginNoticeArgs args); | ||
|
||
/// <summary> | ||
/// Sends meta data to the client. | ||
/// </summary> | ||
/// <remarks> | ||
/// Opcode: <see cref="ServerOpCode.MetaData" /> | ||
/// </remarks> | ||
void SendMetaData(MetaDataArgs args); | ||
} |
Oops, something went wrong.