Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlee0201 committed Oct 6, 2017
1 parent 092e608 commit fd806f3
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions MQTTDemo/IMLib/MQTTClient/NetworkService.mm
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ - (void) createMars {
mars::app::SetCallback(mars::app::AppCallBack::Instance());
mars::stn::setConnectionStatusCallback(new CSCB(self));
mars::stn::setReceiveMessageCallback(new RPCB(self));

mars::baseevent::OnCreate();
}

Expand Down
4 changes: 4 additions & 0 deletions MQTTDemo/IMLib/mars.framework/Headers/stn/stn.h
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,10 @@ extern void (*ReportDnsProfile)(const DnsProfile& _dns_profile);

extern void setConnectionStatusCallback(ConnectionStatusCallback *callback);
extern void setReceiveMessageCallback(ReceiveMessageCallback *callback);

extern void setRefreshUserInfoCallback(GetUserInfoCallback *callback);
extern void setRefreshGroupInfoCallback(GetGroupInfoCallback *callback);

extern ConnectionStatus getConnectionStatus();

extern int (*sendMessage)(TMessage &tmsg, SendMessageCallback *callback);
Expand Down
7 changes: 3 additions & 4 deletions mars/stn/mqtt/MessageDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,13 +611,12 @@ namespace mars {

class TGetGroupInfoCallback : public GetGroupInfoCallback {
void onSuccess(std::list<TGroupInfo> groupInfoList) {
if(StnCallBack::Instance()->m_getGroupInfoCB) {
StnCallBack::Instance()->m_getGroupInfoCB->onSuccess(groupInfoList);
}

for (std::list<TGroupInfo>::iterator it = groupInfoList.begin(); it != groupInfoList.end(); it++) {
MessageDB::Instance()->InsertGroupInfo(*it);
}
if(StnCallBack::Instance()->m_getGroupInfoCB) {
StnCallBack::Instance()->m_getGroupInfoCB->onSuccess(groupInfoList);
}
delete this;
}
void onFalure(int errorCode) {
Expand Down
9 changes: 9 additions & 0 deletions mars/stn/mqtt/stn_callback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ namespace mars {
StnCallBack::Instance()->setReceiveMessageCallback(callback);
}

void setRefreshUserInfoCallback(GetUserInfoCallback *callback) {
StnCallBack::Instance()->setGetUserInfoCallback(callback);
}

void setRefreshGroupInfoCallback(GetGroupInfoCallback *callback) {
StnCallBack::Instance()->setGetGroupInfoCallback(callback);
}


ConnectionStatus getConnectionStatus() {
return StnCallBack::Instance()->getConnectionStatus();
}
Expand Down
2 changes: 2 additions & 0 deletions mars/stn/mqtt/stn_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace mars {


class TGetGroupInfoCallback;
class RefreshUserInfoCallback;
class StnCallBack : public Callback, PullingMessageCallback {

private:
Expand Down Expand Up @@ -88,6 +89,7 @@ class StnCallBack : public Callback, PullingMessageCallback {
void onDBOpened();

friend class TGetGroupInfoCallback;
friend class RefreshUserInfoCallback;
private:
static StnCallBack* instance_;
void PullMessage(int64_t head);
Expand Down
7 changes: 7 additions & 0 deletions mars/stn/stn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,16 @@ MQTTTask::MQTTTask(MQTT_MSG_TYPE type) : Task(), type(type) {
for (std::list<const TUserInfo>::const_iterator it = userInfoList.begin(); it != userInfoList.end(); ++it) {
MessageDB::Instance()->InsertUserInfoOrReplace(*it);
}

if(StnCallBack::Instance()->m_getUserInfoCB) {
StnCallBack::Instance()->m_getUserInfoCB->onSuccess(userInfoList);
}
delete this;
}
void onFalure(int errorCode) {
if(StnCallBack::Instance()->m_getUserInfoCB) {
StnCallBack::Instance()->m_getUserInfoCB->onFalure(errorCode);
}
delete this;
}

Expand Down
4 changes: 4 additions & 0 deletions mars/stn/stn.h
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,10 @@ extern void (*ReportDnsProfile)(const DnsProfile& _dns_profile);

extern void setConnectionStatusCallback(ConnectionStatusCallback *callback);
extern void setReceiveMessageCallback(ReceiveMessageCallback *callback);

extern void setRefreshUserInfoCallback(GetUserInfoCallback *callback);
extern void setRefreshGroupInfoCallback(GetGroupInfoCallback *callback);

extern ConnectionStatus getConnectionStatus();

extern int (*sendMessage)(TMessage &tmsg, SendMessageCallback *callback);
Expand Down

0 comments on commit fd806f3

Please sign in to comment.