public void HandleConnection(object state) { try { run = true; while (run) { byte[] b = new byte[800]; int k = socket.Receive(b); Console.WriteLine("Recieved..."); string message = ""; for (int i = 0; i < k; i++) message += Convert.ToChar(b[i]); messageStore += message; if (message == "/EOT") { messageStore=messageStore.Replace("/EOT", ""); BackupEventArgs eventArgs = new BackupEventArgs(); eventArgs.Message = messageStore; Message(this, eventArgs); messageStore = ""; } //Console.Write(message); /*ASCIIEncoding asen = new ASCIIEncoding(); socket.Send(asen.GetBytes("The string was recieved by the server.")); Console.WriteLine("\nSent Acknowledgement");*/ } } catch (Exception e) { Console.WriteLine("Error Client: Thread - " + e.StackTrace); stop(); } }
private void OnMessage(object sender, BackupEventArgs args) { SocketBackupTransportData data = ObjectSerializer.SerializeFromString<SocketBackupTransportData>(args.Message); if (data.Command == EnumSocketCommands.Command.FAST_BACKUP.ToString()) { Console.Out.WriteLine("-- Backup Job ("+ data.Date.ToString("ddMMyyy")+ ")--"); new BackupJob().GetDevicesForBackupByDate(data.Date); Console.Out.WriteLine("-- End Backup Job --"); } }