Can Someone Put Together A Sample For User Reg And Login... Please

Hey,

I’ve been dying to get multiplayer working in my game, and have waited for Cloud to become active, only to be teased by it’s release without example docs and the like.

I’m developing on windows, so I guess the apple crowd does have a sample app in the simulator, but windows does not.

I wanted to use the dashboard to handle the registration and login, but since I hear it’s buggy and there are no supporting docs to make it work, can someone put together a simple example implementation of the login and reg?

My game is currently working with multiplayer hotseat, as in using one device but passing it to the next guy after your turn, I really need to get multiplayer working with Cloud so I can get some people to beta test for me.

Any help you can give would be helpful to lots of flailing programmers like myself.

thanks

Hi,

We are truly trying to get these out ASAP, please just bare with us just a little longer, we will be releasing a multiplayer guide soon.

Please feel free to email me directly mohamed(at)coronalabs.com and let me see how we can help you in the mean time.

Thanks

-Mohamed

I don’t mean to criticize you guys, honestly.   I realize it’s a lot of work on your end.

I’m just hoping someone can give me something to look at so I can start getting it together.

I need the login part taken care of just so I can start to delve into chat, match making, leaderboards, etc.

I appreciate your efforts Mohamed  ;)

hey tbernard, actually you are 100% correct in asking for this, this is something that we should have/had!

So I appreciate you voicing this, everyone needs a little butt kicking from time to time. :slight_smile:

Here is a simple register and login -

  local widget = require "widget"     CC\_Access\_Key = "xxxxxx" CC\_Secret\_Key = "xxxxxx" coronaCloud = require ( "corona-cloud-core" ) coronaCloud.init( CC\_Access\_Key, CC\_Secret\_Key )   -- This is for using the Cloud Dashboard gameNetwork = require( "gameNetwork" ) local params = { accessKey = CC\_Access\_Key, secretKey = CC\_Secret\_Key, } gameNetwork.init( "corona", params )   local currentAuthToken = ""  --variable to store the login 'authToken'   local function loginSuccess( event )     --store the 'authToken' on login success     currentAuthToken = coronaCloud.authToken     print("logged in") end   local function loginFailure( event )     --clear the 'authToken' on login failure     currentAuthToken = ""     print("login failure")     print(event.type) end   local function registrationHandler( event )     --code to handle the registration     --this is a logical place to call the login code     print("registered") end   Runtime:addEventListener( "LoggedIn", loginSuccess ) Runtime:addEventListener( "LoginError", loginFailure ) Runtime:addEventListener( "UserRegistered", registrationHandler )   local function btnLogin\_Click( event )   coronaCloud.loginAPI( "email", "password" ) end   local function btnRegister\_Click( event )   coronaCloud.registerUser( "firstname", "surname", "username", "email", "password" ) end   local btnLogin = widget.newButton{   label = "Login",   labelColor = { default={ 255, 255, 255, 255 }, over={ 0 } },   defaultColor = { 64, 153, 255, 255 },   overColor = { 64, 153, 255, 200 },   strokeColor = { 255, 255, 255, 255 },   width = 180,   height = 44,   fontSize = 24,   onRelease = btnLogin\_Click } btnLogin.x = display.contentCenterX btnLogin.y = display.contentCenterY - 50   local btnRegister = widget.newButton{   label = "Register",   labelColor = { default={ 255, 255, 255, 255 }, over={ 0 } },   defaultColor = { 64, 153, 255, 255 },   overColor = { 64, 153, 255, 200 },   strokeColor = { 255, 255, 255, 255 },   width = 180,   height = 44,   fontSize = 24,   onRelease = btnRegister\_Click } btnRegister.x = display.contentCenterX btnRegister.y = display.contentCenterY + 50  

In corona-cloud-core.lua set -

coronaCloudController.debugEnabled = true

To see lots of information.

Dave

Thanks Dave.

Now, does the CC_Access_Key, CC_Secret_Key, and the currentAuthToken get added to the top of every storyboard file, 

or just to the main.lua file…?

I wouldn’t be getting a user’s login info until they’ve moved to my menu.lua file, and then from there they go to the mainGame.lua

I don’t understand how it works…

should currentAuthToken be a global?

If someone can give a brief explanation in regards to these structural questions I would really appreciate it.

Thanks

You would only need to use the the CC_Access_Key/Secret_Key in main.lua when you call the init() function(s).  For what Dave did above, calling the gameNetwork.init() wasn’t necessary.  You only need that for using our UI for showing leaderboards and such (but it handles logins too).

You can delay the coronaCloud.loginAPI() call until after you’ve captured the required information.  As far as the authToken, it doesn’t need to be global.  After you call loginAPI() it will set it for you as part of the coronaCloud object.  If you choose to save the authToken for future restarts without having to login in, you would simply set it on re-start:

[lua]

    coronaCloud.authToken = “yoursavedauthtoken”

[/lua]

after you call coronaCloud.init()

Thanks Rob

I think I have enough info to start to put it together this weekend.

One issue… I can’t seem to find corona-cloud-core.lua?

I’m running v1072 windows…

