public void SendMessage() { try { RegisterMe(); ReceivedMessage = Send(null); if (ReceivedMessage != null && ReceivedMessage.Length <= 0) { ReceivedMessage = Receive(); } ReceivedModel = null; if (ReceivedMessage != null) { Parse(); ReceivedModel = _parser.Model; } if (ReceivedModel != null) { ProcessModel(); } } catch (Exception e) { WriteMessageProcessException(e, "Cannot process the message."); NotifyError(); } finally { if (MessageStream != null) { MessageStream.Close(); } UnregisterMe(); } }
public void ReceiveMessage() { try { RegisterMe(); if (ReceivedMessage == null || ReceivedMessage.Length <= 0) { ReceivedMessage = Receive(); } Parse(); ReceivedModel = _parser.Model; SentModel = ProcessModel(); if (SentModel != null) { Send(_parser); } else { SentMessage = null; } } catch (Exception e) { WriteMessageProcessException(e, "Cannot process the message."); NotifyError(); } finally { if (MessageStream != null) { MessageStream.Close(); } UnregisterMe(); } }