/// <summary> /// Constructs a new listener. Can be used to manually add them /// </summary> /// <param name="endPoint">End point of the listener</param> public Listener(PEndPoint endPoint) : base(AddressFamily.InterNetwork, endPoint.Protocol.GetSocketType(), endPoint.Protocol.GetNativeType()) { _endPoint = endPoint; endPoint.Protocol.SetupListener(this, endPoint.Port); lock (_LISTENERS_LOCK) LISTENERS.Add(endPoint, this); }
/// <summary> /// Dynamically link a port and an extension on the go /// </summary> /// <param name="port">Port to set up a listener on</param> /// <param name="extension">Extension to link</param> public static void Link(PEndPoint port, ServerExtensionInitializer extension) { if (clientSyncInit.ContainsKey(port)) { ServerMain.logging.Alert("static Listener.Link : port " + port + " is already bounded!"); return; } clientSyncInit.Add(port, extension); Instantiate(port); }
public ListenerUDP(PEndPoint endPoint) : base(endPoint) { BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, OnReception, this); }
public ListenerTCP(PEndPoint endPoint) : base(endPoint) => BeginAccept(_OnConnection, this);
/// <summary> /// Instantiates a new listener with a type fit for the given end point /// </summary> public static Listener Instantiate(PEndPoint endPoint) { return((Listener)PROTOCOL_LISTENER_TYPES[endPoint.Protocol].GetConstructor(new Type[] { typeof(PEndPoint) }).Invoke(new object[] { endPoint })); }