@@ -80,36 +80,15 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
80
80
Swift::XMPPParser *m_xmppParser;
81
81
Swift::FullPayloadParserFactoryCollection m_collection2;
82
82
83
- SwiftenPlugin (Config *config, Swift::SimpleEventLoop *loop, const std::string &host, int port) : NetworkPlugin() {
83
+ SwiftenPlugin (Config *config, const std::string &host, int port) : NetworkPlugin() {
84
84
this ->config = config;
85
85
m_firstPing = true ;
86
- m_factories = new Swift::BoostNetworkFactories (loop);
87
- m_conn = m_factories->getConnectionFactory ()->createConnection ();
88
- m_conn->onDataRead .connect (boost::bind (&SwiftenPlugin::_handleDataRead, this , _1));
89
- m_conn->connect (Swift::HostAddressPort (*(Swift::HostAddress::fromString (host)), port));
90
86
serializer = new Swift::XMPPSerializer (&collection, Swift::ClientStreamType, false );
91
87
m_xmppParser = new Swift::XMPPParser (this , &m_collection2, m_factories->getXMLParserFactory ());
92
88
m_xmppParser->parse (" <stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' to='localhost' version='1.0'>" );
93
89
94
90
LOG4CXX_INFO (logger, " Starting the plugin." );
95
- }
96
-
97
- // NetworkPlugin uses this method to send the data to networkplugin server
98
- void sendData (const std::string &string) {
99
- m_conn->write (Swift::createSafeByteArray (string));
100
- }
101
-
102
- // This method has to call handleDataRead with all received data from network plugin server
103
- void _handleDataRead (std::shared_ptr<Swift::SafeByteArray> data) {
104
- if (m_firstPing) {
105
- m_firstPing = false ;
106
- NetworkPlugin::PluginConfig cfg;
107
- cfg.setRawXML (true );
108
- cfg.setNeedRegistration (false );
109
- sendConfig (cfg);
110
- }
111
- std::string d (data->begin (), data->end ());
112
- handleDataRead (d);
91
+ connect (host, std::to_string (port));
113
92
}
114
93
115
94
void handleStreamStart (const Swift::ProtocolHeader&) {}
@@ -446,10 +425,7 @@ int main (int argc, char* argv[]) {
446
425
447
426
Logging::initBackendLogging (cfg);
448
427
449
- Swift::SimpleEventLoop eventLoop;
450
- loop_ = &eventLoop;
451
- np = new SwiftenPlugin (cfg, &eventLoop, host, port);
452
- loop_->run ();
428
+ np = new SwiftenPlugin (cfg, host, port);
453
429
454
430
return 0 ;
455
431
}
0 commit comments