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; }
} // 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 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; }
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++; 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); }
/* 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); }