mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-24 14:23:36 -05:00
converted RTT items to new serialization
This commit is contained in:
parent
5071c4bc7f
commit
f6aaee7382
@ -35,17 +35,17 @@
|
||||
#include "util/rsmemory.h"
|
||||
#include "util/rsprint.h"
|
||||
|
||||
#include <serialiser/rsmsgitems.h>
|
||||
#include "rsitems/rsmsgitems.h"
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rsidentity.h>
|
||||
#include <retroshare/rsiface.h>
|
||||
#include "retroshare/rsmsgs.h"
|
||||
#include "retroshare/rsidentity.h"
|
||||
#include "retroshare/rsiface.h"
|
||||
|
||||
#include <rsserver/p3face.h>
|
||||
#include <services/p3idservice.h>
|
||||
#include <gxs/gxssecurity.h>
|
||||
#include <turtle/p3turtle.h>
|
||||
#include <retroshare/rsids.h>
|
||||
#include "rsserver/p3face.h"
|
||||
#include "services/p3idservice.h"
|
||||
#include "gxs/gxssecurity.h"
|
||||
#include "turtle/p3turtle.h"
|
||||
#include "retroshare/rsids.h"
|
||||
#include "distantchat.h"
|
||||
|
||||
//#define DEBUG_DISTANT_CHAT
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "serialiser/rsmsgitems.h"
|
||||
#include "rsitems/rsmsgitems.h"
|
||||
#include "services/p3service.h"
|
||||
#include "pqi/pqiservicemonitor.h"
|
||||
#include "chat/distantchat.h"
|
||||
|
@ -458,7 +458,7 @@ HEADERS += rsitems/itempriorities.h \
|
||||
serialiser/rsserviceserialiser.h \
|
||||
serialiser/rsconfigitems.h \
|
||||
serialiser/rshistoryitems.h \
|
||||
serialiser/rsmsgitems.h \
|
||||
rsitems/rsmsgitems.h \
|
||||
serialiser/rsserial.h \
|
||||
rsitems/rsserviceids.h \
|
||||
serialiser/rsserviceitems.h \
|
||||
@ -612,7 +612,7 @@ SOURCES += serialiser/rsbaseserial.cc \
|
||||
serialiser/rsserviceserialiser.cc \
|
||||
serialiser/rsconfigitems.cc \
|
||||
serialiser/rshistoryitems.cc \
|
||||
serialiser/rsmsgitems.cc \
|
||||
rsitems/rsmsgitems.cc \
|
||||
serialiser/rsserial.cc \
|
||||
serialiser/rsstatusitems.cc \
|
||||
serialiser/rstlvaddrs.cc \
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
#include "retroshare/rsiface.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "serialiser/rsmsgitems.h"
|
||||
#include "rsitems/rsmsgitems.h"
|
||||
#include "rsserver/p3face.h"
|
||||
#include "util/rsstring.h"
|
||||
|
||||
|
@ -27,9 +27,10 @@
|
||||
#include <stdexcept>
|
||||
#include <time.h>
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
#include "serialiser/rsmsgitems.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
|
||||
#include "rsitems/rsmsgitems.h"
|
||||
|
||||
#include "serialization/rstypeserializer.h"
|
||||
|
||||
/***
|
||||
|
@ -36,7 +36,34 @@
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
RsItem *RsRttSerialiser::create_item(uint16_t service,uint8_t type) const
|
||||
{
|
||||
if(service != RS_SERVICE_TYPE_RTT)
|
||||
return NULL ;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case RS_PKT_SUBTYPE_RTT_PING: return new RsRttPingItem() ; //= 0x01;
|
||||
case RS_PKT_SUBTYPE_RTT_PONG: return new RsRttPongItem() ; // = 0x02;
|
||||
default:
|
||||
return NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
void RsRttPingItem::serial_process(SerializeJob j,SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,mSeqNo,"mSeqNo") ;
|
||||
RsTypeSerializer::serial_process<uint64_t>(j,ctx,mPingTS,"mPingTS") ;
|
||||
}
|
||||
|
||||
void RsRttPongItem::serial_process(SerializeJob j,SerializeContext& ctx)
|
||||
{
|
||||
RsTypeSerializer::serial_process<uint32_t>(j,ctx,mSeqNo,"mSeqNo") ;
|
||||
RsTypeSerializer::serial_process<uint64_t>(j,ctx,mPingTS,"mPingTS") ;
|
||||
RsTypeSerializer::serial_process<uint64_t>(j,ctx,mPongTS,"mPongTS") ;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
RsRttPingItem::~RsRttPingItem()
|
||||
{
|
||||
return;
|
||||
@ -370,4 +397,5 @@ RsItem* RsRttSerialiser::deserialise(void *data, uint32_t *pktsize)
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
#endif
|
||||
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "rsitems/rsserviceids.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
|
||||
#include "serialization/rsserializer.h"
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
const uint8_t RS_PKT_SUBTYPE_RTT_PING = 0x01;
|
||||
@ -39,12 +41,11 @@ const uint8_t RS_PKT_SUBTYPE_RTT_PONG = 0x02;
|
||||
class RsRttItem: public RsItem
|
||||
{
|
||||
public:
|
||||
RsRttItem(uint8_t chat_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_RTT,chat_subtype)
|
||||
RsRttItem(uint8_t subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_RTT,subtype)
|
||||
{ setPriorityLevel(QOS_PRIORITY_RS_RTT_PING) ;} // should be refined later.
|
||||
|
||||
virtual ~RsRttItem() {};
|
||||
virtual void clear() {};
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) = 0 ;
|
||||
};
|
||||
|
||||
class RsRttPingItem: public RsRttItem
|
||||
@ -52,9 +53,10 @@ class RsRttPingItem: public RsRttItem
|
||||
public:
|
||||
RsRttPingItem() :RsRttItem(RS_PKT_SUBTYPE_RTT_PING) {}
|
||||
|
||||
virtual ~RsRttPingItem();
|
||||
virtual void clear();
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
virtual ~RsRttPingItem(){}
|
||||
virtual void clear(){}
|
||||
|
||||
virtual void serial_process(SerializeJob j,SerializeContext& ctx);
|
||||
|
||||
uint32_t mSeqNo;
|
||||
uint64_t mPingTS;
|
||||
@ -65,9 +67,10 @@ class RsRttPongItem: public RsRttItem
|
||||
public:
|
||||
RsRttPongItem() :RsRttItem(RS_PKT_SUBTYPE_RTT_PONG) {}
|
||||
|
||||
virtual ~RsRttPongItem();
|
||||
virtual void clear();
|
||||
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
virtual ~RsRttPongItem(){}
|
||||
virtual void clear(){}
|
||||
|
||||
virtual void serial_process(SerializeJob j,SerializeContext& ctx);
|
||||
|
||||
uint32_t mSeqNo;
|
||||
uint64_t mPingTS;
|
||||
@ -75,29 +78,14 @@ class RsRttPongItem: public RsRttItem
|
||||
};
|
||||
|
||||
|
||||
class RsRttSerialiser: public RsSerialType
|
||||
class RsRttSerialiser: public RsSerializer
|
||||
{
|
||||
public:
|
||||
RsRttSerialiser()
|
||||
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_RTT)
|
||||
{ return; }
|
||||
RsRttSerialiser() :RsSerializer(RS_SERVICE_TYPE_RTT) {}
|
||||
|
||||
virtual ~RsRttSerialiser() { return; }
|
||||
virtual ~RsRttSerialiser(){}
|
||||
|
||||
virtual uint32_t size(RsItem *);
|
||||
virtual bool serialise (RsItem *item, void *data, uint32_t *size);
|
||||
virtual RsItem * deserialise(void *data, uint32_t *size);
|
||||
|
||||
private:
|
||||
|
||||
virtual uint32_t sizeRttPingItem(RsRttPingItem *);
|
||||
virtual bool serialiseRttPingItem (RsRttPingItem *item, void *data, uint32_t *size);
|
||||
virtual RsRttPingItem *deserialiseRttPingItem(void *data, uint32_t *size);
|
||||
|
||||
virtual uint32_t sizeRttPongItem(RsRttPongItem *);
|
||||
virtual bool serialiseRttPongItem (RsRttPongItem *item, void *data, uint32_t *size);
|
||||
virtual RsRttPongItem *deserialiseRttPongItem(void *data, uint32_t *size);
|
||||
|
||||
virtual RsItem *create_item(uint16_t service,uint8_t type) const;
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
@ -438,7 +438,7 @@ RsItem * RsSerialiser::deserialise(void *data, uint32_t *size)
|
||||
uint32_t failedtype = getRsItemId(data);
|
||||
std::cerr << "RsSerialiser::deserialise() FAILED PACKET Size: ";
|
||||
std::cerr << getRsItemSize(data) << " ID: ";
|
||||
std::cerr << std::hex << failedtype << std::dec;
|
||||
std::cerr << std::hex << failedtype << std::endl;
|
||||
std::cerr << "RsSerialiser::deserialise() FAILED PACKET: ";
|
||||
std::cerr << " Version: " << std::hex << (uint32_t) getRsItemVersion(failedtype) << std::dec;
|
||||
std::cerr << " Class: " << std::hex << (uint32_t) getRsItemClass(failedtype) << std::dec;
|
||||
|
@ -32,10 +32,11 @@ class RsSerializer: public RsSerialType
|
||||
/*! create_item
|
||||
* should be overloaded to create the correct type of item depending on the data
|
||||
*/
|
||||
virtual RsItem *create_item(uint16_t /* service */, uint8_t /* item_sub_id */) const
|
||||
{
|
||||
return NULL ;
|
||||
}
|
||||
virtual RsItem *create_item(uint16_t /* service */, uint8_t /* item_sub_id */) const=0;
|
||||
// {
|
||||
// std::cerr << "(EE) Serializer does not overload create_item(). This is probably an error."<< std::endl;
|
||||
// return NULL ;
|
||||
// }
|
||||
|
||||
// The following functions overload RsSerialType. They *should not* need to be further overloaded.
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
|
||||
#include "services/p3service.h"
|
||||
#include "serialiser/rsmsgitems.h"
|
||||
#include "rsitems/rsmsgitems.h"
|
||||
#include "util/rsthreads.h"
|
||||
|
||||
#include "retroshare/rsgxsifacetypes.h"
|
||||
|
Loading…
Reference in New Issue
Block a user