📄 callback_client.cpp
字号:
/////////////////////////////////////////////////////////////////////////////
// $Id: callback_client.cpp,v 1.1 2001/09/11 16:37:22 rosimildo Exp $
//
// Copyright (c) 2001 Exor International Inc. All rights reserved.
//
// MODULE DESCRIPTION: A simple "echo" example for eSoap.
//
// MODIFICATION/HISTORY:
//
// $Log: callback_client.cpp,v $
// Revision 1.1 2001/09/11 16:37:22 rosimildo
// added callback example
//
//
// Created 2001/09/10 Rosimildo da Silva, ConnectTel Inc.
// [rdasilva@connecttel.com]
//
/////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include "soap_server.h"
#include "uthread.h"
#include "Echo_proxy.h"
#include "EchoCallback_impl.h"
namespace echo {
void EchoCallback_Impl::callback( const int count )
{
printf( "EchoCallabck: client called back: %d\n", count );
}
}
#define ESOAP_SERVER_URL "http://localhost:8080/rpcrouter"
#define ESOAP_CLIENT_URL "http://localhost:9000/rpcrouter"
int main(int argc, char **argv)
{
// create the server instance, and initialize it.
esoap::ServerFactory::create( esoap::ServerFactory::ABYSS );
esoap::Server::instance()->init( "eSOAPServer", 9000, ".", 0, true );
// Create "Echo" instance, and register it with the server
echo::EchoCallback_Impl echo;
echo.activate();
// start the server...
esoap::Server::instance()->runAsThread();
echo::Echo_Proxy proxy( ESOAP_SERVER_URL, 30 );
try
{
printf( "Echo: Registering client....\n" );
esoap::String res = proxy.registerCallback( ESOAP_CLIENT_URL, 2000, 10 );
printf( "Echo: success, result = %s\n", res.c_str() );
printf( "Echo: main sleeping...\n" );
utils::Thread::sleep( 20000 );
proxy.deRegisterCallback( res );
printf( "Echo: main deregistration complete.\n" );
}
catch( esoap::SoapException & e )
{
printf( "SOAP Fault: Code=%s, String=%s\n",
e.getCode().c_str(), e.getString().c_str() );
}
catch( ... )
{
printf( "Weird C++ error. Please fix your code. :-)\n" );
}
// shutdown server.
echo.deactivate();
esoap::Server::setInstance( 0 );
// just to cleanup the memory...
delete esoap::ParameterFactory::setInstance( 0 );
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -