Post date: Feb 23, 2017 1:54:15 AM
This is implied in the documentation but no example, so I tried out a few things and it works. This is an example of what I did, firstly the class definition which is modified from the example program basic-agents.cpp
class agent1 : public agent
{
public:
explicit agent1(ISource<int>& source1, ISource<int>& source2, ITarget<wstring>& target1, ITarget<wstring>& target2)
: _source1(source1)
, _source2(source2)
, _target1(target1)
, _target2(target2)
{
}
protected:
void run()
{
// send the request
wstringstream ss1;
ss1 << L"agent1: sending request... " << endl;
wcout << ss1.str();
send(_target1, wstring(L"request1"));
send(_target2, wstring(L"reqeust2"));
// Read the response
int response1 = receive(_source1);
int response2 = receive(_source2);
ss1 = wstringstream();
ss1 << L"agent1: received '" << response1 << L"'." << endl;
wcout << ss1.str();
wstringstream ss2 = wstringstream();
ss2 << L"agent2: received '" << response2 << L"'." << endl;
wcout << ss2.str();
done();
}
private:
ISource<int>& _source1;
ISource<int>& _source2;
ITarget<wstring>& _target1;
ITarget<wstring>& _target2;
};
This is ok on intellisense and compiles and builds okay.