public TCPServerForm() { this.InitializeComponent(); this.Messenger = new Messenger(); TCPServerSettings serverSettings = new TCPServerSettings(new TCPServerInteractHandler[] { this.Messenger.InteractHandler }, new TCPServerMessageHandler[] { this.MessageHandler, this.Messenger.MessageHandler }, typeof(Message)); this.Server = new TCPServer(serverSettings); this.Timer = new Timer(); this.Timer.Interval = 1000; this.Timer.Tick += this.SyncSocketList; this.Timer.Start(); }
public TCPServer(TCPServerSettings serverSettings) { this.Counter = 0; this.Sockets = new Dictionary <int, TCPServerClientInfo>(); this.MessageLog = new List <string>(); if (serverSettings.Type != null) { this.DataType = serverSettings.Type; } if (serverSettings.InteractHandlers != null) { serverSettings.InteractHandlers.ToList().ForEach(i => this.ServerInteractEvent += i); } if (serverSettings.MessageHandlers != null) { serverSettings.MessageHandlers.ToList().ForEach(i => this.ServerMessageEvent += i); } }