public Menu() { InitializeComponent(); socketServer = new SocketServer(911, Program.ErrorLog, Program.DebugLog); this.Text = "sar-tool testing:" + Program.port.ToString(); foreach (var file in Program.Server.Cache.Files) { System.Diagnostics.Debug.WriteLine(file); } try { throw new ApplicationException("test"); } catch (Exception ex) { textBox3.Text = ExceptionHelper.GetStackTrace(ex); } this.loop = new Thread(this.TestLoop); this.loop.IsBackground = true; this.loop.Start(); }
public SocketClient(SocketServer parent, TcpClient socket, long clientID, ErrorLogger errorLog, FileLogger debugLog) : base(errorLog, debugLog) { try { this.encoding = Encoding.ASCII; this.parent = parent; this.ID = clientID; this.socket = socket; this.stream = this.socket.GetStream(); this.connected = true; this.connectionLoopThread = new Thread(this.ConnectionLoop); this.outgoingLoopThread = new Thread(this.OutgoingLoop); this.incomingLoopThread = new Thread(this.IncomingLoop); this.pingLoopThread = new Thread(this.PingLoop); this.connectionLoopThread.IsBackground = true; this.outgoingLoopThread.IsBackground = true; this.incomingLoopThread.IsBackground = true; this.pingLoopThread.IsBackground = true; this.Log("Host Constructor"); this.messagesOut = new List<SocketMessage>(); this.messagesIn = new List<SocketMessage>(); // connected this.initilized = true; this.OnConnectionChange(true); this.outgoingLoopThread.Start(); this.incomingLoopThread.Start(); this.connectionLoopThread.Start(); // send clientID this.SendData("set", "Me.ID", clientID.ToString(), this.ID); // send all values lock (parent.MemCache) { foreach (KeyValuePair<string, SocketValue> entry in parent.MemCache) { SocketValue val = entry.Value; this.SendValue(entry.Value, this.ID); } } // send initilization code to client this.SendData("startup", this.ID); } catch (Exception ex) { this.Log(ex); } }
protected override void Dispose(bool disposing) { if (!disposed) { if (disposing) { this.Log("Dispose Starting"); this.Stop(); this.parent = null; this.messagesOut = null; this.messagesIn = null; this.connectionLoopThread = null; this.outgoingLoopThread = null; this.incomingLoopThread = null; this.pingLoopThread = null; this.socket = null; this.stream.Dispose(); this.stream = null; this.memCache = null; this.Log("Dispose Complete"); } } disposed = true; }
public SocketClient(string hostname, int port, ErrorLogger errorLog, FileLogger debugLog) : base(errorLog, debugLog) { this.Log("Client Constructor"); this.encoding = Encoding.ASCII; this.parent = null; this.hostname = hostname; this.port = port; this.messagesOut = new List<SocketMessage>(); this.messagesIn = new List<SocketMessage>(); this.initilized = false; this.connected = false; this.connectionLoopThread = new Thread(this.ConnectionLoop); this.outgoingLoopThread = new Thread(this.OutgoingLoop); this.incomingLoopThread = new Thread(this.IncomingLoop); this.pingLoopThread = new Thread(this.PingLoop); this.connectionLoopThread.IsBackground = true; this.outgoingLoopThread.IsBackground = true; this.incomingLoopThread.IsBackground = true; this.pingLoopThread.IsBackground = true; this.connectionLoopThread.Start(); this.incomingLoopThread.Start(); this.outgoingLoopThread.Start(); this.pingLoopThread.Start(); }