How to return something to client from the server
#1

Hello, I'm trying to make a daily reward system, I've never done something "so complex" so I'm pretty lost on the subject... I managed to make the request on the client side, but when trying to return something from the server , it closes. This is the code that I have written, could someone tell me if there is an obvious problem?

This is my ptype

#ifndef __PTYPE_OLD_DO_DAILYREWARD_H__
#define __PTYPE_OLD_DO_DAILYREWARD_H__

#include "ptype_base.h"

enum{
    MSG_DAILYREWARD_ERROR,
    MSG_DAILYREWARD_LIST_REQ,
    MSG_DAILYREWARD_LIST_RES,
};

#pragma pack(push, 1)

namespace RequestClient{
    struct doDailyRewardList : public pTypeBase{
    };
}

namespace ResponseClient{
    struct ReceiveList : public pTypeBase{
        std:Confusedtring lastDate;
    };

#ifndef _CLIENT_
    inline void DailyRewardErrorMsg(CNetMsg::SP& msg, MSG_DAILYREWARD_ERROR_TYPE err){
        msg->Init(MSG_DAILYREWARD);
        RefMsg(msg) << (unsigned char)MSG_DAILYREWARD_ERROR
            << (unsigned char)err;
    }

    inline void makeDailyRewardReturnList(CNetMsg::SP& msg, std:Confusedtring lastDate){
        ResponseClient::ReceiveList *packet = reinterpret_cast<ResponseClient::ReceiveList*>(msg->m_buf);
        packet->type = MSG_DAILYREWARD;
        packet->subType = MSG_DAILYREWARD_LIST_RES;
        packet->lastDate = lastDate;
        msg->setSize(sizeof(ResponseClient::ReceiveList));
    }
#endif
}

#pragma pack(pop)

#endif

And this would be the function I'm working on

void do_DailyRewardList(CPC* ch, CNetMsg::SP& msg){
    CDBCmd cmd;
    cmd.Init(&gserver->m_dbchar);

    std:Confusedtring sql = boost:Confusedtr(boost::format("SELECT * FROM t_daily_reward_system WHERE a_char_index=%d") % ch->m_index);
    cmd.SetQuery(sql);
    
    if(cmd.Open() == true && cmd.MoveNext() == true){
        std:Confusedtring last_date = ("");
        cmd.GetRec("a_last_date", last_date);    // Format: Datetime

        //LOG_INFO("DAILY REWARD SYSTEM Char Index : %d, Last Date : %s", ch->m_index, last_date);

        CNetMsg::SP rmsg(new CNetMsg);
        ResponseClient::makeDailyRewardReturnList(rmsg, last_date);
        SEND_Q(rmsg, ch->m_desc);
        return;
    }else{
        LOG_ERROR("DAILY REWARD SYSTEM : se fue a la putah");
    }
}

 



Messages In This Thread
[No subject] - by nicolasg - 06-11-2022, 10:39 PM
[No subject] - by nicolasg - 06-12-2022, 06:08 AM
[No subject] - by Andrein95 - 06-28-2022, 10:17 PM
[No subject] - by nicolasg - 06-29-2022, 12:44 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)