本文整理汇总了C++中MessageHandler类的典型用法代码示例。如果您正苦于以下问题:C++ MessageHandler类的具体用法?C++ MessageHandler怎么用?C++ MessageHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MessageHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
void main()
{
string msg ="<Login><Name>Ider</Name></Login>";
MessageHandler mh;
Message snd = mh.RespondToMessage(msg,EndPoint());
cout<<snd.ToString()<<endl;
cout<<"Message type: "<<snd.Type()<<endl<<endl;
msg ="<Dependency><Name>*.*</Name></Dependency>";
snd = mh.RespondToMessage(msg,EndPoint());
cout<<snd.ToString()<<endl;
cout<<"Message type: "<<snd.Type()<<endl<<endl;
msg ="<Dependency><Name>Display</Name></Dependency>";
snd = mh.RespondToMessage(msg,EndPoint());
cout<<snd.ToString()<<endl;
cout<<"Message type: "<<snd.Type()<<endl<<endl;
msg ="*.*";
snd = mh.RespondToMessage(msg,EndPoint());
cout<<snd.ToString()<<endl;
cout<<"Message type: "<<snd.Type()<<endl<<endl;
}
示例2: validateXML
ErrorResult validateXML(const QString &fileName, const QString &schemaFileName)
{
QXmlSchema schema;
schema.load(QUrl(schemaFileName));
MessageHandler schemaMessageHandler;
schema.setMessageHandler(&schemaMessageHandler);
if (!schema.isValid())
return ErrorResult(ErrorResultType_Critical, QObject::tr("Schena '%1' is not valid. %2").
arg(schemaFileName).
arg(schemaMessageHandler.statusMessage()));
QFile file(fileName);
file.open(QIODevice::ReadOnly);
QXmlSchemaValidator validator(schema);
MessageHandler validatorMessageHandler;
validator.setMessageHandler(&validatorMessageHandler);
//TODO neslo mi nacist soubor se dvema poli
// if (!validator.validate(&file, QUrl::fromLocalFile(file.fileName())))
// return ErrorResult(ErrorResultType_Critical, QObject::tr("File '%1' is not valid Agros2D problem file. Error (line %3, column %4): %2").
// arg(fileName).
// arg(validatorMessageHandler.statusMessage()).
// arg(validatorMessageHandler.line()).
// arg(validatorMessageHandler.column()));
return ErrorResult();
}
示例3: registerHandler
bool MessageRouter::registerHandler(
MessageHandler& handler,
const bool& isDefaultHandler)
{
bool isRegistered = false;
// Find an empty slot and store the handler.
for (int i = 0; i < MAX_NUM_HANDLERS; i++)
{
if (handlers[i] == 0)
{
handlers[i] = &handler;
isRegistered = true;
break;
}
}
// Log a failure to register.
if (isRegistered == false)
{
Logger::logDebug("Failed to register handler " + handler.getId() + ".\n");
}
else
{
Logger::logDebug("Registered message handler " + handler.getId() + ".\n");
if (isDefaultHandler)
{
defaultHandler = &handler;
Logger::logDebug("Handler " + handler.getId() + " set as default handler.\n");
}
}
return (isRegistered);
}
示例4: validate
//! [3]
void MainWindow::validate()
{
const QByteArray schemaData = schemaView->toPlainText().toUtf8();
const QByteArray instanceData = instanceEdit->toPlainText().toUtf8();
MessageHandler messageHandler;
QXmlSchema schema;
schema.setMessageHandler(&messageHandler);
schema.load(schemaData);
bool errorOccurred = false;
if (!schema.isValid()) {
errorOccurred = true;
} else {
QXmlSchemaValidator validator(schema);
if (!validator.validate(instanceData))
errorOccurred = true;
}
if (errorOccurred) {
validationStatus->setText(messageHandler.statusMessage());
moveCursor(messageHandler.line(), messageHandler.column());
} else {
validationStatus->setText(tr("validation successful"));
}
const QString styleSheet = QString("QLabel {background: %1; padding: 3px}")
.arg(errorOccurred ? QColor(Qt::red).lighter(160).name() :
QColor(Qt::green).lighter(160).name());
validationStatus->setStyleSheet(styleSheet);
}
示例5: TEST
TEST(BalanceExecuteCommand, ByCategoryAndWallet)
{
// category specified by '-c' is not found
// set-up 1
createFile("testWalletFile" ,
"1447245226;-;500.00;categ;RON\n"
"1447245226;-;500.00;bam;RON\n"
"1447245226;-;500.00;categ;RON\n"
"1447245226;+;100.00;bam;RON\n"
"1448011815;+;20.00;salaros;RON\n");
BalanceCmd balance ;
vector <string> params ;
params.push_back("-c") ;
params.push_back("bam") ;
params.push_back("-w") ;
params.push_back("testWalletFile") ;
MessageHandler message ;
balance.setMessageHandler(message) ;
// test
EXPECT_EQ(true, balance.validateParams(params)) ;
EXPECT_EQ(true, balance.executeCommand(params)) ;
EXPECT_EQ(BALANCE_IS_MSG, message.getMessageCode()) ;
EXPECT_EQ("-400.00", params.at(0)) ;
// tear-down
remove("testWalletFile") ;
}
示例6: message_handler_callback
DBusHandlerResult MessageHandler::message_handler_callback(DBusConnection * conn, DBusMessage * message, void * user_data)
{
if ( user_data == NULL ) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
MessageHandler* handler = static_cast<MessageHandler*>(user_data);
return static_cast<DBusHandlerResult>(handler->handle_message( Connection::self(conn), Message::create(message) ));
}
示例7: routeMessage
void MessageRouter::routeMessage(Message* msg)
{
MessageHandler* msgHandler;
#ifdef DEBUG
std::cout << "MessageRouter::routeMessage( 0x" << std::hex << msg->getID() << std::dec << " )]" << std::endl;
#endif
/// Determine the Destination Address based on the MessageID
msgHandler = msgIDToMsgHandlerTable[msg->getID()];
msgHandler->addToQueue(msg);
}
示例8: kDebug
MessageHandlerChain::~MessageHandlerChain()
{
kDebug(14010) ;
MessageHandler *handler = d->first;
while( handler )
{
MessageHandler *next = handler->next();
delete handler;
handler = next;
}
delete d;
}
示例9: main
int main( int argc, char *argv[] ) {
QApplication app( argc, argv );
IRCClient *irc = new IRCClient();
MessageHandler *mh = new MessageHandler( irc );
QObject::connect( &app, SIGNAL( aboutToQuit() ), irc, SLOT( quit() ) );
mh->show();
irc->connectAndRegister( argc > 1 ? argv[1] : "dev1", 6667, argc > 2 ? argv[2] : "Test", "correlr", "Correl Roush" );
return app.exec();
}
示例10: ConstructL
void OpConsolePrefsHelper::ConstructL()
{
// Register as listener to relevant preferences
g_pccore->RegisterListenerL(this);
g_pcfiles->RegisterFilesListenerL(this);
// Register with the message handler
MessageHandler *mmh = g_main_message_handler;
mmh->SetCallBack(this, MSG_CONSOLE_RECONFIGURE, 0);
// Set up the logger later
mmh->PostMessage(MSG_CONSOLE_RECONFIGURE, 0, 0);
}
示例11: tr
void Fenetre::ouvrir()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Séléctionner un fichier"),
QDir::currentPath(),
tr("Fichiers XML (*.xml)"));
if (fileName.isEmpty())
return;
QFile fileXML(fileName);
if (!fileXML.open(QFile::ReadOnly | QFile::Text)) {
QMessageBox::warning(this, tr("Erreur lecture"),
tr("Impossible de lire le fichier %1:\n%2.")
.arg(fileName)
.arg(fileXML.errorString()));
return;
}
QFile fileSchema("schemaGraph.xsd");
fileSchema.open(QIODevice::ReadOnly);
QXmlSchema schema;
MessageHandler messageHandler;
schema.setMessageHandler(&messageHandler);
schema.load(&fileSchema, QUrl::fromLocalFile(fileSchema.fileName()));
if (schema.isValid()) {
QFile fileXML2(fileName);
fileXML2.open(QIODevice::ReadOnly);
QXmlSchemaValidator validator(schema);
if (!validator.validate(&fileXML2, QUrl::fromLocalFile(fileXML2.fileName()))){
QMessageBox::warning(this, tr("Fichier malformé"),
tr("Impossible d'ouvrir le fichier' %1'.\n Le document ne correspond pas au schéma. \n%2")
.arg(fileName)
.arg(messageHandler.statusMessage()));
return;
}
}
ImportExport import=ImportExport(&graphe,xmltree, affichageSVG);
if (import.ouvrir(&fileXML, &domDocument))
ui->statusBar->showMessage(tr("Fichier chargé"), 2000);
affichageSVG->drawGraph();
ui->afficheGraphe->adjustSize();
//On pense à remettre la liste des sommets pour créer les arcs
redessinerComboArc();
}
示例12: LOG4CXX_DEBUG
bool Narrator::hasAudio(const char *identifier, std::string encoding)
{
LOG4CXX_DEBUG(narratorLog, "Find audio with identifier: '" << identifier << "' and encoding '" << encoding << "'");
Message message;
message.setString(identifier);
message.setClass("userdata");
// use function in MessageHandler to find message
MessageHandler mh;
long id = mh.findMessage(message);
if (id > 0) return true;
LOG4CXX_DEBUG(narratorLog, "No entry found for identifier: '" << identifier << "'");
return false;
}
示例13: handleConn
/*
At first the arguments are read and passed. Then the ssl context is gotten
by calling 'BIO_get_ssl(client, &ssl)'. Afterwards the ssl handshake is
performed and the certificate verified. Then the line is read from the certificate.
This value is mapped to 'organizationalUnitName'.
An example usage of the connection is shown and then the connectino will be
terminated.
*/
void* handleConn(void *argsv){
connArgs* args = (connArgs*) argsv;
MessageHandler* msgHandler = args->msgHandler;
BIO* client = args->conn;
SSL* ssl;
BIO_get_ssl(client, &ssl);
/*ssl handshake*/
msgHandler->debug("performing ssl handshake");
if(BIO_do_handshake(client) != 1){
string fail("handshake failed\nSSL_ERROR: ");
fail.append(ERR_reason_error_string(ERR_get_error()));
msgHandler->log(fail);
} else
msgHandler->log("handshake successful");
/*verifying the certificate*/
X509* peerCert;
if(SSL_get_verify_result(ssl) != X509_V_OK){
string error("verification failed\nSSL_Error: ");
error.append(ERR_reason_error_string(ERR_get_error()));
msgHandler->error(error, CRITICAL);
} else {
msgHandler->debug("verification successful");
peerCert = SSL_get_peer_certificate(ssl);
}
msgHandler->debug("trying to get the line");
/*getting the line*/
char lineN[6];
X509_NAME* name = X509_get_subject_name(peerCert);
X509_NAME_get_text_by_NID(name, NID_organizationalUnitName, lineN, 6);
string line("line is: ");
line.append(lineN);
msgHandler->debug(line);
/*example use of the connection (echoing the incoming msg)*/
char buffer[1024];
bzero(buffer, 1024);
SSL_read(ssl, buffer, 1024);
string debug("message received: ");
debug.append(buffer);
msgHandler->debug(debug);
SSL_write(ssl, buffer, 1024);
/*closing the connection*/
BIO_reset(client);
X509_free(peerCert);
return NULL;
}
示例14: toString
void MessageRouter::handleMessages(
Adapter& adapter)
{
bool handledMessage = false;
// Get the first available message.
const Message* message = adapter.getMessage();
if (message)
{
Logger::logDebug("MessageRouter::handleMessages: Got message " + toString(message->getMessageId()) + ".\n");
}
while (message)
{
MessageHandler* handler = getHandler(message->getDestination());
if (!handler)
{
Logger::logDebug("Failed to handle message " + toString(message->getMessageId()) +
". No handler specified for destination \"" + message->getDestination() + "\"\n");
}
else
{
// Allow the handler to handle the message.
handledMessage = handler->handleMessage(*message);
if (!handledMessage)
{
Logger::logDebug("Component \"" + handler->getId() + "\" failed to handle message " +
toString(message->getMessageId()) + ". Unsupported message.\n");
}
}
// Free up the memory from the handled message.
delete message;
// Get the next available message.
message = adapter.getMessage();
if (message)
{
Logger::logDebug("MessageRouter::handleMessages: Got message " + toString(message->getMessageId()) + ".\n");
}
}
}
示例15: switch
void PrefsLoader::HandleCallback(OpMessage msg, MH_PARAM_1 par1, MH_PARAM_2 par2)
{
switch(msg)
{
case MSG_URL_LOADING_FAILED:
FinishLoading(par2);
break;
case MSG_URL_DATA_LOADED:
LoadData(par1);
break;
case MSG_URL_MOVED:
{
MessageHandler *mmh = g_main_message_handler;
mmh->UnsetCallBack(this, MSG_URL_DATA_LOADED);
mmh->UnsetCallBack(this, MSG_URL_LOADING_FAILED);
mmh->UnsetCallBack(this, MSG_URL_MOVED);
mmh->SetCallBack(this, MSG_URL_DATA_LOADED, par2);
mmh->SetCallBack(this, MSG_URL_LOADING_FAILED, par2);
mmh->SetCallBack(this, MSG_URL_MOVED, par2);
}
break;
}
}