67 lines
1.4 KiB
C#
67 lines
1.4 KiB
C#
// This file is part of the EonaCat project(s) which is released under the Apache License.
|
|
// See the LICENSE file or go to https://EonaCat.com/License for full license details.
|
|
|
|
using System;
|
|
|
|
namespace EonaCat.Network
|
|
{
|
|
public abstract class WSEndpointHost
|
|
{
|
|
protected WSEndpointHost(string path)
|
|
{
|
|
Path = path;
|
|
Sessions = new WSSessionManager();
|
|
}
|
|
|
|
internal ServerState State => Sessions.State;
|
|
|
|
public bool KeepClean
|
|
{
|
|
get
|
|
{
|
|
return Sessions.KeepClean;
|
|
}
|
|
|
|
set
|
|
{
|
|
Sessions.KeepClean = value;
|
|
}
|
|
}
|
|
|
|
public string Path { get; }
|
|
|
|
public WSSessionManager Sessions { get; }
|
|
|
|
public abstract Type EndpointType { get; }
|
|
|
|
public TimeSpan WaitTime
|
|
{
|
|
get
|
|
{
|
|
return Sessions.WaitTime;
|
|
}
|
|
|
|
set
|
|
{
|
|
Sessions.WaitTime = value;
|
|
}
|
|
}
|
|
|
|
internal void Start()
|
|
{
|
|
Sessions.Start();
|
|
}
|
|
|
|
internal void StartSession(WSContext context)
|
|
{
|
|
CreateSession().Start(context, Sessions);
|
|
}
|
|
|
|
internal void Stop(ushort code, string reason)
|
|
{
|
|
Sessions.Stop(code, reason);
|
|
}
|
|
|
|
protected abstract WSEndpoint CreateSession();
|
|
}
|
|
} |