public bool SendResumeUpdate(string data) { try { // Send Request string response = SendData(socket, "ResumeUpdate", data); // Write to Log log.WriteLine($"Sent Resume Update"); // Close Socket CloseSocket(); } catch (ArgumentNullException ane) { // Write to Log log.WriteLine($"NetworkClient SendResumeUpdate: ArgumentNullException: {ane}"); } catch (SocketException) { // Write to Log log.WriteLine($"Sending Resume Update Failed"); // Create new RetryArgs RetryArgs args = new RetryArgs { // Set the RetryArgs Response Data data = data }; // Write to Log log.WriteLine($"Unable to contact Server, will retry later"); // Raise Response Event RetryEvent(this, args); // Return False to Indicate Failure return(false); } catch (Exception e) { // Write to Log log.WriteLine($"NetworkClient SendResumeUpdate: Unexpected Exception: {e}"); } // Return True to Indicate Success return(true); }
public bool SendResumeUpdate(string data) { try { // Encode the data string into a byte array. byte[] msg = Encoding.ASCII.GetBytes($"ResumeUpdate|{data}<EOF>"); // Send Data through Socket and Return Bytes Sent int sentBytes = socket.Send(msg); // Write to Log log.WriteLine($"Sent ResumeUpdate ({sentBytes} bytes) to Client ({clientAddress})"); // Response from Server string response = Receive(); } catch (SocketException) { // Write to Log log.WriteLine($"Sending Resume Update Failed"); // Create new Response Args RetryArgs args = new RetryArgs { // Set the StatusArgs Response Data clientAddress = clientAddress, data = data }; // Write to Log log.WriteLine($"Unable to contact Client ({clientAddress}), will retry later"); // Raise Response Event RetryEvent(this, args); // Return False to Indicate Failure return(false); } catch (Exception e) { // Write to Log log.WriteLine($"NetworkClient SendResumeUpdate: Unexpected Exception: {e}"); } // Return True to Indicate Success return(true); }