Migrating to photon cloud.

nanda
edited February 2012 in Native
i have completed an app in ios(with demo_iPhone_realtime_objc as code base) with a local photon server instance.Now I am planning to move to photon cloud. Can you suggest me way to do it ?

I have already tried with load balancing app (your demo code) and can able to successfully connect to photon cloud. But i dont how to migrate the existing app which run successfully in local photon server instance to photon cloud.

Comments

  • First of all: Photon Cloud does not allow customer server code. It runs the plain LoadBalancing code.

    If you application only uses plain LoadBalancing you can switch by
    1) exchange your local server URI (localhost or 127.0.0.1) with cloud URI (app.exitgamescloud.com)
    2) Register an appid https://cloud.exitgames.com/Dashboard
  • Sorry,You misunderstood my question. I didnt change any code on server side(photon server). I need my existing ios app to connect to photon cloud service.

    i have registered and got the appid. i need to know what are the changes to be done on client side code for migrating to photon cloud service.

    From the above reply Whether it is possible to connect your demo code (demo_iPhone_realtime_objc) with the photon cloud service by providing the following details in PhotonDemo.mm file
    1) In createConnection method
    [m_pLitePeer Connect:[NSString stringWithUTF8String:@app.exitgamescloud.com]];
    2) Where to provide the appid?.
  • the realtime demo is not compatible to the Cloud, as it relies on the Lite app running on the serverside, but the Cloud runs the LoadBalancing app instead. So you would have to migrate your client side network logic from Lite to LoadBalancing.
    Have a look at the differences between the public APIs of classes LitePeer and LoadBalancingClient for what you have to change. The ingame logic of the LoadBalancing app is pretty much similar to the one of Lite, so it should be quite easy to migrate that part.
  • LoadBalancing app get crashed continuously in iphone 5.0 stimulator, when i Pressed the create game button (for the second time).On first click action i can able to successfully connect to cloud sever and after that i pressed on leave game button. The crash happened on second time click action for the create game button .
  • Afaik this is a known bug and a fix will be available with the next release probably by the end of this week.
  • ok thanks.

    How to get the available gameList from the photonCloud as soon as the player get connected?.
  • nanda wrote:
    ok thanks.

    How to get the available gameList from the photonCloud as soon as the player get connected?.
    1. Make sure, that you are currently in the lobby (if you have not explicitly set autoJoinLobby to false or called leaveLobby, this is the case as soon as you have been connected and as long as you are not in a gameroom or in the process of entering one). You can check the the IsInLobby property therefor.
    2. Now the GameList-property will hold the list of open gamerooms, as soon as the client received the initial list-event form the server and the value of this property will alway be on the most up to date state by serverside update events in short intervals, as long as you stay in the lobby. Just leave the lobby, if you don't want to receive further updates on the gamelist anymore.
  • 1.How to access the gameList (which is an NSDictionary) values?. I want to get GameName and number of player playing in each game present in the gameList?
    When i printed the gameList in the [networkLogic run] method under STATE_CONNECTED switch case.
    "<KeyObject: 0x682c650>" = "<LoadBalancingRoom: 0x682b420>. How to access the values present in the gameList?


    2.i am getting "receiveing client 2001 error" which is printed in the console most of time when i tried to connect?
  • nanda wrote:
    1.How to access the gameList (which is an NSDictionary) values?. I want to get GameName and number of player playing in each game present in the gameList?
    When i printed the gameList in the [networkLogic run] method under STATE_CONNECTED switch case.
    "<KeyObject: 0x682c650>" = "<LoadBalancingRoom: 0x682b420>. How to access the values present in the gameList?
    wprintf(L"gameList: \n");
    for(NSUInteger i=0; mClient.GameList.count; ++i)
       wprintf(L"room %d - name: %ls   playerCount: %d\n", i,  &#91;mClient.GameList objectForKey:&#91;mClient.GameList.allKeys objectAtIndex:i&#93;&#93;.ID.UTF32String, &#91;mClient.GameList objectForKey:&#91;mClient.GameList.allKeys objectAtIndex:i&#93;&#93;.PlayerCount);
    wprintf(L"\n");
    

    nanda wrote:
    2.i am getting "receiveing client 2001 error" which is printed in the console most of time when i tried to connect?
    This is the errocode for the authentication timeout, which triggers, when the client has not been able to finish the connect-estabslishEncryption-authenticate procedure within RESPONSE_TIMEOUT milliseconds. This constant is set to 5.000, which means, when you get this error, either you try to conect to an invalid address or your ping on connect is already that bad, that it is practically impossible to play any kind of realtime game.
    Of course you should also make sure, that you are calling service() regularly, so that the Photon client can communicate with the server.
  • thanks kaiseludi for your reply.

    A Slight modification in your code
     wprintf(L"gameList: \n");
        for(NSUInteger i=0; i &lt; mLoadBalancingClient.GameList.count; ++i)
            wprintf(L"room %d - name: %ls   playerCount: %d\n", i,  &#91;&#91;&#91;mLoadBalancingClient.GameList objectForKey:&#91;mLoadBalancingClient.GameList.allKeys objectAtIndex:i&#93;&#93; ID&#93; UTF32String&#93;, &#91;&#91;mLoadBalancingClient.GameList objectForKey:&#91;mLoadBalancingClient.GameList.allKeys objectAtIndex:i&#93;&#93; PlayerCount&#93;);
        wprintf(L"\n");
    


    How to get notified for the gameList update ?
  • Currently there is no functionality of notifying the app, that there has been an update of the gamelist, you are just supplied with the most up to date data, but get not informed, when it is getting updated. However this may be added in the future.
    For now you can achieve such functionality by subclassing LoadBalancingClient and overriding its onEvent()-method like in the following example:
    - (void) onEvent:(EventData*)eventData
    {
    	&#91;super onEvent:eventData&#93;;
    	switch(eventData.Code)
    	{
    		case EventCode::ROOM_LIST:
    			// notify app, that the initial room list event has come in
    			break;
    		case EventCode::ROOM_LIST_UPDATE:
    			// notify app, that a roomlist update event has come in
    			break;
    		default:
    			break;
    	}
    }
    
  • by Kaiserludi :
    Afaik this is a known bug and a fix will be available with the next release probably by the end of this week.

    Can i know exact date for bug fix release of ios version.
  • nanda wrote:
    by Kaiserludi :
    Afaik this is a known bug and a fix will be available with the next release probably by the end of this week.

    Can i know exact date for bug fix release of ios version.
    It went online 2 hours ago.
  • hi kaiserludi,

    There was one new bug in roomList update. RoomList is not getting updated properly. pls verify it and reply me.
    [mLoadBalancingClient opJoinRandomRoom]; is working properly but [mloadBalancingClient opJoinRoom:gameId] is not working properly because of the roomList update.
    If you need i will also provide the Log details.

    My project is getting delayed pls look in to it and reply me as soon as possible
  • Hi nanda.
    I have just tested it and in my tests roomlists worked just fine:
    I went online with 3 clients, client 1 stayed in the lobby all the time and printed out the list of open rooms. Client 2 created a room -> one room listed in the roomlist of client 1. client 3 also created a room -> 2 rooms listed. Client 3 left its room -> 1 room listed. Client 3 joined client 2's room -> now a the one listed room has a playercount of 2.

    Perhaps you can explain you test scenario to me, so that I can try to reproduce the exact same situation.
    Also please keep in mind, that it takes a small amount of time for the room to get listed.
  • Your test case is working fine for me too. Have you checked for the roomList in client2 and client3.
    pls test for the roomList in client 2 and client 3 .You can see the bug.
    If you didnt see the bug try my test case below

    My test case:
    Two clients(client 1 and client 2).
    slight Modified in the [networkLogic run] method as
    under the swith case STATE_CONNECTED:
    case STATE_CONNECTED:
         //added the code for printing the roomList.
          for(NSUInteger i=0; i &lt; mLoadBalancingClient.RoomList.count; ++i)
                        NSLog(@"room %d - name: %@   playerCount: %d\n", i,  &#91;&#91;mLoadBalancingClient.RoomList objectForKey:  &#91;mLoadBalancingClient.RoomList.allKeys objectAtIndex:i&#93;&#93; Name&#93;, &#91;&#91;mLoadBalancingClient.RoomList objectForKey:&#91;mLoadBalancingClient.RoomList.allKeys objectAtIndex:i&#93;&#93; PlayerCount&#93;);
    
    //rest of the code as you given
    

    1.connect the client 1 and client2 to the lobby.(now roomList in both the client will be empty).
    2.Click on the CreateGame button on client 1. ( now the roomList will be updated and show in client 2).
    3.Click on the leave game button on client 1. (now roomList will be empty in both client).
    4.Now click createGame button on client 2.(roomList will not be updated in the client 1).


    [Note: Until you create a room or join room there was no bug as you did for client 1. Try create a game or join a game for the client1 and then test as you said].
  • Thanks. In that scenario it doesn't work for me, too. I will have a look, whats going wrong there.
  • nanda wrote:
    hi kaiserludi,

    There was one new bug in roomList update. RoomList is not getting updated properly. pls verify it and reply me.
    [mLoadBalancingClient opJoinRandomRoom]; is working properly but [mloadBalancingClient opJoinRoom:gameId] is not working properly because of the roomList update.
    If you need i will also provide the Log details.

    My project is getting delayed pls look in to it and reply me as soon as possible
    Well, it has not really been a new bug, but should have been occurred with all previous versions, too.
    However it's fixed now and as you have mentioned, that it is urgent for you and the fix won't get available in the download area before tomorrow, please use this link:
    http://dl.dropbox.com/u/4296291/Photon- ... ud_SDK.zip

    For your Information:
    It has not really been an issue with gamelist-updates, but with automatically joining the lobby, which has not been working, when returning from a gameroom (You only get gamelist updates when inside a lobby, so that you can save your clients from this traffic by not joining it, if you do not use gamelists anyway).
  • thanks you kaiserludi for your help. Now the roomList is properly updating.

    In previous post i asked you about roomList update and you replied with
    Currently there is no functionality of notifying the app, that there has been an update of the gamelist, you are just supplied with the most up to date data, but get not informed, when it is getting updated. However this may be added in the future.
    For now you can achieve such functionality by subclassing LoadBalancingClient and overriding its onEvent()-method like in the following example:

    i have created a new Class called GameListUpdate:LoadBalancingClient
    In NetworkLogic.h i have added this code
    @class GameListUpdate;
    and replaced the LoadBalancingClient* mLoadBalancingClient with GameListUpdate* mLoadBalancingClient;

    and in networkLogic.mm i have added this code
    #import "LoadBalancingClient.h"
    #import "EventCode.h"
    @interface GameListUpdate : LoadBalancingClient {
        
    }
    @end
    
    @implementation GameListUpdate
    
    - (void) onEvent:(EventData*)eventData
    {
        NSLog(@"%s",__FUNCTION__);
        &#91;super onEvent:eventData&#93;;
        switch(eventData.Code)
        {
            case 230:
                // notify app, that the initial room list event has come in
                NSLog(@"inside 230");
                &#91;&#91;NSNotificationCenter defaultCenter&#93; postNotificationName:@"gameListUpdated" object:nil&#93;; 
                break;
            case 229:
                // notify app, that a roomlist update event has come in
                NSLog(@"inside 229");
                &#91;&#91;NSNotificationCenter defaultCenter&#93; postNotificationName:@"gameListUpdated" object:nil&#93;; 
                break;
            default:
                break;
        }
    }
    @end
    

    But still i am not receiving any nslog in onEvent method. Am i doing something wrong or please help me with some code for the roomList update notification.
  • Hi again.

    Your code is working perfectly for me.

    Have you checked, that you have replaced
    &#91;LoadBalancingClient alloc&#93;
    
    with
    &#91;GameListUpdate alloc&#93;
    
    ?
  • i forget to replace it.
    ThankYou dude for all your help.
  • i implemented my game disconnection logic in the
    - (void) connectionErrorReturn:(int)errorCode
    - (void) clientErrorReturn:(int)errorCode
    - (void) serverErrorReturn:(int)errorCode
    

    i often receive the following message in the gdb
    2012-02-25 14:50:14,056369 INFO    CPhotonPeer.cpp                PhotonPeer_internal_send()                                   line:   694 - payload will be sent in 2 fragments
    2012-02-25 14:50:14,327160 INFO    CPhotonPeer.cpp                PhotonPeer_internal_serializeToBuffer()                      line:  1389 - Info: UDP package is full. Commands in Package: 2 . Commands left in queue: 2
    2012-02-25 14:50:14,827085 INFO    CPhotonPeer.cpp                PhotonPeer_internal_serializeToBuffer()                      line:  1389 - Info: UDP package is full. Commands in Package: 1 . Commands left in queue: 2
    2012-02-25 14:50:15,827100 INFO    EnetPeerLayer.cpp              sendOutgoingCommands()                                       line:    82 - going to resend pCommand: time: 21999 = 21607 sentCount: 1, original sentTime: 20999
    2012-02-25 14:50:15,827195 INFO    CPhotonPeer.cpp                PhotonPeer_internal_serializeToBuffer()                      line:  1389 - Info: UDP package is full. Commands in Package: 1 . Commands left in queue: 1
    2012-02-25 14:50:17,826943 INFO    EnetPeerLayer.cpp              sendOutgoingCommands()                                       line:    82 - going to resend pCommand: time: 23998 = 23714 sentCount: 2, original sentTime: 20999
    2012-02-25 14:50:20,326901 INFO    EnetPeerLayer.cpp              sendOutgoingCommands()                                       line:    82 - going to resend pCommand: time: 26498 = 26430 sentCount: 3, original sentTime: 20999
    2012-02-25 14:50:20,327009 INFO    CPhotonPeer.cpp                PhotonPeer_internal_serializeToBuffer()                      line:  1389 - Info: UDP package is full. Commands in Package: 1 . Commands left in queue: 1
    2012-02-25 14:50:20,826839 INFO    CPhotonPeer.cpp                PhotonPeer_internal_serializeToBuffer()                      line:  1389 - Info: UDP package is full. Commands in Package: 1 . Commands left in queue: 1
    2012-02-25 14:50:25,326656 INFO    EnetPeerLayer.cpp              sendOutgoingCommands()                                       line:    49 - disconnect due to retry timeout (max retry time) time: 31498   originalSentTime: 20999
    2012-02-25 14:50:25.326 SketchWFriendCP&#91;1900:207&#93; -&#91;NetworkLogic connectionErrorReturn:&#93; with errocode = 1040
    

    i am sending the message in unreliable mode.
  • This shows that some of your operations are too big to be sent in a single udp-packet (one packet is 1.200bytes including overhead, which depending on the kind of data, which you send, means about 1.000bytes of payload) and is therefor automatically split up into 2 fragments. In the case of fragmentation Photon will send all fragments of one operation reliable, no matter if the operation would have been sent unreliable otherwise.
  • ok kaiserludi, then the only way to fix this bug is we need to check for the data length (1.000bytes of payload)and split it before sending to photon server or suggest me some way to fix this bug.
  • The reasoning between making fragments reliable is that they are all needed to re-assemble the single but big request.
    Unless you turn the big chunk into multiple smaller but "complete" commands, you would only re-implement fragmentation.