Example #1
0
        /// <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);
        }
Example #2
0
 /// <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);
 }
Example #3
0
 public ListenerUDP(PEndPoint endPoint) : base(endPoint)
 {
     BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, OnReception, this);
 }
Example #4
0
 public ListenerTCP(PEndPoint endPoint) : base(endPoint) => BeginAccept(_OnConnection, this);
Example #5
0
 /// <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 }));
 }