Creating and connecting to a room

I am using Marmalade Quick 7.8 but I can't work out how to create a room. This is the code I am using

local client = LoadBalancingClient.new(appInfo.ServerAddress, appInfo.AppId, appInfo.AppVersion) client.lastTick = PhotonTime.timeFromStart() client.autoconnect = true client:connect() print(client:availableRoomsCount()) print(client:isConnectedToGame()) if(client:availableRoomsCount() == 0) then print("Create Room") client:createRoom({maxPlayers = 2, isVisible = true, isOpen = true}) end print(client:availableRoomsCount())

But it always shows the room count to be 0.

What am I doing wrong here?

Comments

  • You need to call client:service() regularly (usually in on-timer procedure) to let photon client communicate with server.
    Also it does not make sense to call client:createRoom() until client is connected to the lobby. Implement client:onStateChange(state) method to handle states and create room when state changes to LoadBalancingClient.State.JoinedLobby
  • edited August 2015
    Sorry, that code was only a snippet.
    This is the whole code I am using now:
    print("Multiplayer Test") local photon = require("photon") local PhotonTime = require("photon.common.util.time") local LoadBalancingClient = require("photon.loadbalancing.LoadBalancingClient") local LoadBalancingConstants = require("photon.loadbalancing.constants") local Logger = require("photon.common.Logger") local tableutil = require("photon.common.util.tableutil") local appInfo = require("cloud-app-info") local client = LoadBalancingClient.new(appInfo.ServerAddress, appInfo.AppId, appInfo.AppVersion) client.lastTick = PhotonTime.timeFromStart() client:connect() isConnected = false function client:onStateChange(state) stateName = LoadBalancingClient.StateToName(state) print("onStateChange", stateName) end function update(event) client:service() end system:addEventListener("update", update)

    But I don't get the JoinedLobby state change, only the ConnectedToMaster one. This is the output from the console:

    Multiplayer Test 08/06/15 14:07:13 INFO LoadBalancingClient: State: Uninitialized -> ConnectingToMasterserver 08/06/15 14:07:13 INFO LoadBalancingClient: Connecting to Master app-eu.exitgamescloud.com:5055 08/06/15 14:07:13 INFO PhotonConnect: app-eu.exitgamescloud.com:5055 start connection to host 08/06/15 14:07:13 INFO PhotonConnect: app-eu.exitgamescloud.com:5055 37.58.117.146 5055 successful start connection 08/06/15 14:07:15 INFO LoadBalancingClient: Master: Connected 08/06/15 14:07:15 INFO LoadBalancingClient: Master: Encryption Establishing... 08/06/15 14:07:16 INFO LoadBalancingClient: Master: Encryption Established 08/06/15 14:07:16 INFO LoadBalancingClient: Master: Authenticate... 08/06/15 14:07:17 INFO LoadBalancingClient: Master: Authenticated 08/06/15 14:07:17 INFO LoadBalancingClient: Master: Join Lobby... 08/06/15 14:07:18 INFO LoadBalancingClient: Master: Joined to Lobby 08/06/15 14:07:18 INFO LoadBalancingClient: State: ConnectingToMasterserver -> ConnectedToMaster onStateChange ConnectedToMaster
  • Now you are missing client::createRoom call. Put it into client:onStateChange handler when state changes to LoadBalancingClient.State.JoinedLobby
  • The state only changes to ConnectedToMaster, never JoinedLobby.
  • Yes. I see this in log. This is weird. Insdk sources, setting state to JoinedLobby is next line after printing "Joined to Lobby".
    What lua sdk version do you use?
    Can you please add onStateChange handler and print state numeric values?
    In fact Photon allows room creation and random join right after connecting to the master (no lobby required). But i'm not sure what is your final state. You can try.
  • I am using the Marmalade sdk, version 7.8.

    I changed the print function to print out the numerical values. Here is the log:

    Multiplayer Test 08/08/15 19:19:23 INFO LoadBalancingClient: State: Uninitialized -> ConnectingToMasterserver 08/08/15 19:19:23 INFO LoadBalancingClient: Connecting to Master app-eu.exitgamescloud.com:5055 08/08/15 19:19:23 INFO PhotonConnect: app-eu.exitgamescloud.com:5055 start connection to host 08/08/15 19:19:24 INFO PhotonConnect: app-eu.exitgamescloud.com:5055 37.58.117.146 5055 successful start connection 08/08/15 19:19:27 INFO LoadBalancingClient: Master: Connected 08/08/15 19:19:27 INFO LoadBalancingClient: Master: Encryption Establishing... 08/08/15 19:19:29 INFO LoadBalancingClient: Master: Encryption Established 08/08/15 19:19:29 INFO LoadBalancingClient: Master: Authenticate... 08/08/15 19:19:29 INFO LoadBalancingClient: Master: Authenticated 08/08/15 19:19:29 INFO LoadBalancingClient: Master: Join Lobby... 08/08/15 19:19:31 INFO LoadBalancingClient: Master: Joined to Lobby 08/08/15 19:19:31 INFO LoadBalancingClient: State: ConnectingToMasterserver -> ConnectedToMaster onStateChange 2

    How can I do this?
  • Marmalade's Photon SDK is outdated.
    I'm not sure if we can update it. It depends on marmalade team as well. We trying to contact them.
  • Implement client:onStateChange(state) method to handle states and create room when state changes to LoadBalancingClient.State.JoinedLobby


    _______________
    NOOR
Sign In or Register to comment.