See the Leaderboard/Achievement Guide.  The link to the github repository are near the top of the guide.

http://docs.coronalabs.com/guide/cloud/leaderachieve/index.html

doh

I read that a few days and forgot.

Thanks Rob

I have included hotseat multiplayer for my game, for times you don’t or can’t use the internet.

In my menu.lua file, the player chooses internet or hotseat gameplay.

I don’t want to initiate corona cloud when it’s not needed, in the case that the player chooses hotseat.

I’m wondering if I have to include the corona cloud init in my main.lua, or if it would be doable to only call that in the menu.lua file after the player chooses internet game play?

You can include it when you need it.

user login and registration is working  :)

now, I need to create a game lobby “room”

I think I’ll be able to get profile and news loaded, but I want to create a general waiting room that would list all connected users, and also be a chat room.

The general chat would want to be available all the time so it would need to persist beyond any particular user…

From there, I need to create a list of pending games, as well as a way for users to create or join a pending game.

Any examples or advice would be a great help.

So, I set everything up for Corona Cloud push notification and when I try to broadcast a message I get that  “No devices are registered for this game”… even though the device is registered, Access_Key and CC_Secret_Key are correct and when launching the App, it promoted a popup for allowing notification and set it to “allow”… 

I used the code Dave provided above and I followed the certificate tutorial and generated a pem file. 

What might be the cause of this issue? I even tried doing the whole thing again but no luck…

Hi,

We are truly trying to get these out ASAP, please just bare with us just a little longer, we will be releasing a multiplayer guide soon.

Please feel free to email me directly mohamed(at)coronalabs.com and let me see how we can help you in the mean time.

Thanks

-Mohamed

I don’t mean to criticize you guys, honestly.   I realize it’s a lot of work on your end.

I’m just hoping someone can give me something to look at so I can start getting it together.

I need the login part taken care of just so I can start to delve into chat, match making, leaderboards, etc.

I appreciate your efforts Mohamed  ;)

hey tbernard, actually you are 100% correct in asking for this, this is something that we should have/had!

So I appreciate you voicing this, everyone needs a little butt kicking from time to time. :slight_smile:

Hi mustafamsy, could you please try something for me. On the Portal, please set the unused Push mechanism to ‘Status = Disabled’ and try again.

Thanks

-Mohamed

Here is a simple register and login -

  local widget = require "widget"     CC\_Access\_Key = "xxxxxx" CC\_Secret\_Key = "xxxxxx" coronaCloud = require ( "corona-cloud-core" ) coronaCloud.init( CC\_Access\_Key, CC\_Secret\_Key )   -- This is for using the Cloud Dashboard gameNetwork = require( "gameNetwork" ) local params = { accessKey = CC\_Access\_Key, secretKey = CC\_Secret\_Key, } gameNetwork.init( "corona", params )   local currentAuthToken = ""  --variable to store the login 'authToken'   local function loginSuccess( event )     --store the 'authToken' on login success     currentAuthToken = coronaCloud.authToken     print("logged in") end   local function loginFailure( event )     --clear the 'authToken' on login failure     currentAuthToken = ""     print("login failure")     print(event.type) end   local function registrationHandler( event )     --code to handle the registration     --this is a logical place to call the login code     print("registered") end   Runtime:addEventListener( "LoggedIn", loginSuccess ) Runtime:addEventListener( "LoginError", loginFailure ) Runtime:addEventListener( "UserRegistered", registrationHandler )   local function btnLogin\_Click( event )   coronaCloud.loginAPI( "email", "password" ) end   local function btnRegister\_Click( event )   coronaCloud.registerUser( "firstname", "surname", "username", "email", "password" ) end   local btnLogin = widget.newButton{   label = "Login",   labelColor = { default={ 255, 255, 255, 255 }, over={ 0 } },   defaultColor = { 64, 153, 255, 255 },   overColor = { 64, 153, 255, 200 },   strokeColor = { 255, 255, 255, 255 },   width = 180,   height = 44,   fontSize = 24,   onRelease = btnLogin\_Click } btnLogin.x = display.contentCenterX btnLogin.y = display.contentCenterY - 50   local btnRegister = widget.newButton{   label = "Register",   labelColor = { default={ 255, 255, 255, 255 }, over={ 0 } },   defaultColor = { 64, 153, 255, 255 },   overColor = { 64, 153, 255, 200 },   strokeColor = { 255, 255, 255, 255 },   width = 180,   height = 44,   fontSize = 24,   onRelease = btnRegister\_Click } btnRegister.x = display.contentCenterX btnRegister.y = display.contentCenterY + 50  

In corona-cloud-core.lua set -

coronaCloudController.debugEnabled = true

To see lots of information.

Dave

Thanks Dave.

Now, does the CC_Access_Key, CC_Secret_Key, and the currentAuthToken get added to the top of every storyboard file, 

or just to the main.lua file…?

I wouldn’t be getting a user’s login info until they’ve moved to my menu.lua file, and then from there they go to the mainGame.lua

I don’t understand how it works…

should currentAuthToken be a global?

If someone can give a brief explanation in regards to these structural questions I would really appreciate it.

Thanks