private void comm_MessageReceived(object sender, MessageReceivedEventArgs e) { try { IMessageIndicationObject obj = e.IndicationObject; if (obj is MemoryLocation) { MemoryLocation loc = (MemoryLocation)obj; string logmsg = string.Format("New message received in storage \"{0}\", index {1}.", loc.Storage, loc.Index); logger(logmsg); DecodedShortMessage msg = comm.ReadMessage(loc.Index, loc.Storage); ShowMessage(msg.Data); return; } if (obj is ShortMessage) { ShortMessage msg = (ShortMessage)obj; SmsPdu pdu = comm.DecodeReceivedMessage(msg); logger("New message received:"); ShowMessage(pdu); return; } logger("Error: Unknown notification object!"); } catch (Exception ex) { ShowException(ex); } }
/// <summary> /// Handles an unsolicited message of the specified input string. /// </summary> /// <param name="input">The input string to handle, the unsolicited message will be removed</param> /// <param name="description">Receives a textual description of the message, may be empty</param> /// <returns>The message indication object generated from the message</returns> /// <exception cref="T:System.ArgumentException">Input string does not match any of the supported /// unsolicited messages</exception> public IMessageIndicationObject HandleUnsolicitedMessage(ref string input, out string description) { IMessageIndicationObject messageIndicationObject; List <MessageIndicationHandlers.UnsoMessage> .Enumerator enumerator = this.messages.GetEnumerator(); try { while (enumerator.MoveNext()) { MessageIndicationHandlers.UnsoMessage current = enumerator.Current; if (!current.IsMatch(input)) { continue; } IMessageIndicationObject messageIndicationObject1 = current.Handler(ref input); description = current.Description; messageIndicationObject = messageIndicationObject1; return(messageIndicationObject); } throw new ArgumentException("Input string does not match any of the supported unsolicited messages."); } finally { enumerator.Dispose(); } return(messageIndicationObject); }
private void comm_MessageReceived(object sender, MessageReceivedEventArgs e) { try { IMessageIndicationObject obj = e.IndicationObject; if (obj is MemoryLocation) { MemoryLocation loc = (MemoryLocation)obj; Output(string.Format("New message received in storage \"{0}\", index {1}.", loc.Storage, loc.Index)); Output(""); return; } if (obj is ShortMessage) { ShortMessage msg = (ShortMessage)obj; SmsPdu pdu = comm.DecodeReceivedMessage(msg); Output("New message received."); Output(""); ShowMessage(pdu); return; } Output("Error: Unknown notification object!"); } catch (Exception ex) { Output(ex.ToString()); } }
private void comm_MessageReceived(object sender, MessageReceivedEventArgs e) { IMessageIndicationObject obj = e.IndicationObject; MemoryLocation loc = (MemoryLocation)obj; DecodedShortMessage[] messages; messages = comm.ReadMessages(PhoneMessageStatus.ReceivedUnread, loc.Storage); foreach (DecodedShortMessage message in messages) { SmsDeliverPdu data = new SmsDeliverPdu(); SmsPdu smsrec = message.Data; ShowMessage(smsrec, message.Index); } }
private void comm_MessageReceived(object sender, MessageReceivedEventArgs e) { try { IMessageIndicationObject obj = e.IndicationObject; if (obj is ShortMessage) { ShortMessage msg = (ShortMessage)obj; SmsPdu pdu = comm.DecodeReceivedMessage(msg); ReceiveMessage(pdu); return; } MessageBox.Show("Error: Unknown notification object!"); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void comm_MessageReceived(object sender, MessageReceivedEventArgs e) { try { IMessageIndicationObject obj = e.IndicationObject; if (obj is GsmComm.GsmCommunication.ShortMessage) { GsmComm.GsmCommunication.ShortMessage msg = (GsmComm.GsmCommunication.ShortMessage)obj; SmsPdu pdu = comm.DecodeReceivedMessage(msg); } if (obj is MemoryLocation) { MemoryLocation loc = (MemoryLocation)obj; //statusBar1.Text = "New message received in storage "+loc.Storage + ", index " + loc.Index; } Read_message(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
/// <summary> /// Initializes a new instance of the class. /// </summary> /// <param name="obj">The object that indicates a new received message.</param> public MessageReceivedEventArgs(IMessageIndicationObject obj) { this.indicationObject = obj; }
private void OnMessageReceived(IMessageIndicationObject obj) { if (this.MessageReceived == null) { this.LogIt(LogLevel.Info, "No event handlers for MessageReceived event, message is ignored."); return; } else { this.LogIt(LogLevel.Info, "Firing async MessageReceived event."); MessageReceivedEventArgs messageReceivedEventArg = new MessageReceivedEventArgs(obj); this.MessageReceived.BeginInvoke(this, messageReceivedEventArg, new AsyncCallback(this.AsyncCallback), null); return; } }
/// <summary> /// Initializes a new instance of the class. /// </summary> /// <param name="obj">The object that indicates a new received message.</param> public MessageReceivedEventArgs(IMessageIndicationObject obj) { this.indicationObject = obj; }