mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-10 15:28:37 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
85 lines
2.2 KiB
C#
85 lines
2.2 KiB
C#
namespace Sandbox.Network;
|
|
|
|
public abstract class NetworkSocket
|
|
{
|
|
internal Action<Connection> OnClientConnect;
|
|
internal Action<Connection> OnClientDisconnect;
|
|
internal Action<(Connection previous, Connection current)> OnHostChanged;
|
|
|
|
/// <summary>
|
|
/// Whether this socket should be disposed automatically when the network system
|
|
/// it belongs to is disconnected.
|
|
/// </summary>
|
|
internal bool AutoDispose { get; set; } = true;
|
|
|
|
internal abstract void Dispose();
|
|
internal abstract void GetIncomingMessages( NetworkSystem.MessageHandler handler );
|
|
|
|
/// <summary>
|
|
/// This is called on a worker thread and should handle any threaded processing of messages.
|
|
/// </summary>
|
|
internal abstract void ProcessMessagesInThread();
|
|
|
|
/// <summary>
|
|
/// Called when everything has just been hooked up to the network system.
|
|
/// </summary>
|
|
internal virtual void Initialize( NetworkSystem networkSystem )
|
|
{
|
|
// If the socket already has connections, we should call OnClientConnect here to
|
|
// add them to the network system
|
|
}
|
|
|
|
/// <summary>
|
|
/// ConnectionInfo table has been updated
|
|
/// </summary>
|
|
internal virtual void OnConnectionInfoUpdated( NetworkSystem networkSystem )
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when a session has failed with a user. Steam Networking Messages will invoke this callback
|
|
/// if an attempt to send a message to a user failed because of a broken session.
|
|
/// </summary>
|
|
internal virtual void OnSessionFailed( SteamId steamId )
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set data about this socket. For example, this might be used to change whether a lobby
|
|
/// should be visible for players depending on the game state.
|
|
/// </summary>
|
|
internal virtual void SetData( string key, string value )
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the name of the server. This will be displayed to other players when they
|
|
/// query servers.
|
|
/// </summary>
|
|
internal virtual void SetServerName( string name )
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the current map name. This will be displayed to other players when they
|
|
/// query servers.
|
|
/// </summary>
|
|
internal virtual void SetMapName( string name )
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called once a second
|
|
/// </summary>
|
|
internal virtual void Tick( NetworkSystem networkSystem )
|
|
{
|
|
|
|
}
|
|
}
|
|
|