public int onResponse(object cbArg, LBMRequest req, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_RESPONSE: response_count++; response_byte_count += msg.data().Length; if (_verbose > 0) { Console.Out.WriteLine("LBM.MSG_RESPONSE [" + msg.source() + "][" + msg.sequenceNumber() + "], " + msg.data().Length + " bytes"); if (_verbose > 1) { dump(msg); } } break; default: Console.Out.WriteLine("Unknown message type " + msg.type() + "[" + msg.source() + "]"); break; } msg.dispose(); Console.Out.Flush(); return(0); }
protected int onReceive(object cbArg, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_DATA: IntPtr messagePtr = msg.dataPointerSafe(); if (bufferAcquiredSize != msg.length()) { if (bufferAcquiredSize >= 0) { source.buffsCancel(); } // assume that the payload size is correctly checked on the pinger size bufferAcquiredSize = (source.buffAcquire(out bufferAcquired, (uint)msg.length(), 0) == 0) ? (int)msg.length() : -1; } #if RunUnsafeMode dqwordBlockCopy(bufferAcquired.ToPointer(), messagePtr.ToPointer(), (int)msg.length()); #else memcpy(bufferAcquired, messagePtr, (int)msg.length()); #endif source.buffsCompleteAndAcquire(out bufferAcquired, (uint)bufferAcquiredSize, 0); break; case LBM.MSG_BOS: System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); break; case LBM.MSG_UNRECOVERABLE_LOSS: System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], LOST"); /* Any kind of loss makes this test invalid */ System.Console.WriteLine("Unrecoverable loss occurred. Quitting..."); System.Environment.Exit(1); break; case LBM.MSG_UNRECOVERABLE_LOSS_BURST: System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], LOST BURST"); /* Any kind of loss makes this test invalid */ System.Console.WriteLine("Unrecoverable loss occurred. Quitting..."); System.Environment.Exit(1); break; default: System.Console.Out.WriteLine("Unhandled receiver event [" + msg.type() + "] from source [" + msg.source() + "] with topic [" + msg.topicName() + "]. Refer to https://ultramessaging.github.io/currdoc/doc/dotnet_example/index.html#unhandledcsevents for a detailed description."); break; } msg.dispose(); return(0); }
static int onReceive(Object cbArg, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_DATA: if((msg.flags() & LBM.MSG_FLAG_OTR)==LBM.MSG_FLAG_OTR) System.Console.Out.WriteLine("Processing OTR Message. SQN: " + msg.sequenceNumber()); else if((msg.flags() & LBM.MSG_FLAG_RETRANSMIT)==LBM.MSG_FLAG_RETRANSMIT) System.Console.Out.WriteLine("Processing Late Join Message. SQN: " + msg.sequenceNumber()); else System.Console.Out.WriteLine("Processing Normal Message. SQN: " + msg.sequenceNumber()); System.Console.Out.WriteLine("Msg Received: " + msg.dataString()); break; case LBM.MSG_BOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); break; default: System.Console.Out.WriteLine("Unknown lbm_msg_t type " + msg.type() + " [" + msg.topicName() + "][" + msg.source() + "]"); break; } System.Console.Out.Flush(); msg.dispose(); return 0; }
public int onReceive(Object cbArgs, LBMMessage theMessage) { /* There are several different events that can cause the * receiver callbackto be called. Decode the event that * caused this. */ switch (theMessage.type()) { case LBM.MSG_DATA: /* NOTE: Normally it would be a bad idea to do * something as slow as a print statement in the * callback function itself. In this example, we'll * probably only receive one message, so it doesn't * matter. */ System.Console.WriteLine( "Received " + theMessage.length() + " bytes on topic " + theMessage.topicName() + ": '" + System.Text.Encoding.GetEncoding("ISO-8859-1").GetString(theMessage.data()) + "'"); /* Increment the number of messages we've received.*/ messagesReceived++; break; case LBM.MSG_BOS: System.Console.WriteLine("[" + theMessage.topicName() + "][" + theMessage.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.WriteLine("[" + theMessage.topicName() + "][" + theMessage.source() + "], End of Transport Session"); break; default: System.Console.WriteLine("unexpected event: " + theMessage.type()); System.Environment.Exit(1); break; } theMessage.dispose(); /* * Return 0 if there were no errors. Returning a non-zero value will * cause LBM to log a generic error message. */ return(0); } /* onReceive */
} // Logger public int OnReceive(object cbArg, LBMMessage msg) { TmonConnection conn = (TmonConnection)msg.sourceClientObject(); if (conn != null) { conn.ReceiverEvent(msg); } switch (msg.type()) { case LBM.MSG_DATA: MyLog("app_rcv_callback: LBM_MSG_DATA: " + (long)msg.length() + " bytes on topic " + msg.topicName() + ":" + msg.dataString()); _messagesReceived++; break; case LBM.MSG_BOS: MyLog("app_rcv_callback: LBM_MSG_BOS: [" + msg.topicName() + "][" + msg.source() + "]"); break; case LBM.MSG_EOS: MyLog("app_rcv_callback: LBM_MSG_EOS: [" + msg.topicName() + "][" + msg.source() + "]"); _messagesReceived++; break; case LBM.MSG_UNRECOVERABLE_LOSS: MyLog("app_rcv_callback: LBM_MSG_UNRECOVERABLE_LOSS: [" + msg.topicName() + "][" + msg.source() + "]"); _messagesReceived++; break; case LBM.MSG_UNRECOVERABLE_LOSS_BURST: MyLog("app_rcv_callback: LBM_MSG_UNRECOVERABLE_LOSS_BURST: [" + msg.topicName() + "][" + msg.source() + "]"); _messagesReceived++; break; default: // Unexpected receiver event. MyLog("app_rcv_callback: default: [" + msg.topicName() + "][" + msg.source() + "], type=" + msg.type()); break; } // switch return(0); } // OnReceive
static int onReceiveImmediate(object cbArg, LBMMessage msg) { string nontopic_str = "Non-Topic Immediate Message"; switch (msg.type()) { case LBM.MSG_DATA: imsg_count++; imsg_byte_count += msg.data().Length; if (verbose) { System.Console.Out.Write("[" + nontopic_str + "][" + msg.source() + "][" + msg.sequenceNumber() + "], "); System.Console.Out.WriteLine(msg.data().Length + " bytes"); } break; case LBM.MSG_REQUEST: imsg_count++; imsg_byte_count += msg.data().Length; if (verbose) { System.Console.Out.Write("Request [" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], "); System.Console.Out.WriteLine(msg.data().Length + " bytes"); } break; default: System.Console.Out.WriteLine("Unknown lbm_msg_t type " + msg.type() + " [" + nontopic_str + "][" + msg.source() + "]"); break; } System.Console.Out.Flush(); return(0); }
static int onReceiveImmediate(object cbArg, LBMMessage msg) { string nontopic_str = "Non-Topic Immediate Message"; switch (msg.type()) { case LBM.MSG_DATA: imsg_count++; imsg_byte_count += msg.data().Length; if (verbose) { System.Console.Out.Write("[" + nontopic_str + "][" + msg.source() + "][" + msg.sequenceNumber() + "], "); System.Console.Out.WriteLine(msg.data().Length + " bytes"); } break; case LBM.MSG_REQUEST: imsg_count++; imsg_byte_count += msg.data().Length; if (verbose) { System.Console.Out.Write("Request [" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], "); System.Console.Out.WriteLine(msg.data().Length + " bytes"); } break; default: System.Console.Out.WriteLine("Unhandled receiver event [" + msg.type() + "] for immediate_msg from source [" + msg.source() + "] with topic [" + msg.topicName() + "]. Refer to https://ultramessaging.github.io/currdoc/doc/dotnet_example/index.html#unhandledcsevents for a detailed description."); break; } System.Console.Out.Flush(); return(0); }
public int onResponse(object cbArg, LBMRequest req, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_RESPONSE: response_count++; response_byte_count += msg.data().Length; if (_verbose > 0) { System.Console.Out.WriteLine("Response [" + msg.source() + "][" + msg.sequenceNumber() + "], " + msg.data().Length + " bytes"); if (_verbose > 1) { dump(msg); } } break; default: System.Console.Out.WriteLine("Unhandled receiver event [" + msg.type() + "] from source [" + msg.source() + "]. Refer to https://ultramessaging.github.io/currdoc/doc/dotnet_example/index.html#unhandledcsevents for a detailed description."); break; } msg.dispose(); System.Console.Out.Flush(); return(0); }
private int onResponse(object cbArg, LBMRequest req, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_RESPONSE: Console.Out.WriteLine("LBM.MSG_RESPONSE [" + msg.source() + "][" + msg.sequenceNumber() + "], " + msg.data().Length + " bytes"); break; default: Console.Out.WriteLine("Unknown message type " + msg.type() + "[" + msg.source() + "]"); break; } msg.dispose(); Console.Out.Flush(); return(0); }
private int LBMReceiverCallback(object cbArg, LBMMessage lbmMsg) { /* There are several different events that can cause the * receiver callbackto be called. Decode the event that * caused this. */ switch (lbmMsg.type()) { case LBM.MSG_DATA: /* NOTE: Normally it would be a bad idea to do * something as slow as a print statement in the * callback function itself. In this example, we'll * probably only receive one message, so it doesn't * matter. */ System.Console.WriteLine("Received " + lbmMsg.length() + " bytes on topic " + lbmMsg.topicName() + ": '" + Encoding.UTF8.GetString(lbmMsg.data()) + "'"); Thread.Sleep(10000); break; case LBM.MSG_BOS: System.Console.WriteLine("[" + lbmMsg.topicName() + "][" + lbmMsg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.WriteLine("[" + lbmMsg.topicName() + "][" + lbmMsg.source() + "], End of Transport Session"); break; default: System.Console.WriteLine("unexpected event: " + lbmMsg.type()); System.Environment.Exit(1); break; } lbmMsg.dispose(); /* * Return 0 if there were no errors. Returning a non-zero value will * cause LBM to log a generic error message. */ return(0); }
static int onReceive(Object cbArg, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_DATA: System.Console.Out.WriteLine("Msg Received: " + msg.dataString()); break; case LBM.MSG_BOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); break; default: System.Console.Out.WriteLine("Unknown lbm_msg_t type " + msg.type() + " [" + msg.topicName() + "][" + msg.source() + "]"); break; } System.Console.Out.Flush(); msg.dispose(); return 0; }
/* Class for receiving messages */ static int onReceive(Object cbArg, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_UME_REGISTRATION_SUCCESS_EX: UMERegistrationSuccessInfo reg = msg.registrationSuccessInfo(); System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "] store " + reg.storeIndex() + ": " + reg.store() + " UME registration successful. Sequence number is " + reg.sequenceNumber()); break; case LBM.MSG_UME_REGISTRATION_COMPLETE_EX: UMERegistrationCompleteInfo regcomplete = msg.registrationCompleteInfo(); System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "] UME registration complete. SQN " + regcomplete.sequenceNumber() + ". Flags " + regcomplete.flags()); break; default: System.Console.Out.WriteLine("Other event, type=" + msg.type()); break; } return 0; }
} /* main */ /* Class for receiving messages */ static int onReceive(Object cbArg, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_UME_REGISTRATION_SUCCESS_EX: UMERegistrationSuccessInfo reg = msg.registrationSuccessInfo(); System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "] store " + reg.storeIndex() + ": " + reg.store() + " UME registration successful. Sequence number is " + reg.sequenceNumber()); break; case LBM.MSG_UME_REGISTRATION_COMPLETE_EX: UMERegistrationCompleteInfo regcomplete = msg.registrationCompleteInfo(); System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "] UME registration complete. SQN " + regcomplete.sequenceNumber() + ". Flags " + regcomplete.flags()); break; default: System.Console.Out.WriteLine("Other event, type=" + msg.type()); break; } return(0); }
static int onReceive(Object cbArg, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_DATA: if ((msg.flags() & LBM.MSG_FLAG_OTR) == LBM.MSG_FLAG_OTR) { System.Console.Out.WriteLine("Processing OTR Message. SQN: " + msg.sequenceNumber()); } else if ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) == LBM.MSG_FLAG_RETRANSMIT) { System.Console.Out.WriteLine("Processing Late Join Message. SQN: " + msg.sequenceNumber()); } else { System.Console.Out.WriteLine("Processing Normal Message. SQN: " + msg.sequenceNumber()); } System.Console.Out.WriteLine("Msg Received: " + msg.dataString()); break; case LBM.MSG_BOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); break; default: System.Console.Out.WriteLine("Unknown lbm_msg_t type " + msg.type() + " [" + msg.topicName() + "][" + msg.source() + "]"); break; } System.Console.Out.Flush(); msg.dispose(); return(0); }
static int onReceive(Object cbArg, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_DATA: System.Console.Out.WriteLine("Msg Received: " + msg.dataString()); break; case LBM.MSG_BOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); break; default: System.Console.Out.WriteLine("Unknown lbm_msg_t type " + msg.type() + " [" + msg.topicName() + "][" + msg.source() + "]"); break; } System.Console.Out.Flush(); msg.dispose(); return(0); }
public int onReceive(object cbArg, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_DATA: if (stotal_msg_count == 0) { data_start_time = Environment.TickCount; } else { data_end_time = Environment.TickCount; } msg_count++; total_msg_count++; stotal_msg_count++; subtotal_msg_count++; byte_count += msg.length(); total_byte_count += msg.length(); if ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0) { rx_msgs++; } if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0) { otr_msgs++; } if (_verbose) { Console.Write("[@{0}.{1:000000}]", msg.timestampSeconds(), msg.timestampMicroseconds()); if (msg.channelInfo() != null) { switch (msg.channelInfo().channelFlags()) { case LBM.MSG_FLAG_NUMBERED_CHANNEL: System.Console.Out.Write("[" + msg.topicName() + ":" + msg.channelInfo().channelNumber() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], "); break; default: break; } } else { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], "); } if ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0) { System.Console.Out.Write("-RX- "); } if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0) { System.Console.Out.Write("-OTR- "); } System.Console.Out.WriteLine(msg.data().Length + " bytes"); if (lbmhfxrcv.verifiable) { int rc = VerifiableMessage.verifyMessage(msg.data(), msg.data().Length, lbmhfxrcv.verbose); if (rc == 0) { System.Console.WriteLine("Message sqn " + msg.sequenceNumber() + " does not verify!"); } else if (rc == -1) { System.Console.Error.WriteLine("Message sqn " + msg.sequenceNumber() + " is not a verifiable message."); System.Console.Error.WriteLine("Use -V option on source and restart receiver."); } else { if (lbmhfxrcv.verbose) { System.Console.WriteLine("Message sqn " + msg.sequenceNumber() + " verfies"); } } } } break; case LBM.MSG_BOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: //data_end_time = System.DateTime.Now.Ticks; System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); if (_end_on_eos) { if (_summary) { print_summary(); } end(); } subtotal_msg_count = 0; break; case LBM.MSG_UNRECOVERABLE_LOSS: unrec_count++; total_unrec_count++; if (_verbose) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "],"); System.Console.Out.WriteLine(" LOST"); } break; case LBM.MSG_UNRECOVERABLE_LOSS_BURST: burst_loss++; if (_verbose) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "],"); System.Console.Out.WriteLine(" LOST BURST"); } break; case LBM.MSG_REQUEST: if (stotal_msg_count == 0) { data_start_time = Environment.TickCount; } else { data_end_time = Environment.TickCount; } msg_count++; stotal_msg_count++; subtotal_msg_count++; byte_count += msg.data().Length; total_byte_count += msg.data().Length; if (_verbose) { System.Console.Out.Write("Request [" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], "); System.Console.Out.WriteLine(msg.data().Length + " bytes"); } break; default: System.Console.Out.WriteLine("Unknown lbm_msg_t type " + msg.type() + " [" + msg.topicName() + "][" + msg.source() + "]"); break; } msg.dispose(); System.Console.Out.Flush(); return(0); }
protected int onReceive(object cbArg, LBMMessage msg) { bool promoted = false; switch (msg.type()) { case LBM.MSG_DATA: if (_verbose > 0) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], "); System.Console.Out.WriteLine(msg.data().Length + " bytes"); if (_verbose > 1) { dump(msg); } } break; case LBM.MSG_BOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); if (_end_on_eos) { end(); } break; case LBM.MSG_UNRECOVERABLE_LOSS: if (_verbose > 0) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "],"); System.Console.Out.WriteLine(" LOST"); } break; case LBM.MSG_UNRECOVERABLE_LOSS_BURST: if (_verbose > 0) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "],"); System.Console.Out.WriteLine(" LOST BURST"); } break; case LBM.MSG_REQUEST: request_count++; bool skipped = request != null; if (_verbose > 0) { System.Console.Out.Write("Request [" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], "); System.Console.Out.WriteLine(msg.data().Length + " bytes" + (skipped ? " (ignored)" : "")); if (_verbose > 1) { dump(msg); } } if (!skipped) { request = msg; promoted = true; } break; default: System.Console.Out.WriteLine("Unhandled receiver event [" + msg.type() + "] from source [" + msg.source() + "] with topic [" + msg.topicName() + "]. Refer to https://ultramessaging.github.io/currdoc/doc/dotnet_example/index.html#unhandledcsevents for a detailed description."); break; } if (!promoted) { msg.dispose(); } System.Console.Out.Flush(); return(0); }
protected int onReceive(object cbArg, LBMMessage msg) { long t; if (_ping) { t = System.Diagnostics.Stopwatch.GetTimestamp() * lbmpong.pspertick / 1000; } else { t = 0; } switch (msg.type()) { case LBM.MSG_DATA: if (rtt_ignore == 0) { _msg_count++; } byte[] message = null; IntPtr messagePtr = (IntPtr)0; long s = 0; if (use_smx) { messagePtr = msg.dataPointerSafe(); } else { message = msg.data(); } if (_ping) { s = (use_smx) ? lbmpong.parse_s(messagePtr, 0) : lbmpong.parse_s(message, 0); calc_latency(t, s); if (rtt_ignore == 0 && _msg_count == _msgs) { rtt_avg_usec = ((double)total_nsec / 1000.0) / (double)_msg_count; print_rtt_data(); print_latency(System.Console.Out); try { print_stats(); } catch (LBMException ex) { System.Console.Error.WriteLine("Error printing transport stats in ponglbmreceiver" + ex.Message); } end(); msg.dispose(); return(0); } if (_msecpause > 0) { // This would not normally be a good // thing in a callback on the context // thread. System.Threading.Thread.Sleep(_msecpause); } if (!use_smx) { lbmpong.format(message, 0, System.Diagnostics.Stopwatch.GetTimestamp() * lbmpong.pspertick / 1000); } } if (use_mim) { _ctx.send(_ping ? "lbmpong/ping" : "lbmpong/pong", message, message.Length, LBM.MSG_FLUSH | LBM.SRC_NONBLOCK); } else if (use_smx) { try { IntPtr writeBuff; if (_src.buffAcquire(out writeBuff, (uint)msg.length(), 0) == 0) { if (_ping) { lbmpong.format(writeBuff, 0, System.Diagnostics.Stopwatch.GetTimestamp() * lbmpong.pspertick / 1000); } else { memcpy(writeBuff, messagePtr, (int)msg.length()); } _src.buffsComplete(); } } catch (LBMException ex) { System.Console.Error.WriteLine("Error (while doing SMX acquire/complete): " + ex.Message); System.Environment.Exit(1); } } else { _src.send(message, message.Length, LBM.MSG_FLUSH | LBM.SRC_NONBLOCK); } if (_ping && _verbose) { System.Console.Out.WriteLine(_msg_count + " curr " + t + " sent " + s + " latency " + (t - s) + " ns"); } if (rtt_ignore > 0) { rtt_ignore--; } break; case LBM.MSG_BOS: System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); if (_end_on_eos) { end(); } break; case LBM.MSG_UNRECOVERABLE_LOSS: if (_verbose) { System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], LOST"); } /* Any kind of loss makes this test invalid */ System.Console.WriteLine("Unrecoverable loss occurred. Quitting..."); System.Environment.Exit(1); break; case LBM.MSG_UNRECOVERABLE_LOSS_BURST: System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], LOST BURST"); /* Any kind of loss makes this test invalid */ System.Console.WriteLine("Unrecoverable loss occurred. Quitting..."); System.Environment.Exit(1); break; default: System.Console.Out.WriteLine("Unhandled receiver event [" + msg.type() + "] from source [" + msg.source() + "] with topic [" + msg.topicName() + "]. Refer to https://ultramessaging.github.io/currdoc/doc/dotnet_example/index.html#unhandledcsevents for a detailed description."); break; } msg.dispose(); System.Console.Out.Flush(); return(0); }
/* Class for receiving messages */ static int onReceive(Object cbArg, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_DATA: System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "]"); if ((msg.flags() & LBM.MSG_FLAG_UME_RETRANSMIT) != 0) { System.Console.Out.Write("-RX-"); } if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0) { System.Console.Out.Write("-OTR-"); } System.Console.Out.Write(", "); System.Console.Out.WriteLine(msg.data().Length + " bytes"); break; case LBM.MSG_REQUEST: if ((msg.flags() & LBM.MSG_FLAG_UME_RETRANSMIT) != 0) { System.Console.Out.Write("-RX-"); } if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0) { System.Console.Out.Write("-OTR-"); } System.Console.Out.Write(", "); System.Console.Out.WriteLine(msg.data().Length + " bytes"); break; case LBM.MSG_BOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); break; case LBM.MSG_UNRECOVERABLE_LOSS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber().ToString("x") + "], LOST"); break; case LBM.MSG_UNRECOVERABLE_LOSS_BURST: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber().ToString("x") + "], LOST BURST"); break; case LBM.MSG_UME_REGISTRATION_ERROR: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "] UME registration error: " + msg.dataString()); break; case LBM.MSG_UME_REGISTRATION_SUCCESS_EX: UMERegistrationSuccessInfo reg = msg.registrationSuccessInfo(); System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "] store " + reg.storeIndex() + ": " + reg.store() + " UME registration successful. Sequence number is " + reg.sequenceNumber()); break; case LBM.MSG_UME_REGISTRATION_COMPLETE_EX: UMERegistrationCompleteInfo regcomplete = msg.registrationCompleteInfo(); System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "] UME registration complete. SQN " + regcomplete.sequenceNumber() + ". Flags " + regcomplete.flags()); break; case LBM.MSG_UME_DEREGISTRATION_SUCCESS_EX: System.Console.Out.Write("DEREGISTRATION SUCCESSFUL "); UMEDeregistrationSuccessInfo dereg = msg.deregistrationSuccessInfo(); System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "] store " + dereg.storeIndex() + ": " + dereg.store() + " UME deregistration successful. SrcRegID " + dereg.sourceRegistrationId() + " RcvRegID " + dereg.receiverRegistrationId() + ". Flags " + dereg.flags() + " "); System.Console.Out.WriteLine(); break; case LBM.MSG_UME_DEREGISTRATION_COMPLETE_EX: System.Console.Out.WriteLine("DEREGISTRATION COMPLETE"); break; case LBM.MSG_UME_REGISTRATION_CHANGE: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "] UME registration change: " + msg.dataString()); break; default: System.Console.Out.WriteLine("Other event, type=" + msg.type()); break; } return 0; }
} /* main */ /* Class for receiving messages */ static int onReceive(Object cbArg, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_DATA: System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "]"); if ((msg.flags() & LBM.MSG_FLAG_UME_RETRANSMIT) != 0) { System.Console.Out.Write("-RX-"); } if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0) { System.Console.Out.Write("-OTR-"); } System.Console.Out.Write(", "); System.Console.Out.WriteLine(msg.data().Length + " bytes"); break; case LBM.MSG_REQUEST: if ((msg.flags() & LBM.MSG_FLAG_UME_RETRANSMIT) != 0) { System.Console.Out.Write("-RX-"); } if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0) { System.Console.Out.Write("-OTR-"); } System.Console.Out.Write(", "); System.Console.Out.WriteLine(msg.data().Length + " bytes"); break; case LBM.MSG_BOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); break; case LBM.MSG_UNRECOVERABLE_LOSS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber().ToString("x") + "], LOST"); break; case LBM.MSG_UNRECOVERABLE_LOSS_BURST: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber().ToString("x") + "], LOST BURST"); break; case LBM.MSG_UME_REGISTRATION_ERROR: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "] UME registration error: " + msg.dataString()); break; case LBM.MSG_UME_REGISTRATION_SUCCESS_EX: UMERegistrationSuccessInfo reg = msg.registrationSuccessInfo(); System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "] store " + reg.storeIndex() + ": " + reg.store() + " UME registration successful. Sequence number is " + reg.sequenceNumber()); break; case LBM.MSG_UME_REGISTRATION_COMPLETE_EX: UMERegistrationCompleteInfo regcomplete = msg.registrationCompleteInfo(); System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "] UME registration complete. SQN " + regcomplete.sequenceNumber() + ". Flags " + regcomplete.flags()); break; case LBM.MSG_UME_DEREGISTRATION_SUCCESS_EX: System.Console.Out.Write("DEREGISTRATION SUCCESSFUL "); UMEDeregistrationSuccessInfo dereg = msg.deregistrationSuccessInfo(); System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "] store " + dereg.storeIndex() + ": " + dereg.store() + " UME deregistration successful. SrcRegID " + dereg.sourceRegistrationId() + " RcvRegID " + dereg.receiverRegistrationId() + ". Flags " + dereg.flags() + " "); System.Console.Out.WriteLine(); break; case LBM.MSG_UME_DEREGISTRATION_COMPLETE_EX: System.Console.Out.WriteLine("DEREGISTRATION COMPLETE"); break; case LBM.MSG_UME_REGISTRATION_CHANGE: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "] UME registration change: " + msg.dataString()); break; default: System.Console.Out.WriteLine("Other event, type=" + msg.type()); break; } return(0); }
public int onReceive(object cbArg, LBMMessage msg) { // keep the sqn of a regular or hot failover sequence UInt64 sqn = (UInt64)msg.sequenceNumber(); if (_verbose) { if ((msg.flags() & LBM.MSG_FLAG_HF_64) > 0) { sqn = msg.hfSequenceNumber64(); } else if ((msg.flags() & LBM.MSG_FLAG_HF_32) > 0) { sqn = (UInt64)msg.hfSequenceNumber32(); } } switch (msg.type()) { case LBM.MSG_DATA: msg_count++; total_msg_count++; subtotal_msg_count++; byte_count += msg.length(); if ((total_msg_count == 100) && (_dereg == 1)) { _wrcvr.umederegister(); _dereg = 0; } if ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0) { rx_msgs++; } if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0) { otr_msgs++; } if (_verbose) { if (msg.channelInfo() != null) { Console.WriteLine("@{0}.{1:000000}[{2}{3}][{4}][{5}]{6}{7}{8}{9}{10}{11}{12}, {13} bytes", msg.timestampSeconds(), msg.timestampMicroseconds(), msg.topicName(), String.Empty, msg.source(), sqn, ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0 ? "-RX" : String.Empty), ((msg.flags() & LBM.MSG_FLAG_OTR) != 0 ? "-OTR" : String.Empty), ((msg.flags() & LBM.MSG_FLAG_HF_64) != 0 ? "-HF64" : String.Empty), ((msg.flags() & LBM.MSG_FLAG_HF_32) != 0 ? "-HF32" : String.Empty), ((msg.flags() & LBM.MSG_FLAG_HF_DUPLICATE) != 0 ? "-HFDUP" : String.Empty), ((msg.flags() & LBM.MSG_FLAG_HF_PASS_THROUGH) != 0 ? "-PASS" : String.Empty), ((msg.flags() & LBM.MSG_FLAG_HF_OPTIONAL) != 0 ? "-HFOPT" : String.Empty), msg.length()); } } break; case LBM.MSG_BOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); if (_end_on_eos) { end(); } subtotal_msg_count = 0; break; case LBM.MSG_UNRECOVERABLE_LOSS: unrec_count++; total_unrec_count++; if (_verbose) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + sqn + "],"); System.Console.Out.WriteLine(" LOST"); } break; case LBM.MSG_UNRECOVERABLE_LOSS_BURST: burst_loss++; if (_verbose) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + sqn + "],"); System.Console.Out.WriteLine(" LOST BURST"); } break; case LBM.MSG_REQUEST: msg_count++; total_msg_count++; subtotal_msg_count++; byte_count += msg.length(); if (_verbose) { System.Console.Out.Write("Request [" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], "); System.Console.Out.WriteLine(msg.length() + " bytes"); } break; case LBM.MSG_NO_SOURCE_NOTIFICATION: System.Console.Out.WriteLine("[" + msg.topicName() + "], no sources found for topic"); break; case LBM.MSG_UME_DEREGISTRATION_SUCCESS_EX: System.Console.Out.Write("Received MSG_UME_DEREGISTRATION_SUCCESS_EX\n"); break; case LBM.MSG_UME_DEREGISTRATION_COMPLETE_EX: System.Console.Out.Write("Received MSG_UME_DEREGISTRATION_COMPLETE_EX\n"); break; default: System.Console.Out.WriteLine("Unhandled receiver event [" + msg.type() + "] from source [" + msg.source() + "] with topic [" + msg.topicName() + "]. Refer to https://ultramessaging.github.io/currdoc/doc/dotnet_example/index.html#unhandledcsevents for a detailed description."); break; } msg.dispose(); System.Console.Out.Flush(); return(0); }
protected int onReceive(object cbArg, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_DATA: if (msg_count == 0) { saved_source = msg.source(); } msg_count++; total_msg_count++; subtotal_msg_count++; byte_count += msg.data().Length; if ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0) { rx_msgs++; } if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0) { otr_msgs++; } if (_verbose) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], "); if ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0) { System.Console.Out.Write("-RX- "); } if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0) { System.Console.Out.Write("-OTR- "); } System.Console.Out.WriteLine(msg.data().Length + " bytes"); } break; case LBM.MSG_BOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); subtotal_msg_count = 0; break; case LBM.MSG_NO_SOURCE_NOTIFICATION: if (_verbose) { System.Console.Out.WriteLine("[" + msg.topicName() + "], no sources found for topic"); } break; case LBM.MSG_UNRECOVERABLE_LOSS: unrec_count++; total_unrec_count++; if (_verbose) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "],"); System.Console.Out.WriteLine(" LOST"); } break; case LBM.MSG_UNRECOVERABLE_LOSS_BURST: burst_loss++; if (_verbose) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "],"); System.Console.Out.WriteLine(" LOST BURST"); } break; case LBM.MSG_REQUEST: msg_count++; total_msg_count++; subtotal_msg_count++; byte_count += msg.data().Length; if (_verbose) { System.Console.Out.Write("Request [" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], "); System.Console.Out.WriteLine(msg.data().Length + " bytes"); } break; default: System.Console.Out.WriteLine("Unhandled receiver event [" + msg.type() + "] from source [" + msg.source() + "] with topic [" + msg.topicName() + "]. Refer to https://ultramessaging.github.io/currdoc/doc/dotnet_example/index.html#unhandledcsevents for a detailed description."); break; } System.Console.Out.Flush(); msg.dispose(); return(0); }
protected int onReceive(object cbArg, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_DATA: try { if (++bounce_count < NUM_ROUNDTRIPS_PER_MSG) { // Bounce the message -- no need to size check IntPtr messagePtr = msg.dataPointerSafe(); #if RunUnsafeMode dqwordBlockCopy(bufferAcquired.ToPointer(), messagePtr.ToPointer(), (int)msg.length()); #else memcpy(bufferAcquired, messagePtr, (int)msg.length()); #endif source.buffsCompleteAndAcquire(out bufferAcquired, (uint)buffer.Length, 0); } else { tsend[rcvd_msgs] = getTicks(); bounce_count = 0; if (rcvd_msgs > lbmlatping.NUM_MSGS) { // still doing statistics report (throw away the extraneous message) break; } if (latping.usBusyWaitPause > 0) { // Busy wait for at least requested microseconds. long tstarget = tsend[rcvd_msgs] + nanosToTicks(latping.usBusyWaitPause * 1000); while (tstarget > getTicks()) { ; } } tsstart[rcvd_msgs + 1] = getTicks(); #if RunUnsafeMode fixed(void *buff = buffer) { dqwordBlockCopy(bufferAcquired.ToPointer(), buff, buffer.Length); } #else memcpy(bufferAcquired, bufferptr, (int)buffer.Length); #endif source.buffsCompleteAndAcquire(out bufferAcquired, (uint)buffer.Length, 0); if (rcvd_msgs++ == lbmlatping.NUM_MSGS) { int i; double min = Double.MaxValue, max = 0; int max_idx = -1; double[] elapsed_ts = new double[lbmlatping.NUM_MSGS - lbmlatping.NUM_MSGS_IGNORED]; System.Console.Out.WriteLine("Successfully sent & received " + lbmlatping.NUM_MSGS + " total " + buffer.Length + "-byte messages, ignoring the first " + lbmlatping.NUM_MSGS_IGNORED + " messages."); System.Console.Out.WriteLine("Round-trip times in nanoseconds."); for (i = lbmlatping.NUM_MSGS_IGNORED; i < lbmlatping.NUM_MSGS; i++) { elapsed_ts[i - lbmlatping.NUM_MSGS_IGNORED] = ((double)ticksToNanos(tsend[i] - tsstart[i])) / NUM_ROUNDTRIPS_PER_MSG; if (elapsed_ts[i - lbmlatping.NUM_MSGS_IGNORED] < min) { min = elapsed_ts[i - lbmlatping.NUM_MSGS_IGNORED]; } else if (elapsed_ts[i - lbmlatping.NUM_MSGS_IGNORED] > max) { max = elapsed_ts[i - lbmlatping.NUM_MSGS_IGNORED]; max_idx = i - lbmlatping.NUM_MSGS_IGNORED; } } /* Now calculate some summary statistics. */ lbmStatistics stats = new lbmStatistics(); Array.Sort(elapsed_ts); stats.calcSummaryStats(elapsed_ts); string output = String.Format("Min: {0:0.00}, Max {1:0.00}", min, max); System.Console.Out.WriteLine(output); output = String.Format("Mean: {0:0.00}, Median: {1:0.00}, Standard Dev: {2:0.00}", stats.mean, stats.data[stats.data.Length / 2], stats.sample_sd); System.Console.Out.WriteLine(output); output = String.Format("99.9%: {0:#.00}, 99%: {1:0.00}, 95%: {2:0.00}, 90%: {3:0.00}, 80%: {4:0.00}", stats.data[(stats.data.Length * 999) / 1000], stats.data[(stats.data.Length * 99) / 100], stats.data[(stats.data.Length * 95) / 100], stats.data[(stats.data.Length * 9) / 10], stats.data[(stats.data.Length * 8) / 10]); System.Console.Out.WriteLine(output); /* We're done. */ Environment.Exit(0); } } } catch (Exception e) { System.Console.Out.WriteLine(e.ToString()); } break; case LBM.MSG_BOS: System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); break; case LBM.MSG_UNRECOVERABLE_LOSS: System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], LOST"); /* Any kind of loss makes this test invalid */ System.Console.WriteLine("Unrecoverable loss occurred. Quitting..."); System.Environment.Exit(1); break; case LBM.MSG_UNRECOVERABLE_LOSS_BURST: System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], LOST BURST"); /* Any kind of loss makes this test invalid */ System.Console.WriteLine("Unrecoverable loss occurred. Quitting..."); System.Environment.Exit(1); break; default: System.Console.Out.WriteLine("Unhandled receiver event [" + msg.type() + "] from source [" + msg.source() + "] with topic [" + msg.topicName() + "]. Refer to https://ultramessaging.github.io/currdoc/doc/dotnet_example/index.html#unhandledcsevents for a detailed description."); break; } msg.dispose(); return(0); }
public int onReceive(object cbArg, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_DATA: if (stotal_msg_count == 0) { data_start_time = Environment.TickCount; } else { data_end_time = Environment.TickCount; } msg_count++; total_msg_count++; if ((total_msg_count == 100) && _dereg == 1) { System.Console.Out.WriteLine("Sending DEREGISTRATION\n"); System.Console.Out.Flush(); _lbmrcvr.umederegister(); } stotal_msg_count++; subtotal_msg_count++; byte_count += msg.data().Length; total_byte_count += msg.data().Length; if ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0) { rx_msgs++; } if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0) { otr_msgs++; } if (_verbose) { System.Console.Error.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "]"); if ((msg.flags() & LBM.MSG_FLAG_UME_RETRANSMIT) != 0) { System.Console.Error.Write("-RX-"); } if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0) { System.Console.Error.Write("-OTR-"); } System.Console.Error.Write(", "); System.Console.Error.WriteLine(msg.data().Length + " bytes"); } if (_exack > 0) { if ((msg.sequenceNumber() % _exack) == 0) { if (_verbose) { System.Console.Out.WriteLine(" Sending Explicit ACK"); } try { msg.sendExplicitAck(); } catch (Exception e) { System.Console.Error.WriteLine("msg.sendExplicitAck(): " + e.Message); } } } break; case LBM.MSG_BOS: System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); if (_end_on_eos) { if (_summary) { print_summary(); } end(); } subtotal_msg_count = 0; break; case LBM.MSG_UNRECOVERABLE_LOSS: unrec_count++; total_unrec_count++; if (_verbose) { System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber().ToString("x") + "], LOST"); } break; case LBM.MSG_UNRECOVERABLE_LOSS_BURST: burst_loss++; if (_verbose) { System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], LOST BURST"); } break; case LBM.MSG_REQUEST: if (stotal_msg_count == 0) { data_start_time = Environment.TickCount; } else { data_end_time = Environment.TickCount; } msg_count++; stotal_msg_count++; subtotal_msg_count++; byte_count += msg.data().Length; total_byte_count += msg.data().Length; break; case LBM.MSG_UME_REGISTRATION_ERROR: System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "] UME registration error: " + msg.dataString()); break; case LBM.MSG_UME_DEREGISTRATION_SUCCESS_EX: System.Console.Out.Write("Received MSG_UME_DEREGISTRATION_SUCCESS_EX\n"); UMEDeregistrationSuccessInfo dereg = msg.deregistrationSuccessInfo(); System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "] store " + dereg.storeIndex() + ": " + dereg.store() + " UME registration successful. SrcRegID " + dereg.sourceRegistrationId() + " RcvRegID " + dereg.receiverRegistrationId() + ". Flags " + dereg.flags() + " "); if ((dereg.flags() & LBM.MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_OLD) != 0) { System.Console.Out.Write("OLD[SQN " + dereg.sequenceNumber() + "] "); } if ((dereg.flags() & LBM.MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_NOCACHE) != 0) { System.Console.Out.Write("NOCACHE "); } System.Console.Out.WriteLine(); break; case LBM.MSG_UME_DEREGISTRATION_COMPLETE_EX: System.Console.Out.Write("Received MSG_UME_DEREGISTRATION_COMPLETE_EX\n"); break; case LBM.MSG_UME_REGISTRATION_SUCCESS_EX: UMERegistrationSuccessInfo reg = msg.registrationSuccessInfo(); System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "] store " + reg.storeIndex() + ": " + reg.store() + " UME registration successful. SrcRegID " + reg.sourceRegistrationId() + " RcvRegID " + reg.receiverRegistrationId() + ". Flags " + reg.flags() + " "); if ((reg.flags() & LBM.MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_OLD) != 0) { System.Console.Out.Write("OLD[SQN " + reg.sequenceNumber() + "] "); } if ((reg.flags() & LBM.MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_NOCACHE) != 0) { System.Console.Out.Write("NOCACHE "); } if ((reg.flags() & LBM.MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_SRC_SID) != 0) { System.Console.Out.Write("Src Session ID 0x" + reg.sourceSessionId().ToString("x") + " "); } System.Console.Out.WriteLine(); break; case LBM.MSG_UME_REGISTRATION_COMPLETE_EX: UMERegistrationCompleteInfo regcomplete = msg.registrationCompleteInfo(); System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "] UME registration complete. SQN " + regcomplete.sequenceNumber() + ". Flags " + regcomplete.flags() + " "); if ((regcomplete.flags() & LBM.MSG_UME_REGISTRATION_COMPLETE_EX_FLAG_QUORUM) != 0) { System.Console.Out.Write("QUORUM "); } if ((regcomplete.flags() & LBM.MSG_UME_REGISTRATION_COMPLETE_EX_FLAG_RXREQMAX) != 0) { System.Console.Out.Write("RXREQMAX "); } if ((regcomplete.flags() & LBM.MSG_UME_REGISTRATION_COMPLETE_EX_FLAG_SRC_SID) != 0) { System.Console.Out.Write("Src Session ID 0x" + regcomplete.sourceSessionId().ToString("x") + " "); } System.Console.Out.WriteLine(); break; case LBM.MSG_UME_REGISTRATION_CHANGE: System.Console.Error.WriteLine("[" + msg.topicName() + "][" + msg.source() + "] UME registration change: " + msg.dataString()); break; default: System.Console.Out.WriteLine("Unhandled receiver event [" + msg.type() + "] from source [" + msg.source() + "] with topic [" + msg.topicName() + "]. Refer to https://ultramessaging.github.io/currdoc/doc/dotnet_example/index.html#unhandledcsevents for a detailed description."); break; } msg.dispose(); // Send ACK now System.Console.Out.Flush(); return(0); }
protected int onReceive(object cbArg, LBMMessage msg) { bool promoted = false; switch (msg.type()) { case LBM.MSG_DATA: if (_verbose > 0) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], "); System.Console.Out.WriteLine(msg.data().Length + " bytes"); if (_verbose > 1) { dump(msg); } } break; case LBM.MSG_BOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); if (_end_on_eos) { end(); } break; case LBM.MSG_UNRECOVERABLE_LOSS: if (_verbose > 0) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "],"); System.Console.Out.WriteLine(" LOST"); } break; case LBM.MSG_UNRECOVERABLE_LOSS_BURST: if (_verbose > 0) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "],"); System.Console.Out.WriteLine(" LOST BURST"); } break; case LBM.MSG_REQUEST: request_count++; bool skipped = request != null; if (_verbose > 0) { System.Console.Out.Write("Request [" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], "); System.Console.Out.WriteLine(msg.data().Length + " bytes" + (skipped ? " (ignored)" : "")); if (_verbose > 1) { dump(msg); } } if (!skipped) { request = msg; promoted = true; } break; default: System.Console.Out.WriteLine("Unknown lbm_msg_t type " + msg.type() + " [" + msg.topicName() + "][" + msg.source() + "]"); break; } if (!promoted) { msg.dispose(); } System.Console.Out.Flush(); return(0); }
public int onReceive(object cbArg, LBMMessage msg) { // keep the sqn of a regular or hot failover sequence UInt64 sqn = (UInt64)msg.sequenceNumber(); if (_verbose) { if ((msg.flags() & LBM.MSG_FLAG_HF_64) > 0) { sqn = msg.hfSequenceNumber64(); } else if ((msg.flags() & LBM.MSG_FLAG_HF_32) > 0) { sqn = (UInt64)msg.hfSequenceNumber32(); } } switch (msg.type()) { case LBM.MSG_DATA: if (stotal_msg_count == 0) { data_start_time = Environment.TickCount; } else { data_end_time = Environment.TickCount; } msg_count++; total_msg_count++; stotal_msg_count++; subtotal_msg_count++; byte_count += msg.length(); total_byte_count += msg.length(); if ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0) { rx_msgs++; } if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0) { otr_msgs++; } if (_verbose) { Console.WriteLine("@{0}.{1:000000}[{2}{3}][{4}][{5}]{6}{7}{8}{9}{10}{11}{12}, {13} bytes", msg.timestampSeconds(), msg.timestampMicroseconds(), msg.topicName(), String.Empty, msg.source(), sqn, ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0 ? "-RX" : String.Empty), ((msg.flags() & LBM.MSG_FLAG_HF_64) != 0 ? "-HF64" : String.Empty), ((msg.flags() & LBM.MSG_FLAG_HF_32) != 0 ? "-HF32" : String.Empty), ((msg.flags() & LBM.MSG_FLAG_HF_DUPLICATE) != 0 ? "-HFDUP" : String.Empty), ((msg.flags() & LBM.MSG_FLAG_HF_PASS_THROUGH) != 0 ? "-PASS" : String.Empty), ((msg.flags() & LBM.MSG_FLAG_HF_OPTIONAL) != 0 ? "-HFOPT" : String.Empty), ((msg.flags() & LBM.MSG_FLAG_OTR) != 0 ? "-OTR" : String.Empty), msg.length()); if (lbmrcv.verifiable) { int rc = VerifiableMessage.verifyMessage(msg.data(), msg.data().Length, lbmrcv.verbose); if (rc == 0) { System.Console.WriteLine("Message sqn " + sqn + " does not verify!"); } else if (rc == -1) { System.Console.Error.WriteLine("Message sqn " + sqn + " is not a verifiable message."); System.Console.Error.WriteLine("Use -V option on source and restart receiver."); } else { if (lbmrcv.verbose) { System.Console.WriteLine("Message sqn " + sqn + " verfies"); } } } else if (lbmrcv.sdm) { try { SDMsg.parse(msg.data()); LBMSDMField f = SDMsg.locate("Sequence Number"); long recvdseq = ((LBMSDMFieldInt64)f).get(); System.Console.Out.WriteLine("SDM Message contains " + SDMsg.count() + " fields and Field Sequence Number == " + recvdseq); } catch (LBMSDMException sdme) { System.Console.Out.WriteLine("Error occurred processing received SDM Message: " + sdme); } } } break; case LBM.MSG_BOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: //data_end_time = System.DateTime.Now.Ticks; System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); if (_end_on_eos) { if (_summary) { print_summary(); } end(); } subtotal_msg_count = 0; break; case LBM.MSG_UNRECOVERABLE_LOSS: unrec_count++; total_unrec_count++; if (_verbose) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + sqn + "],"); System.Console.Out.WriteLine(" LOST"); } break; case LBM.MSG_UNRECOVERABLE_LOSS_BURST: burst_loss++; if (_verbose) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + sqn + "],"); System.Console.Out.WriteLine(" LOST BURST"); } break; case LBM.MSG_REQUEST: if (stotal_msg_count == 0) { data_start_time = Environment.TickCount; } else { data_end_time = Environment.TickCount; } msg_count++; stotal_msg_count++; subtotal_msg_count++; byte_count += msg.data().Length; total_byte_count += msg.data().Length; if (_verbose) { System.Console.Out.Write("Request [" + msg.topicName() + "][" + msg.source() + "][" + sqn + "], "); System.Console.Out.WriteLine(msg.data().Length + " bytes"); } break; case LBM.MSG_HF_RESET: if (_verbose) { Console.WriteLine("[{0}][{1}][{2}]{3}{4}{5}{6}-RESET\n", msg.topicName(), msg.source(), sqn, ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0 ? "-RX" : String.Empty), ((msg.flags() & LBM.MSG_FLAG_OTR) != 0 ? "-OTR" : String.Empty), ((msg.flags() & LBM.MSG_FLAG_HF_64) != 0 ? "-HF64" : String.Empty), ((msg.flags() & LBM.MSG_FLAG_HF_32) != 0 ? "-HF32" : String.Empty)); } break; default: System.Console.Out.WriteLine("Unknown lbm_msg_t type " + msg.type() + " [" + msg.topicName() + "][" + msg.source() + "]"); break; } msg.dispose(); return(0); }
protected int onReceive(object cbArg, LBMMessage msg) { switch (msg.type()) { case LBM.MSG_DATA: if (msg_count == 0) { saved_source = msg.source(); } msg_count++; total_msg_count++; subtotal_msg_count++; byte_count += msg.data().Length; if ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0) { rx_msgs++; } if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0) { otr_msgs++; } if (_verbose) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], "); if ((msg.flags() & LBM.MSG_FLAG_RETRANSMIT) != 0) { System.Console.Out.Write("-RX- "); } if ((msg.flags() & LBM.MSG_FLAG_OTR) != 0) { System.Console.Out.Write("-OTR- "); } System.Console.Out.WriteLine(msg.data().Length + " bytes"); } break; case LBM.MSG_BOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], Beginning of Transport Session"); break; case LBM.MSG_EOS: System.Console.Out.WriteLine("[" + msg.topicName() + "][" + msg.source() + "], End of Transport Session"); subtotal_msg_count = 0; break; case LBM.MSG_NO_SOURCE_NOTIFICATION: if (_verbose) { System.Console.Out.WriteLine("[" + msg.topicName() + "], no sources found for topic"); } break; case LBM.MSG_UNRECOVERABLE_LOSS: unrec_count++; total_unrec_count++; if (_verbose) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "],"); System.Console.Out.WriteLine(" LOST"); } break; case LBM.MSG_UNRECOVERABLE_LOSS_BURST: burst_loss++; if (_verbose) { System.Console.Out.Write("[" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "],"); System.Console.Out.WriteLine(" LOST BURST"); } break; case LBM.MSG_REQUEST: msg_count++; total_msg_count++; subtotal_msg_count++; byte_count += msg.data().Length; if (_verbose) { System.Console.Out.Write("Request [" + msg.topicName() + "][" + msg.source() + "][" + msg.sequenceNumber() + "], "); System.Console.Out.WriteLine(msg.data().Length + " bytes"); } break; default: System.Console.Out.WriteLine("Unknown lbm_msg_t type " + msg.type() + " [" + msg.topicName() + "][" + msg.source() + "]"); break; } System.Console.Out.Flush(); msg.dispose(); return(0); }