protected override void HandleConnectionReady(IPEndPoint from) { if (connectingMessengers.Remove(from)) { // Complete the connection process NetConnection conn = new NetConnection(from, this); if (!Connections.TryAdd(from, conn)) { NetLogger.LogError("An error occured trying to add a NetConnection! IP: {0}", from); } else { NetLogger.LogImportant("Client successfully connected from {0}", from); newConnections.Enqueue(conn); } } else { NetLogger.LogWarning("ConnectionReady sent from non-connecting client @ {0}!", from); AddWatchedConnection(from, "connection ready from non-connecting client"); } base.HandleConnectionReady(from); }
public bool Start(IPEndPoint endPoint, IPEndPoint receiveEndPoint = null) { if (IsRunning) { throw new NetException(string.Format("{0} is already running!", GetType().Name)); } try { IsRunning = true; // Create the socket and setup endpoints CreateSocket(endPoint, receiveEndPoint); // Log success NetLogger.LogImportant("Started DashNet v3.0"); //NetLogger.LogImportant("{1} bound to {0}, listening on {2}", BoundEndPoint, GetType().Name, ReceiveEndPoint); NetLogger.LogImportant("{1} bound to {0}", BoundEndPoint, GetType().Name); NetLogger.LogImportant("{1} receiving on {0}", ReceiveEndPoint, GetType().Name); // Start the network loop CreateStartThread(); return(true); } catch (SocketException e) { IsRunning = false; NetLogger.LogError("Could not start Messenger, {0}", e.SocketErrorCode); return(false); } }