You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Network/BaseSocket.cs

57 lines
2.1 KiB

6 years ago
using System;
namespace ZeroLevel.Network
6 years ago
{
5 years ago
public abstract class BaseSocket
6 years ago
{
5 years ago
static BaseSocket()
5 years ago
{
MAX_FRAME_PAYLOAD_SIZE = Configuration.Default.FirstOrDefault<int>("MAX_FRAME_PAYLOAD_SIZE", DEFAULT_MAX_FRAME_PAYLOAD_SIZE);
}
6 years ago
public const string DEFAULT_MESSAGE_INBOX = "__message_inbox__";
public const string DEFAULT_REQUEST_INBOX = "__request_inbox__";
protected const string DEFAULT_REQUEST_ERROR_INBOX = "__request_error__";
6 years ago
/// <summary>
6 years ago
/// Buffer size for receiving data
6 years ago
/// </summary>
protected const int DEFAULT_RECEIVE_BUFFER_SIZE = 4096;
6 years ago
/// <summary>
6 years ago
/// If during the specified period there was no network activity, send a ping-request
6 years ago
/// </summary>
protected const long HEARTBEAT_PING_PERIOD_TICKS = 1500 * TimeSpan.TicksPerMillisecond;
6 years ago
/// <summary>
6 years ago
/// Connection check period
6 years ago
/// </summary>
5 years ago
protected const int MINIMUM_HEARTBEAT_UPDATE_PERIOD_MS = 7500;
6 years ago
/// <summary>
6 years ago
/// The period of the request, after which it is considered unsuccessful
6 years ago
/// </summary>
5 years ago
internal const long MAX_REQUEST_TIME_TICKS = 30000 * TimeSpan.TicksPerMillisecond;
6 years ago
public const int MAX_REQUEST_TIME_MS = 30000;
6 years ago
/// <summary>
6 years ago
/// Maximum size of data packet to transmit (serialized frame size)
6 years ago
/// </summary>
5 years ago
private const int DEFAULT_MAX_FRAME_PAYLOAD_SIZE = 1024 * 1024 * 32;
public readonly static int MAX_FRAME_PAYLOAD_SIZE;
6 years ago
/// <summary>
6 years ago
/// The size of the message queue to send
6 years ago
/// </summary>
public const int MAX_SEND_QUEUE_SIZE = 1024;
5 years ago
protected void Broken() => Status = Status == SocketClientStatus.Disposed ? Status : SocketClientStatus.Broken;
protected void Disposed() => Status = SocketClientStatus.Disposed;
protected void Working() => Status = Status == SocketClientStatus.Disposed ? Status : SocketClientStatus.Working;
public SocketClientStatus Status { get; private set; } = SocketClientStatus.Initialized;
6 years ago
public abstract void Dispose();
}
5 years ago
}

Powered by TurnKey Linux.