|
|
@ -9,8 +9,8 @@ using namespace MW; |
|
|
|
MWMap* |
|
|
|
MWMap::instance() |
|
|
|
{ |
|
|
|
static mwMap mwMapInstance; |
|
|
|
return &mwMap Instance; |
|
|
|
static MWMap mwMapInstance; |
|
|
|
return &mwMapInstance; |
|
|
|
} |
|
|
|
|
|
|
|
void |
|
|
@ -18,7 +18,7 @@ MWMap::enter(const shared_ptr<MWSessionPrx>& session, const shared_ptr<MWCallbac |
|
|
|
const Ice::Current& current) |
|
|
|
{ |
|
|
|
lock_guard<mutex> sync(_mutex); |
|
|
|
_callback.push_back(callback); |
|
|
|
_callbacks.push_back(callback); |
|
|
|
|
|
|
|
auto p = _connectionMap.find(current.con); |
|
|
|
if (p == _connectionMap.end()) |
|
|
@ -33,9 +33,9 @@ MWMap::enter(const shared_ptr<MWSessionPrx>& session, const shared_ptr<MWCallbac |
|
|
|
current.con->setCloseCallback([this](const shared_ptr<Ice::Connection>& con) |
|
|
|
{ |
|
|
|
|
|
|
|
deadRouter(con); |
|
|
|
|
|
|
|
)}; |
|
|
|
deadRouter(con); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
@ -48,9 +48,9 @@ MWMap::enter(const shared_ptr<MWSessionPrx>& session, const shared_ptr<MWCallbac |
|
|
|
void |
|
|
|
MWMap::leave(const shared_ptr<MWCallbackPrx>& callback, const Ice::Current& current) |
|
|
|
{ |
|
|
|
lock_guard(mutex) sync(_mutex); |
|
|
|
_callbacks.remove_if([&callback](const shared_ptr<MWCallbackPrx>& cb) { return Ice::proxyIdentifyEqual(callback, cb); }); |
|
|
|
_connectionMap[current.con].remove_if([¤t](const share_ptr<MWSessionPrx>& s) {return current.id == s->ice_getIdentity(); }); |
|
|
|
lock_guard<mutex> sync(_mutex); |
|
|
|
_callbacks.remove_if([&callback](const shared_ptr<MWCallbackPrx>& cb) { return Ice::proxyIdentityEqual(callback, cb); }); |
|
|
|
_connectionMap[current.con].remove_if([¤t](const shared_ptr<MWSessionPrx>& s) {return current.id == s->ice_getIdentity(); }); |
|
|
|
} |
|
|
|
|
|
|
|
void |
|
|
@ -64,11 +64,11 @@ MWMap::message(const string& data) const |
|
|
|
} |
|
|
|
|
|
|
|
void |
|
|
|
MWMap::dearRouter() |
|
|
|
MWMap::deadRouter(const shared_ptr<Ice::Connection>& con) |
|
|
|
{ |
|
|
|
cout << "Detected dead router. Detroying all sessions " << endl; |
|
|
|
list<shared_ptr<MWSessionPrx>> sessions; |
|
|
|
lock_guar<mutex> sync(_mutex); |
|
|
|
lock_guard<mutex> sync(_mutex); |
|
|
|
auto p = _connectionMap.find(con); |
|
|
|
if(p != _connectionMap.end()) |
|
|
|
{ |
|
|
|