private bool HandleUnsolicitedMessages(ref string bigInput) { string str = null; MessageIndicationHandlers messageIndicationHandler = new MessageIndicationHandlers(); if (!messageIndicationHandler.IsUnsolicitedMessage(bigInput)) { return false; } else { this.LogItShow(LogLevel.Verbose, bigInput, ">> "); IMessageIndicationObject messageIndicationObject = messageIndicationHandler.HandleUnsolicitedMessage(ref bigInput, out str); this.LogIt(LogLevel.Info, string.Concat("Unsolicited message: ", str)); this.OnMessageReceived(messageIndicationObject); return true; } }
private bool CommThreadReceive() { bool flag; string str = null; this.receiveNow.Reset(); this.noData.Reset(); bool flag1 = false; MessageIndicationHandlers messageIndicationHandler = new MessageIndicationHandlers(); StringBuilder stringBuilder = new StringBuilder(); do { flag = false; try { if (this.ReceiveInternal(out str)) { stringBuilder.Append(str); flag = true; } } catch (Exception exception1) { Exception exception = exception1; this.LogIt(LogLevel.Error, "Error while receiving data from the phone."); this.LogIt(LogLevel.Error, "Error details:"); this.LogIt(LogLevel.Error, exception.ToString()); stringBuilder = new StringBuilder(); flag = false; break; } try { if (!flag && messageIndicationHandler.IsIncompleteUnsolicitedMessage(stringBuilder.ToString())) { this.LogIt(LogLevel.Info, "Incomplete unsolicited message found, reading on after sleep."); Thread.Sleep(this.timeout); flag = true; } } catch (Exception exception3) { Exception exception2 = exception3; this.LogIt(LogLevel.Error, "Error while checking received data for unsolicited messages."); this.LogIt(LogLevel.Error, "Received data was:"); this.LogItShow(LogLevel.Error, stringBuilder.ToString(), ">> "); this.LogIt(LogLevel.Error, "This data will not be processed further."); this.LogIt(LogLevel.Error, "Error details:"); this.LogIt(LogLevel.Error, exception2.ToString()); stringBuilder = new StringBuilder(); flag = false; } } while (flag); if (stringBuilder.Length <= 0) { this.noData.Set(); flag1 = false; } else { this.inputQueue.Enqueue(stringBuilder.ToString()); string str1 = this.MakeQueueString(this.inputQueue); if (this.HandleUnsolicitedMessages(ref str1)) { this.inputQueue.Clear(); this.inputQueue.Enqueue(str1); } this.dataReceived.Set(); flag1 = true; } return flag1; }
public UnsoMessage(string pattern, MessageIndicationHandlers.UnsoHandler handler) { this.pattern = pattern; this.startPattern = pattern; this.description = string.Empty; this.handler = handler; this.completeChecker = null; }