AppWarp and App42 Sample for Cocos2dx

0 votes

Hello People,

 

    I am trying to dig my head into realtime multiplayer gaming solution in cocos2dx, I have been looking into many threads and searching for sample using AppWarp and App42 both together, I have tried to implement AppWarp using the sample cocos2dx, it doesn't work, it doesn't do anything, I was wondering that if AppWarp need App42 to connect with things?, I didn't get any sample as such. Am I missing something? May be the basic flow of using the Client and Api.

 

Anyone can help me please?

 

Update

I am using the following code to try to use AppWarp.

//Appwrap functions

void Opponents::connectToAppWarp()
{
 
    
    isConnected = false;
    AppWarp::Client *warpClientRef;
    AppWarp::Client::initialize(GameConfig::appwrap_key,GameConfig::appwrap_secret_key);
    warpClientRef = AppWarp::Client::getInstance();
    warpClientRef->setRecoveryAllowance(60);
    warpClientRef->setConnectionRequestListener(this);
    warpClientRef->setRoomRequestListener(this);
    warpClientRef->setZoneRequestListener(this);
    warpClientRef->connect(UserDefault::getInstance()->getStringForKey("username"));
}
 
void Opponents::onDisconnectDone(int res)
{
    MessageBox("You have been disconnected!", "Disconnected!");
}
 
void Opponents::onConnectDone(int res)
{
    if (res==AppWarp::ResultCode::success)
    {
        
        printf("\nonConnectDone .. SUCCESS..session=%d\n",AppWarp::AppWarpSessionID);
        AppWarp::Client *warpClientRef;
        warpClientRef = AppWarp::Client::getInstance();
        warpClientRef->joinRoom(GameConfig::appwrap_room_id);
    }else if (res==AppWarp::ResultCode::success_recovered)
    {
        //unscheduleRecover();
        printf("\nonConnectDone .. SUCCESS with success_recovered..session=%d\n",AppWarp::AppWarpSessionID);
    }
    else if (res==AppWarp::ResultCode::connection_error_recoverable)
    {
        //scheduleRecover();
        printf("\nonConnectDone .. FAILED..connection_error_recoverable..session=%d\n",AppWarp::AppWarpSessionID);
    }
    else if (res==AppWarp::ResultCode::bad_request)
    {
        //unscheduleRecover();
        printf("\nonConnectDone .. FAILED with bad request..session=%d\n",AppWarp::AppWarpSessionID);
    }
    else if (res==AppWarp::ResultCode::connection_error)
    {
        //unscheduleRecover();
        printf("\nonConnectDone .. FAILED with connection error..session=%d\n",AppWarp::AppWarpSessionID);
    }
    else
    {
       
        printf("\nonConnectDone .. FAILED with unknown reason..session=%d\n",AppWarp::AppWarpSessionID);
       
    }
}
 
Nothing works when I execute the code above, my question is related to if any realtion between AppWarp and App42 api, I think I need to create user using App42, and use with AppWarp client, I am asking that, I can't find any sample using both. 
asked Jan 22, 2015 in AppWarp by veda.in (28 points)
edited Jan 23, 2015 by veda.in

1 Answer

+1 vote
 
Best answer
Hi,

AppWarp and App42 work independently. You do not need App42 to run AppWarp sample. What type of error are you getting? Is it a compile time error, or you are getting some failure in listener functions?

Thanks
answered Jan 22, 2015 by Suyash Mohan (900 points)
selected Feb 6, 2015 by veda.in
No, I am not getting any error, I am not getting how to use both the wrappers together, and when I implemented AppWarp the listeners doesn't work, it seems to me nothing working..
As I told you both work independently. You might get error with file cJSON as it is part of both SDKs. To solve this just keep one copy of .cpp/.c

You need to give me more technical details, to help you better.
@Suyash Mohan I have updated my question see the blue part, as I said I am not getting any error regarding integration, I managed all correctly. My question is different. Thanks.
No you don't need App42 to use AppWarp. You can pass any string in connect method as username. The only condition is username should be unique and does not have special characters.|


The reason your code might not be working is you are using old way of onConnectDone with newer SDK. onConnectDone accepts two parameters. The new declarations is as follow
void onConnectDone(int reasultCode, int reasonCode)

Since onConnectDone is a virtual method, using wrong declaration does not throw any error, but it will not work.

Thanks
I've tried Suyash Mohan suggestion and modified onConnectDone. However, sample still fails to connect to server. There's no progress after clicking on startgame for the first time. When startgame is clicked again, I got "onConnectDone .. FAILED with bad request..session=0" error.
I am also facing same problem even using newer verion.Please tell me what should i do?
Did you try the Ninja Fight MultiplayerDemo(https://github.com/shephertz/AppWarpCocos2DX) which comes with the SDK? Also, please provide some description of the error which you are facing. It will help to debug the problem.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...