Fixed message id type to be qint64

This commit is contained in:
Jordan Sherer 2020-04-04 15:15:17 -04:00
parent 75cda323a1
commit 39aafa6f5e
2 changed files with 6 additions and 6 deletions

View File

@ -21,7 +21,7 @@
#include "Message.h"
#include "DriftingDateTime.h"
const quint32 EPOCH = 1499299200000; // July 6, 2017
const qint64 EPOCH = 1499299200000; // July 6, 2017
#if USE_SNOWFLAKE
quint64 snowflake(quint64 epoch, quint16 machine, quint16 sequence){
@ -48,15 +48,15 @@ Message::Message(QString const &type, QString const &value, QMap<QString, QVari
value_{ value },
params_{ params }
{
if(params_.value("_ID", 0).toInt() == 0){
if(params_.value("_ID", 0).toLongLong() == 0){
params_["_ID"] = QString::number(DriftingDateTime::currentMSecsSinceEpoch()-EPOCH);
}
}
int Message::ensureId(){
qint64 Message::ensureId(){
// if a non-zero id exists, we're good
if(params_.contains("_ID")){
auto id = params_.value("_ID", 0).toInt();
auto id = params_.value("_ID", 0).toLongLong();
if(id != 0){
return id;
}

View File

@ -29,8 +29,8 @@ public:
QString value() const { return value_; }
void setValue(QString value){ value_ = value; }
int id() const { return params_.value("_ID").toInt(); }
int ensureId();
qint64 id() const { return params_.value("_ID").toLongLong(); }
qint64 ensureId();
QMap<QString, QVariant> params() const { return params_; }
private: