1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
#include <IceGrid/AdminCallbackRouter.h>
using namespace std;
using namespace IceGrid;
void
AdminCallbackRouter::addMapping(const string& category, const shared_ptr<Ice::Connection>& con)
{
lock_guard lock(_mutex);
#ifdef NDEBUG
_categoryToConnection.insert({ category, con });
#else
bool inserted = _categoryToConnection.insert({ category, con }).second;
assert(inserted == true);
#endif
}
void
AdminCallbackRouter::removeMapping(const string& category)
{
lock_guard lock(_mutex);
#ifndef NDEBUG
size_t one =
#endif
_categoryToConnection.erase(category);
assert(one == 1);
}
void
AdminCallbackRouter::ice_invokeAsync(pair<const Ice::Byte*, const Ice::Byte*> inParams,
function<void(bool, const pair<const Ice::Byte*, const Ice::Byte*>&)> response,
function<void(exception_ptr)> exception,
const Ice::Current& current)
{
shared_ptr<Ice::Connection> con;
{
lock_guard lock(_mutex);
auto p = _categoryToConnection.find(current.id.category);
if(p == _categoryToConnection.end())
{
throw Ice::ObjectNotExistException(__FILE__, __LINE__);
}
con = p->second;
}
auto target = con->createProxy(current.id)->ice_facet(current.facet);
//
// Call with AMI
//
target->ice_invokeAsync(current.operation, current.mode, inParams,
move(response),
[exception = move(exception)] (exception_ptr)
{
exception(make_exception_ptr(Ice::ObjectNotExistException(__FILE__, __LINE__)));
},
nullptr,
current.ctx);
}
|