public Client(string name, IPEndPoint iPEndPoint, Socket socket, Dictionary <IPEndPoint, string> connectedClients, IStringMethods stringMethods, IUserMethods userMethods) { signalHandler += HandleConsoleSignal; SetSignalHandler(signalHandler, true); this.name = name; ConnectedClients = connectedClients; this.iPEndPoint = iPEndPoint; this.socket = socket; this.userMethods = userMethods; this.stringMethods = stringMethods; }
public Client(IStringMethods stringMethods, IUserMethods userMethods) { signalHandler += HandleConsoleSignal; SetSignalHandler(signalHandler, true); ConnectedClients = new Dictionary <IPEndPoint, string>(); socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); this.stringMethods = stringMethods; this.userMethods = userMethods; iPEndPoint = null; bool isStarted = false; while (isStarted != true) { Console.Write("Input your port: "); int port = userMethods.ReadPort(); try { foreach (var iPAdress in Dns.GetHostEntry(Dns.GetHostName()).AddressList) { if (iPAdress.AddressFamily == AddressFamily.InterNetwork) { iPEndPoint = new IPEndPoint(iPAdress, port); break; } } socket.Bind(iPEndPoint); isStarted = true; } catch (Exception) { Console.WriteLine("This port is already in use."); } } Console.Write("Input your name: "); name = userMethods.ReadName() + '(' + iPEndPoint.ToString() + ')'; Console.Write("Your full name is "); Console.WriteLine(name); Console.WriteLine(); this.userMethods.PrintUsingInformation(); Console.WriteLine(); }
public ProblemQ1(IStringMethods myStringMethods) { _stringMethods = myStringMethods; }
public UserMethods(IStringMethods stringMethods) { this.stringMethods = stringMethods; }
static StringExtensions() { _strMethods = new StringMethods(); }
public DecimalMethods() { _stringMethods = new StringMethods(); }
public Chat(IStringMethods stringMethods, IUserMethods userMethods) { this.stringMethods = stringMethods; this.userMethods = userMethods; ConnectedClientsHistory = new Dictionary <IPEndPoint, string>(); }