/// <summary> The onMessage method is called by the UMDS client code. Application /// logic should be added within this method for processing each message. /// /// This message is called from the UMDS client thread processing the /// socket. Blocking or complex code in this function can prevent the /// socket from being processed. Ensure that application logic is kept to /// a minimum, and hands off the received message to an application /// thread. /// </summary> public override void onMessage(UMDSMessage msg) { /* Count this message and the number of bytes received */ interval_msg_count++; if (msg.appdata != null) { interval_byte_count += msg.length(); } if (msg.recovered) { total_rxmsg_count++; } /* * If the verbose option was used, dump data about the message. * Assume the message begins with text */ if (verbose) { System.Console.Out.WriteLine(rcvnum + ": Yahoo! Received Data Message of Length " + msg.length() + " Sequence Number " + msg.seqnum + " source " + msg.srcidx + " topic " + msg.topic + " src_session_id " + msg.source_session_id + (msg.recovered?" -RX-":"")); // Find the first 0 byte and create a string with the text if (msg.appdata.Length > 0) { int zero; for (zero = 0; zero < msg.appdata.Length && msg.appdata[zero] != 0; zero++) { ; } char [] appbs = new char[zero]; for (zero = 0; zero < msg.appdata.Length && msg.appdata[zero] != 0; zero++) { appbs[zero] = (char)msg.appdata[zero]; } System.String appstr = new System.String(appbs); System.Console.Out.WriteLine(appstr); } } }