using System;
using System.Net;

namespace WS
{
    public enum NetworkType
	{
		KCP,
		TCP,
		WebSocket,
	}

	///<summary>服务</summary>
	public abstract class AService : WSComponent
	{
		///<summary>客户端链接</summary>
		public abstract AChannel GetChannel(long id);

		///<summary>收到客服端链接回调</summary>
		private Action<AChannel> acceptCallback;
		///<summary>收到客户端链接回调</summary>
		public event Action<AChannel> AcceptCallback
		{
			add
			{
				acceptCallback += value;
			}
			remove
			{
				acceptCallback -= value;
			}
		}

		///<summary>发送客户端链接成功事件</summary>
		protected void OnAccept(AChannel channel)
		{
			acceptCallback.Invoke(channel);
		}

		///<summary>链接渠道</summary>
		public abstract AChannel ConnectChannel(IPEndPoint ipEndPoint);

		///<summary>链接渠道</summary>
		public abstract AChannel ConnectChannel(string address);

		///<summary>删除</summary>
		public abstract void Remove(long channelId);

		///<summary>帧更新</summary>
		public abstract void Update();
	}
}