Get Room Properties Corona SDK

0 votes
This is gonna be my 3rd time asking about the same topic. I was able to connect to appwarp rooms by creating static. But I tried getting the info of the room and it's not working. I already tried the API's and guide but it can't seem to work or maybe because we lack of samples. I am just trying to print() the properties such as id, name, users etc. This topic was seen but was never answered. I was fascinated with appwarp because it's fast but now it's telling me not to buy it due to lack of support.
closed with the note: ~resolved
asked Jan 3, 2016 in AppWarp by rhaineyensid (10 points)
closed Jan 5, 2016 by rhaineyensid

1 Answer

0 votes

Hello rhaineyensid,

I have created one sample for you which implements getAllRooms and getLiveRoomInfo along with its corresponding callbacks. 

Let me know if you face any problem, i will be happy to help you.

Thanks.

 

 

answered Jan 4, 2016 by rajeev.etc (1,660 points)
Finally! Thanks for replying. Though i think the sample contains old version of corona syntax like storyboard which has been replaced by composer already and other scene functions. I managed to do some work around with that. But we still have a problem. I tried elimination method to compare two different functions:

display.setStatusBar( display.HiddenStatusBar )

appWarpClient = require "AppWarp.WarpClient" --import appwarp plugin

API_KEY = "###########################"  --some random characters here from my api key
SECRET_KEY = "##########################"  --some random characters here from my secret key
STATIC_ROOM_ID = "##########"  --some random characters here from my room id


appWarpClient.initialize(API_KEY, SECRET_KEY) --start appwarp

appWarpClient.connectWithUserName(tostring(os.clock()))  --add username

function onConnectDone(resultCode)
  print(resultCode)                       --try printing to see if function really works
end

appWarpClient.addRequestListener("onConnectDone", onConnectDone)

local function gameLoop(event)
  appWarpClient.Loop()
end

Runtime:addEventListener("enterFrame", gameLoop)

//** I do understand that the above function won't connect online. But this is only to prove if the function is being read every time I run the main.lua. And it prints the result code which means this function is alive. Now I removed this function and used onGetLiveRoomInfo() **//


display.setStatusBar( display.HiddenStatusBar )

appWarpClient = require "AppWarp.WarpClient" --import appwarp plugin

API_KEY = "###########################"  --some random characters here from my api key
SECRET_KEY = "##########################"  --some random characters here from my secret key
STATIC_ROOM_ID = "##########"  --some random characters here from my room id


appWarpClient.initialize(API_KEY, SECRET_KEY) --start appwarp

appWarpClient.connectWithUserName(tostring(os.clock()))  --add username

function onGetLiveRoomInfoDone(resultCode,roomTable)
  print(resultCode)     --didn't print anything even 5==error
end

appWarpClient.addRequestListener("onGetLiveRoomInfoDone", onGetLiveRoomInfoDone)

local function gameLoop(event)
  appWarpClient.Loop()
end

Runtime:addEventListener("enterFrame", gameLoop)


//** Didn't print any even 5 (error), and not only this but other related getRoom functions are dead. I thought I was doing it wrong before by printing roomTable.name but when I saw your sample, my previous syntax was correct and it is just the function not being read **//
Can you share your sample project with us so that we can look into it? It will help to debug the problem.
I saw the sample, and the getLiveRoomInfo API is not called and hence onGetLiveRoomInfoDone callback is not getting called. You are calling connectWithUserName API so its response will come in onConnectDone callback. Please have a go through our documentation(http://appwarp.shephertz.com/game-development-center/corona-client-apis/) to know the corresponding callback for a particular API.
Also, i have recreated the sample using composer which can be downloaded from here(https://www.dropbox.com/s/yb0i3zu188yl6yt/AppWarpSample.zip?dl=0).
Please have a look at menu.lua file for api calls and their callbacks.
Let me know if you face any problem.
thanks for quick reply. well, regarding getLiveRoomInfo API, i intentionally put the entire function within the comment because it won't work anyways and only revealed the connectWithUserName API. As my previous comment, i tried both. i was just switching functions but getRoom functions are not printing even the resultcode. I saw your revised sample and i can tell the same problem though i stripped some widgets and composer since it will also run basic. I used the same keys that you used to see if there's any difference but still it's not printing. pls refer to  https://www.dropbox.com/s/zjg3mb3ue0km5c4/try2.zip?dl=0
The last sample calls connectWithUserName but does not implement its corresponding callback onConnectDone. I have modified your sample accordingly which can be downloaded from here(https://www.dropbox.com/s/d2uc9v1rgyu9anq/try2.zip?dl=0).

I tested it and it running fine at my end. As of now when you will run the sample connectWithUserName will be called which response will come in onConnectDone. In onConnectDone callback, i have called getAllRooms api which response will come in onGetAllRoomsDone callback.
Let me know if you face any problem.
There you go! All this time, I was thinking that getRoom funcs are independent since they can be searched by static ID. That's why I tend to remove onConnect and just declared them separately. I just followed the API docs because it was unclear that you need to put "appWarpClient.getAllRooms()" or other syntax inside of onConnect func.

On what i understand, onConnect func is to connect into rooms via ID. Thus if you don't have room  ID, you can search randomly with getAllRooms which i thought an independent func.
Thanks for your feedback. We will sure do the appropriate changes to avoid the confusions.
Also, i assume now the sample is running well at your end and you are able to get the callbacks. Please close this thread if the query has been resolved.
sure. thanks so much. atleast it's working now.
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
...