mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added NxsNetMgr to simulator
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7266 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
1d17290e78
commit
df4cf6030e
36
tests/librssimulator/peer/FakeNxsNetMgr.h
Normal file
36
tests/librssimulator/peer/FakeNxsNetMgr.h
Normal file
@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "gxs/rsgxsnetservice.h"
|
||||
#include "FakeLinkMgr.h"
|
||||
|
||||
class FakeNxsNetMgr : public RsNxsNetMgr
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
FakeNxsNetMgr(FakeLinkMgr *linkMgr)
|
||||
:mLinkMgr(linkMgr) { return; }
|
||||
|
||||
const RsPeerId& getOwnId()
|
||||
{
|
||||
return mLinkMgr->getOwnId();
|
||||
}
|
||||
|
||||
void getOnlineList(uint32_t serviceId, std::set<RsPeerId>& ssl_peers)
|
||||
{
|
||||
(void) serviceId;
|
||||
|
||||
std::list<RsPeerId> peerList;
|
||||
mLinkMgr->getOnlineList(peerList);
|
||||
|
||||
std::list<RsPeerId>::const_iterator it;
|
||||
for(it = peerList.begin(); it != peerList.end(); it++)
|
||||
{
|
||||
ssl_peers.insert(*it);
|
||||
}
|
||||
}
|
||||
private:
|
||||
|
||||
FakeLinkMgr *mLinkMgr;
|
||||
};
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "FakeNetMgr.h"
|
||||
#include "FakePublisher.h"
|
||||
#include "FakeServiceControl.h"
|
||||
#include "FakeNxsNetMgr.h"
|
||||
|
||||
|
||||
PeerNode::PeerNode(const RsPeerId& id,const std::list<RsPeerId>& friends, bool online)
|
||||
@ -31,6 +32,7 @@ PeerNode::PeerNode(const RsPeerId& id,const std::list<RsPeerId>& friends, bool o
|
||||
mLinkMgr = new FakeLinkMgr(id, friends, online) ;
|
||||
mPeerMgr = new FakePeerMgr(id, friends) ;
|
||||
mPublisher = new FakePublisher() ;
|
||||
mNxsNetMgr = new FakeNxsNetMgr(mLinkMgr);
|
||||
|
||||
_service_control = new FakeServiceControl(mLinkMgr) ;
|
||||
_service_server = new p3ServiceServer(mPublisher,_service_control);
|
||||
@ -75,6 +77,12 @@ p3PeerMgr *PeerNode::getPeerMgr()
|
||||
return mPeerMgr;
|
||||
}
|
||||
|
||||
|
||||
RsNxsNetMgr *PeerNode::getNxsNetMgr()
|
||||
{
|
||||
return mNxsNetMgr;
|
||||
}
|
||||
|
||||
void PeerNode::notifyOfFriends()
|
||||
{
|
||||
std::list<RsPeerId> friendList;
|
||||
@ -172,12 +180,17 @@ void PeerNode::takeOffline(std::list<RsPeerId> &offlineList)
|
||||
|
||||
void PeerNode::tick()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cerr << " ticking peer node " << _id << std::endl;
|
||||
#endif
|
||||
_service_server->tick() ;
|
||||
}
|
||||
|
||||
void PeerNode::incoming(RsRawItem *item)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cerr << "PeerNode::incoming()" << std::endl;
|
||||
#endif
|
||||
_service_server->recvItem(item) ;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,8 @@ class p3ServiceControl;
|
||||
class FakeLinkMgr;
|
||||
class FakePeerMgr;
|
||||
class FakeNetMgr;
|
||||
class RsNxsNetMgr;
|
||||
class FakeNxsNetMgr;
|
||||
class pqiMonitor;
|
||||
class pqiServiceMonitor;
|
||||
class pqiService;
|
||||
@ -33,6 +35,7 @@ class PeerNode
|
||||
p3LinkMgr *getLinkMgr();
|
||||
p3PeerMgr *getPeerMgr();
|
||||
p3NetMgr *getNetMgr();
|
||||
RsNxsNetMgr *getNxsNetMgr();
|
||||
|
||||
void AddService(pqiService *service);
|
||||
void AddPqiMonitor(pqiMonitor *service);
|
||||
@ -52,6 +55,7 @@ class PeerNode
|
||||
FakeLinkMgr *mLinkMgr;
|
||||
FakePeerMgr *mPeerMgr;
|
||||
FakeNetMgr *mNetMgr;
|
||||
FakeNxsNetMgr *mNxsNetMgr;
|
||||
|
||||
/* for monitors */
|
||||
std::list<pqiMonitor *> mPqiMonitors;
|
||||
|
@ -34,7 +34,7 @@ bool IsolatedServiceTester::startup()
|
||||
|
||||
bool IsolatedServiceTester::tick()
|
||||
{
|
||||
|
||||
mNode->tick();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -57,9 +57,11 @@ RsItem *IsolatedServiceTester::getPacket()
|
||||
RsRawItem *rawitem = mNode->outgoing();
|
||||
if (rawitem)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
/* convert back to standard item for convenience */
|
||||
std::cerr << "IsolatedServiceTester::getPacket() have RsRawItem";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* convert to RsServiceItem */
|
||||
uint32_t size = rawitem->getRawLength();
|
||||
@ -96,8 +98,10 @@ RsItem *IsolatedServiceTester::getPacket()
|
||||
|
||||
bool IsolatedServiceTester::sendPacket(RsItem *si)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cerr << "IsolatedServiceTester::sendPacket()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* try to convert */
|
||||
uint32_t size = mRsSerialiser->size(si);
|
||||
@ -132,6 +136,14 @@ bool IsolatedServiceTester::sendPacket(RsItem *si)
|
||||
|
||||
if (raw)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cerr << "IsolatedServiceTester::sendPacket()";
|
||||
std::cerr << std::endl;
|
||||
si->print(std::cerr);
|
||||
std::cerr << "IsolatedServiceTester::sendPacket() passing to Node: ";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
raw->PeerId(si->PeerId());
|
||||
mNode->incoming(raw);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user