Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Third Party Photon Unity Networking

Discussion in 'Multiplayer' started by tobiass, Aug 23, 2011.

  1. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    EvilDingo: Hehe, yes, for Australia the server location is probably a worst-case place: Chicago, USA.
    It's weird that the PhotonCloud setting won't work for you but the SelfHosted does. Maybe you should remove the settings .asset file and re-create it through the editor. Fill in the same appId you use now.

    legend411: There are no concrete plans yet but the idea is of course good. Our todo list is quite long already so this won't make it in until Q2 2012. As said in various places, it can be very costly to host all those instances (one per game / room). But let's not start this discussion over ;)
     
  2. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,242
    May I ask you for stating a few of your todo points here?
    Or exists a public roadmap on your site?
    Really would like to get some insight into Photon's development :)

    Greetings
     
  3. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    :)

    Our todo list is not public, sorry.
    I'm not sure how much we want to disclose at the moment, so just very high level and without order: We're working on the cloud service (surrounding hosted Photon) and Photon Unity Networking (PUN). In PUN, we will take a look at lag compensation, saving bandwidth and performance and we want to implement true grouping (interest management).
     
  4. sijj

    sijj

    Joined:
    May 3, 2011
    Posts:
    12
    hi, i am new to unity and photon networking and i am converting my Maltiplayer game made using ultimate unity networking into Photon networking. with the tutorial(came with sdk) i have converted my all unity networking code to photon networking using photon converter. i have fixed all the bugs but at runtime i have having problem with PhotonView.RPC method. it is giving me this error.

    "PhotonView with ID 1000 has no method "SetCurrentCharacter" that takes 0 argument(s):" and my code is as follows.

    void SetupAvatar(int characterId)
    {
    if (character != null)
    PhotonNetwork.Destroy(character);
    character = (GameObject)PhotonNetwork.Instantiate(characterPrefabs[characterId], Vector3.zero, Quaternion.identity, 0);

    // Sync Avatar configuration
    if (PhotonNetwork.isNonMasterClientInGame || PhotonNetwork.isMasterClient) {
    Debug.Log("Before Set Current character!!!");
    photonView.RPC("SetCurrentCharacter", PhotonTargets.AllBuffered);
    }
    }

    [RPC]
    void SetCurrentCharacter(PhotonViewID characterViewId)
    {
    Debug.Log("Set Current Character Method!!!");
    PhotonView view = PhotonView.Find(characterViewId.ID);

    if (view == null)
    {
    PhotonNetwork.Destroy(gameObject);
    return;
    }

    character = view.gameObject;
    character.transform.parent = transform;
    character.transform.localPosition = Vector3.zero;
    character.transform.localRotation = Quaternion.identity;

    _animation = character.animation;
    if (_animation != null)
    enabled = true;
    }

    i do not know how to get the photon View id so i can pass it as a parameter in this method.

    any help will be greatly appreciative. thanks.
     
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    I just got mail that v1.4.1 is live in the Asset Store now.
    I updated the original post with the version info. In short: We fixed a lot of bugs concerning instantiation and RPCs for players who join later on. We also fixed and refactored a lot of other stuff while keeping the framework identical to that of v1.3.

    The cloud is up to date for the new solutions but compatible with v1.3 of this package.
    If you host yourself, you need to update your server as well to at least Photon v3 RC5. Sadly, we missed a bug in that server-build which means it is leaking memory over time. Expect RC6 soon (without anything but bugfixes).

    Update: RC5a is now available and should fix the memory leak. Please use this version.
     
    Last edited: Nov 11, 2011
  6. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    TobiaS: Just wanted to say that I think you/Photon are doing a great job supporting Unity and the Unity community. Keep up the good work!
     
  7. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    The message explains all. Your RPC sends no arguments, but your method needs an int argument.
     
  8. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    Thank you!
    I'd like to return that compliment. You and many others make this community a great place to be.
     
  9. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    I just uploaded a new Photon v3 Server SDK "RC5a", which should fix the memory leak.

    For development, there is likely not a big difference.
    If you are going to host Photon yourself, don't go live with RC5. Use RC5a at least.
     
  10. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    We just found out that the background thread which was supposed to keep the connection (while you load something) was not started when you disabled the message queue.
    The fix is a single '!' in the code, as described here:
    http://forum.exitgames.com/viewtopic.php?f=17&t=1047&p=5022#p4995

    We will submit an updated package to the asset store soon.

    While I'm posting:
    We found a few bottlenecks in our protocol client code and fixed those. It won't matter for games with low traffic but if your game uses a lot of bandwidth, expect a boost with the next update ;)
     
    Last edited: Nov 17, 2011
  11. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,075
    So, just to be sure, as one of the comments to the asset mentioned they got p2p support from Photon... Photon routes everything through its dedicated server over the Internet... so it's not possible to get p2p or LAN-only/bluetooth etc connections from Photon, right?
     
  12. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    Yes, Photon always has a dedicated server between the players.
    Unity Networking also uses a server but this can also be hosted by some player (it's not P2P either).
    For webplayers, noone (aside Unity) would be able to implement P2P or player-hosted games.
    For mobiles, a dedicated (non player-hosted) server has the huge benefit that players can always connect.
     
  13. shinriyo_twitter

    shinriyo_twitter

    Joined:
    Aug 12, 2011
    Posts:
    328
    Hi there I have a question.
    I am not good at English, so I can't understand well.

    I registered account and I downloaded asset Photon Networking Asset.

    When I inport the asset, it ask me mail address and I fill out my e-mail address.

    However It set setting blow
    Server Address 127.0.0.1
    Port 5055

    I think it is server side service. but, why it set local address?
    Or, it is only engine service so, Must I get cloud server?

    is it Windows only?
     
  14. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    shinriyo:
    If you registered before, your email is already connected to a app on the cloud. In this case, the wizard does not get it automatically.
    To get your account's appId: Login to exitgamescloud.com/dashboard. You got a mail to set a password when you registered or you can request a new mail (only the login link from the last password-request is valid).

    Once you know your (secret) appId, you can fill in these values to the PhotonServerSettings:
    hosting type: PhotonCloud
    server address: app.exitgamescloud.com
    server port: 5055
    app id: <the appId assigned to your account>
     
  15. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    I just got the confirmation that Photon Unity Networking v1.5 is now in the asset store. This is what's new:

    v1.5
    Fixed: Background thread now starts when message queue is paused (for loading something, by setting isMessageQueueRunning to false)
    Fixed: Destroy(gameObject) now removes the instantiate from the server's cache (players joining later won't get the instantiate - just as expected)
    Fixed: Some of the Log output was not included in "more verbose" log levels
    Updated: Client library to that of Photon Unity SDK v3.0.0.7 which uses less memory and gives you some performance if your game has a lot of traffic / players
    Removed: some obsolete values in the PUN framework
    Added: LoadbalancingPeer class and moved around some other classes. The goal is to extract some classes for general use in DotNet (without Unity, if needed)
    Note: If you host your own Photon server, please update to Photon v3 SDK RC7 (it has some memory fixes, too)
    Note: Destroy() for views is not yet working for players who join late into existing games. This is not a buffered action. We're on it.

    Don't expect too much from the performance changes! Unless you have a big number of players and objects to update, this didn't affect your game so far ;)


    Edit: The multiplayer "Viking Demo" and "Angry Bots Demo" are also using PUN 1.5 now.
     
    Last edited: Nov 22, 2011
  16. shinriyo_twitter

    shinriyo_twitter

    Joined:
    Aug 12, 2011
    Posts:
    328
    Hi TobiasS

    Thank you a lot. I logged-in via Unity!
    Is it free to use forever?
     
  17. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    Almost.
    I think for the next 1..2 months it stays free but the recent developer newsletter announced this: "Monthly introductory fees will start at US$9 for 100 concurrent users".
    We will tune the service quite a bit before it goes commercial but we also have a few games live on it already.
     
  18. DamienJeuVideo

    DamienJeuVideo

    Joined:
    Nov 7, 2011
    Posts:
    6
    Hi everyone,

    I'm trying to use Photon Server 3, but I don't see how can I use it for my game.

    Server part, I have to create a new project and copy/paste code from LobbyLite project ? Is quite difficult for me to understand where I can programming specific server code (like mysql loggin, game logic or matchmaking).

    After that I'm very interesting by MasterServer but it's difficult to understand how can I use it. Is it the first app who player connect ? So MasterServer have to use Lite code I suppose ?

    Can I imagine something like a MasterServer with Lite on IP 192.168.0.1 and another photon server app called MysqlLoggin on another IP 192.168.0.2 ? And after that a Chat on another IP... ? If I do that, I have to paid 3 licence ?

    I hope your understand my question :)

    thanks;
     
  19. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Please see the first post of this topic, there is now the Unity plugin for Photon that makes live much easier. You don´t need to download the litelobby or photon server.
     
  20. Kaiserludi

    Kaiserludi

    Joined:
    Jan 21, 2009
    Posts:
    94
    Well, actually it depends on his needs:
    - If he does not need to add any custom server side code and does not need any client side low level access, then he can use PUN with the Exitgames Cloud.
    - If he needs to add custom server side code, but does not need any client side low level access, then he can use PUN with a self hosted Photon 3 server.
    - If he does not need to add any custom server side code, but needs client side low level access, then he can use the normal Photon Unity client with the Exitgames Cloud.
    - If he needs to add custom server side code and needs client low level access, then he has to use the normal Photon Unity client with a self hosted Photon 3 server.

    However the second and third situation are pretty rare: Normally you either need client low level access to enhance the client side with custom functionality and a self hosted server to enhance the server side with customfunctionality or you don't need either of the too and can go with PUN and the cloud.
     
  21. DamienJeuVideo

    DamienJeuVideo

    Joined:
    Nov 7, 2011
    Posts:
    6
    Unfortunately is it what I need.
     
  22. Kaiserludi

    Kaiserludi

    Joined:
    Jan 21, 2009
    Posts:
    94
    In this case this is the wrong thread ;)

    I would recommend to not copy-and paste the LiteLobby-Apllication into your own Photon Application, but to instead let your own Application either inherit from LiteLobby or let it wrap LiteLobby, so that you do not have to merge the LiteLobby code into your project again on every update. Then you would just overwrite functionality, which you want to change or enhance.

    You would use the LoadBalancing Application in that case, which actually consists out of two Applications: Master and Gameserver. Your clients connect to the Masterserver and crat or join a game there with opCreateGame)/opJoinGame(). If this operation is successful, then the masterserver will supply you with the address and port of a gameserver in the operationResponse. Now youdisconnect from the master and reconnect to the supplies gameserver-url, where you will create/join the gameroom again.
    If more then one game-server is available then for joinGame() the Master will find out for you, on which gameserver the room, which you want to join, is running, anf for creategame() the Master will decide, on which gameServer youshould go to create it, depending on configurable aspects like the amount of open rooms, the amount of palyers, the cpu in use, etc. of the available gameservers.

    On the Masterserver there will not run Lite, but the Masterserver-Application and on the Gameservers the gameserver application.
    In the pre-configured setup, when connecting rom a local client, the masterserver will be available on "localhost:5055", when connecting via udp and on "localhost:4530" for clients, which connect via tcp.
    The client should really not connect to any hardcoded game-server urls, but use the ones, provided by the master, but with the preconfigured setup with two gameservers those wil be "localhost:5056" and "localhost:5057" for udp and "localhost:4531" and "localhost:4532" for tcp.
    Of course this will only be suitable for testing purposes. In a live environement, you will host every gameserver on a separate machine with a separate ip.
    Every gameserver instance has a config file, where you will have to specify the address and port, which the master should use, to reach this gameserver and the address and port, which the master should send the clients, to use for reaching this gameserver. Normally both can be the same public ip of the machine, where the gameserver is running on. In case, that the gameserver is running on the same machine like the master, you can use the local-ip for communication with the master, but you will still have to configure the public ip for the clients to use, so that also clients, which are not running on the same machine, can access the gameserver (relevant when testing with mobile clients!). Of course you will also have to configure the master address and port in every gameservers config-file.
    By the way: As the gameservers will register their selves on the master server, as soon, as you start them, you can add and remove new gameservers at any time depending on your needs, without having to configure anything on the master or even having to restart the master.
     
  23. Tomo-Games

    Tomo-Games

    Joined:
    Sep 20, 2010
    Posts:
    220
    Congrats on the new 1.5 update. :D

    Ahh so is PhotonNetwork.Destroy now working? Didn't Destroy(gameObject) actually call Destroy(view) internally? Sorry haven't had time to download and see for myself. Tobias I'm Tomo in the exit games forum.

    Happy Thanksgiving!
     
    Last edited: Nov 24, 2011
  24. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    Tomo: Hey!
    PhotonNetwork.Destroy() will work for GameObjects if you used Instantiate to create the GO. Those prefabs have to contain at least one PhotonView and on Destroy() those will be removed as well.
    We're not happy yet with destroying PhotonViews individually. Especially because their objects might be network-instantiated or they might be created individually as component to existing GOs.

    So, use Destroy() for GameObjects instead for views.

    Happy Thanksgiving :)
     
  25. shinriyo_twitter

    shinriyo_twitter

    Joined:
    Aug 12, 2011
    Posts:
    328
    Hi there

    I used the sample of Phoon's sample that the constracter character's chat

    I modified to OnControllerColliderHit in ThirdPersonController for detect Player and Player.
    but it didn't work.
    Code (csharp):
    1.  
    2. void OnControllerColliderHit(ControllerColliderHit hit)
    3. {
    4.     if (hit.gameObject.tag == "Player") {
    5.         Debug.Log("hello"); // no working
    6.     }
    7. }
    8.  
     
  26. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    shinriyo: The supplied code does not look like something network related. Try getting help in the other forums on this board. The question would be: How to get OnControllerColliderHit called.

    In general: For concrete issues, it would be better to start a new thread in our forum. Then it won't get lost so easily.
     
  27. shinriyo_twitter

    shinriyo_twitter

    Joined:
    Aug 12, 2011
    Posts:
    328
    Hi TobiasS

    OK. I will create new thread
     
  28. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    A new update is in the asset store. It is strongly recommended to upgrade your game to this, as we improved the stability of connections.
    Whats new:

    v1.6:
    Updated: Client library to v3.0.0.8 which brings important fixes and some Unity-targeted performance optimizations
    Changed: Default update rate is 10/second now, which is a better standard (send-rate stays at 20/second)
    Changed: During disconnect, operation responses are now ignored. Example: Join a random game, then disconnect before entering the room. This now disconnects you (instead of getting you in the room).
    Changed: Internals how the PhotonStream works. This is now leaner and faster and is the first step to optimized syncing
    Note: This is incompatible with previous PUN versions. Don't run separate PUN versions in one game

    The Photon Viking Demo and the Photon Angry Bots are also updated.
     
  29. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    We updated the package in the Asset Store once more. This time we got these changes:

    v1.7
    Changed: In event/callback methods for OnPhotonCreateGameFailed and OnPhotonJoinGameFailed, renamed "Room" to "Game". This is important to adjust!
    Changed: PhotonViews are now usable via Awake() on any script (previously they were setup between Awake and Start)
    Fixed: No more broken connection if Join/Create/JoinRandom/LeaveRoom is called during connection or disconnection: an error is logged instead.
    Changes: cacheInstantiationCount is ONLY reset in LeftRoomCleanup() if autoCleanUpPlayerObjects is true
    Fixed: cacheInstantiationCount is now compared to ushort.MaxValue (with u in ushort)
    Added: New GameVersion argument to Connect*, plus new PUN version. These version strings make sure only clients that use the exact same game version and PUN version will be able to play together.
    Added: Information about versioning in documentation
    Changed: Unregister allocated viewIDs after PhotonNetwork.Destroy*
    Fixed: Compatibility with Unity 3.5 (excluding Flash export for the time being)
    Changed: Destroy was sent twice for views in some cases. Cleaned up. As this was no real bug, this is no fix.
    Updated: to new client lib (v3.0.0.9)
    Fixed: Relatively rare encryption issue which led to a disconnect.

    As PUN versions might cause new clients to be incompatible with older ones, we now add pun's version to the game's version for authenticate. This separates newer clients from others automatically. Keep this in mind, while you develop ;)
    Also make sure to keep the first of these changes in mind, if you use OnPhotonCreateGameFailed or OnPhotonJoinGameFailed. Those won't be called anymore.
     
  30. imkira

    imkira

    Joined:
    Dec 26, 2011
    Posts:
    39
    Hello there, thank you for Photon, it is a beautiful piece of software I have been experimenting for a while.
    I would like to confirm whether there is a bug when calling a Connect that fails due to no networking connection available where OnFailedToConnectToPhoton is not called (as I understand it should be). As a quick test you can simply unplug the network cable, but actually this happened to me on the mobile when network access is temporarily unavailable.
    As you can see in the following log NetworkingPeer:DebugReturn gets called but OnFailedToConnectToPhoton doesn't.

    Code (csharp):
    1.  
    2. E/Unity   (16650): Dns.GetHostEntry() failed: System.Net.Sockets.SocketException: No such host is known
    3. E/Unity   (16650):   at System.Net.Dns.GetHostByName (System.String hostName) [0x00000] in <filename unknown>:0
    4. E/Unity   (16650):   at System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) [0x00000] in <filename unknown>:0
    5. E/Unity   (16650):   at ExitGames.Client.Photon.NConnect..ctor (ExitGames.Client.Photon.EnetPeer npeer, System.String ipPort) [0x00000] in <filename unknown>:0
    6. E/Unity   (16650): UnityEngine.Debug:Internal_Log(Int32, String, Object)
    7. E/Unity   (16650): UnityEngine.Debug:LogError(Object)
    8. E/Unity   (16650): PhotonHandler:DebugReturn(DebugLevel, String)
    9. E/Unity   (16650): NetworkingPeer:DebugReturn(DebugLevel, String)
    10. E/Unity   (16650): ExitGames.Client.Photon.NConnect:.ctor(EnetPeer, String)
    11. E/Unity   (16650): ExitGames.Client.Photon.EnetPeer:Connect(String, String, Byte)
    12. E/Unity   (16650): ExitGames.Client.Photon.PhotonPeer:Connect(String, String, Byte)
    13. E/Unity   (16650): NetworkingPeer:Connect(String, String, Byte)
    14. E/Unity   (16650): PhotonNetwork:Connect(String, Int32, String, String)
    15. E/Unity   (16650): PhotonNetwork:ConnectUsingSettings(String)
    16. E/Unity   (16650): $:MoveNext()
    17.  
    Thank you in advance for your comments.
     
  31. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    Yes, this seems to be a bug.
    Thanks for pointing us to it. I have to unplug my network cable more often ;)

    Will be fixed in the next update! Do you need a workaround before the next update is coming (probably 2 weeks or so)?
     
  32. the_gnoblin

    the_gnoblin

    Joined:
    Jan 10, 2009
    Posts:
    722
    I'm happy that this bug will be fixed soon! :)
     
  33. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,089
    Are there any performance benefits to PUN vs. Unity Networking?
     
  34. imkira

    imkira

    Joined:
    Dec 26, 2011
    Posts:
    39
    Hi TobiasS, thank you very much for your prompt reply and support :)
    As I am still in the process of R&Ding with Photon I can perfectly wait for the next update.

    By the way, I found some other connectivity/API problems I run into very easily when using Photon for Unity that I still don't quite understand but I suppose it is either related to a timing issue, a networking-synchronization-via-the-cloud-related thing or most probably the coder's (my) fault. Anyway, some of them are just doubts or ideas/thoughts about my experience on using Photon for Unity. Any comments are welcome!

    • PhotonNetwork.ConnectUsingSettings("foo") -> OnJoinedLobby() -> PhotonNetwork.JoinRoom("bar") doesn't create a channel if it doesn't exist as opposed to what the docs say. Instead I get a "joinGame failed, client stays on masterserver: OperationResponse 226: ReturnCode: 32758 (Game does not exist)."
    • PhotonNetwork.ConnectUsingSettings("foo") -> OnJoinedLobby() -> PhotonNetwork.GetRoomList() always returns 0 rooms even when there is more. According to the docs "and fetching the room list is as easy as calling PhotonNetwork.GetRoomList(). This list is always up to date (no need to fetch/poll etc).", which appears to contradict this result I am getting. I have noticed that if I either place a sleep (via a yield WaitForSeconds(foo)) or if I wait for the asynchronous OnReceivedRoomList/OnReceivedRoomListUpdate and call PhotonNetwork.GetRoomList() from there I can get a non-empty room list. It appears obvious to me that what GetRoomList does is it "gets the last cached room list", not a "the current room list on the server" as it appears to be a non blocking operation. I really love non-blocking I/O but I think there is space for improvement with regards to the API in the sense of using a more event-driven I/O-like API. For example, if you could do something like a PhotonNetwork.GetRoomList(OnMyGetListSuccess,
      optionally_a_OnMyGetRoomListFailed, optionally_a_OnMyGetRoomListTimedOut, _some_time_out_value_like_10.0), instead of having general event functions like OnReceivedRoomList/OnReceivedRoomListUpdate which kind of forces you to keep contextual information like "now that I got this OnReceivedRoomListUpdate, what should I do with the room list I got? Do I want to join immediately a given channel in the context of mach-making or do I want to pass this list on to some specific function? Or do I simply want to ignore the room list because I don't need it now?".
    • I suppose it is related to the previous problem but many times the Connect() -> OnJoinedLobby() -> JoinRandomRoom() fails with "no match found".
    • Suppose as user A you create room B, then you either disconnect (1), leave room A (2) or forcefully terminate and restart the app (3), and then you create room C again. After this, from another device you get the list of rooms as, say user D, you sometimes get [B, C] both of which were created by user A. In the worst case, which I suppose is getting a room that has been recently closed, but that is understandable. What I think it conflicts with the fact that you can not join/create a new room if you're already inside a room. I suppose this is probably some kind of conflict resolution issue in the server side, I guess...

    Anyway, I am looking forward to the next version :)
     
    Last edited: Jan 18, 2012
  35. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    The description is outdated. JoinGame will fail if the game is not existing or full. CreateGame fails if the game already exists (but can be called with null as name, which generates a GUID as name, server side).
    Will fix the doc, thanks.

    Ah, right. Never used it this way.
    OnJoinedLobby tells you that you are in the lobby, not that you got the room list. The roomlist is delivered in another message from the server, which causes the call to OnReceivedRoomList().
    You could simply move your code into that method, or wait.
    The list is updated by the server in intervals. It's not polled by individual requests of clients (saves a lot of work server side). The PUN framework caches and updates the list, so you can access it anytime but it's only updated while in the lobby on the master.

    This is normal when you develop games or have few players. If no one is around or if all games are full, you can't join a game. Create one in that case and make the user wait until someone joins your game (then succeeding with join random).

    It's much simpler if you can only join a single room, so that's our basis. It can be changed easily if you work with the Photon Server SDKs. For the Cloud we try to supply a basic and flexible logic.
    You can't avoid racing conditions where a room gets closed the second you try to join. That's the way it is with distributed clients and networking, as there is always some lag, sadly.
    About opening rooms from within rooms: It could be possible but we didn't see the important usecase yet. Instead, we wanted to involve the MasterServer when creating and joining rooms, so it's up to date first and everyone can find your games and names don't collide. If a room "mine" would be opened on several gameservers at the same time, who can use that name? It must be unique...
     
  36. imkira

    imkira

    Joined:
    Dec 26, 2011
    Posts:
    39
    Thank you very much for the quick reply!

    I think I have not been sufficiently clear in my previous remarks.
    To start with, suppose there are 2 players connected.
    What I am talking about is the 1st player joining room A, then leaving it (explicitely via a LeftRoom or implicitely via Connect soon after a forced disconnect, a sudden app termination, or similar event) and then joining a room B. What happens around this time is that, when the 2nd player gets the room list sometimes it will be returned as [A, B] (both of which were created by the 1st player). Since such thing is not possible (i.e., a user cannot create nor be in two rooms simultaneously), I guess the servers should resolve this conflict (via a creation timestamp or whatever...). If the full list is always returned by the server, I suppose the server should handle and solve these conflicts for the clients. If the server only sends "deltas", then I guess the client should solve these conflicts making sure that only the room whose creation date has a higher timestamp is returned for any given user. I wouldn't mind much if this "conflicting state" lasted just a matter of 1 or 2 seconds but I have recently confirmed that it can happen very often and last for 30 ~ 60secs in the process of automatic match making in the game I am developing.

    PS: by the way, do players get room list updates while they are not in the lobby but in some given room they joined/created?
     
    Last edited: Jan 19, 2012
  37. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    Now it's clear. Thanks.
    We didn't experience such long timeouts yet. Usually, the updates between servers are faster than a player switching.
    What you easily experience when you test is that you stop a client or otherwise keep it from sending a "disconnect" to the gameserver. In that case, the server's timeout will clean up the connection, room and the listing of said room. This might take up to 30 seconds and looks like one client causing multiple rooms.
    Also: rooms stay alive until no player is in it anymore. Even if player One is correctly disconnecting, player Two might still be in there, cause the "other" test client crashed or was closed.

    Currently, we don't have the infrastructure to identify a "session" of any client. When it connects, its just "some" player, so we can't check if "this" player has another room open.

    Room lists are sent "complete" when you join the lobby, then we send update deltas. The only "place" to get lists is in a lobby, which is also a room (but one which doesn't send join/leave events and doesn't pass on other events).

    Hope this helps.
     
  38. imkira

    imkira

    Joined:
    Dec 26, 2011
    Posts:
    39
    Got it!
    Thank you very much for your thorough explanation :)
     
  39. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    We just replaced the previous Photon Unity Networking version with a new one. We tried to get every reported issue resolved but also squeezed something new: On the Cloud's master server you get statistics of players online, looking for games and the number of rooms in use.
    This version should be compatible with 3.5 already but please keep reporting issues if you encounter any.

    v1.8 (25.01.2012)
    Added: changelog tp PUN package
    Fixed: a bug that occured when calling a PhotonNetwork.Instantiate in the same frame after calling a PhotonNetwork.Destroy.
    Changed: InitializeSecurity made obselete. requestSecurity is now true per default, this will encrypt authenticate(the APPID etc.) All normal messages (RPC etc) are NOT encrypted ATM.
    Removed: instances of GAME to ROOM inside PhotonNetwork.(Please mind isNonMasterClientInGame' -> 'isNonMasterClientInRoom')
    Added: new statistic: PN.countOfPlayersInRooms
    Changed: OnPhotonPlayerDisconnected is now called AFTER possible MasterClient switch
    Changed: OnPhotonPlayerDisconnected is now called AFTER the playerList (and playercount) has been updated: The player is first removed from the playerlist.
    Changed: OnPhotonRandomJoinFailed is now properly called after RandomJoin failed because an empty room was accidently joined. Previously OnPhotonJoinRoomFailed would be called instead.
    Changed: PhotonNetwork won't generate a player name. Instead the Worker Demo does this when no name was applied yet. (player names are synced automatically when set)
     
  40. tutibueno

    tutibueno

    Joined:
    Dec 11, 2009
    Posts:
    9
    Hi Tobias, great update.

    It seems that when a user is disconnected by connection issues (not when leave leave the room by using the function), the server is not recognizing that and doesn't disconnects the user from the room, leaving all objects in the scene.

    I am using photon cloud.

    If you want I can wrap up an example project.

    Thanks!
     
  41. mindlube

    mindlube

    Joined:
    Oct 3, 2008
    Posts:
    993
    Hmm, seems to work for me: If I cut off the network connection, am receiving OnPlayerDisconnected. It takes about 20 seconds locally, and 30 seconds for other clients.
     
  42. tutibueno

    tutibueno

    Joined:
    Dec 11, 2009
    Posts:
    9
    Hmm I've tested it again using the default example project and the result was the same. The character from the broken connection remained in the scene even after the server detected that there was only one player in the room.
     
  43. mindlube

    mindlube

    Joined:
    Oct 3, 2008
    Posts:
    993
  44. tutibueno

    tutibueno

    Joined:
    Dec 11, 2009
    Posts:
    9
  45. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    The server timeout is really long. I think we can safely change that with the next cloud maintenance.
    Locally, the timeout is less than 10sec for me.

    We're looking into the destroy issue and will post a fix or more details.
     
    Last edited: Jan 31, 2012
  46. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
  47. tutibueno

    tutibueno

    Joined:
    Dec 11, 2009
    Posts:
    9
    Thanks for clarifying timeout x clean objects. The fix is working. Thanks so much!
     
  48. chrisx84

    chrisx84

    Joined:
    Nov 9, 2011
    Posts:
    85
    is there a way to allow players to change scenes and wont spawn a duplicate of themselves on the first scene?
    ie. when a player goes from scene 0 to scene 1 they spawn in both scenes and move at the same time in both.
    Is there a way so when a player enters scene 1 they dont appear in scene 0?
     
  49. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    This time, the changelist is actually pretty long:

    v1.9 (27 February 2012)
    Note: This update is not compatible with older PUN versions, so don't mix client versions for one title. Photon Cloud will automatically put PUN v1.9 clients into a new virtual app, so they don't see rooms of other clients.
    Fixed: Cleanup after a player left. (bug introduced in 1.8)
    Fixed: PUN viewID assignment after conversion from Unity Networking
    Added: More checks to validate PhotonViews (PhotonViewIDs are stripped from Prefabs but GOs in the Hierarchy must have one).
    Removed: Removed TODO's from PhotonNetwork and made Destroy behaviour more consistent: Players can only destroy objects that they own, the master client can destroy everyones objects.
    Changed: PhotonNetwork.Instantiate now requires a PhotonView at the root of a prefab
    Changed: PhotonNetwork.Destroy(GameObject go) required the gameobject to be created via PhotonNetwork.Instantiate
    Added: Summary and Example for each of the PhotonNetworkingMessage values (each names a "callback" method used by PUN)
    Added: PhotonNetwork.Instantiate overloads which take a prefab's Name to instantiate. You no longer need to pass a GameObject for a asset that's in the Resouces anyways.
    Changed: PhotonNetwork.GetRoomList() now returns RoomInfo[] instead of a Room[]. Simply change the type! RoomInfo is a different class but behaves like the rooms did.
    Added: RoomInfo class, as base for Room. The RoomInfo is what you get in room listing: PhotonNetwork.GetRoomList() and you can't modify RoomInfo (you're not yet in those rooms)
    Added: Room.SetCustomProperties() and PhotonPlayer.SetCustomProperties() to add/update custom properties to players or rooms. The key of those must be string! You can't currently delete customProperties from the server (but set them null). This is likely to change.
    Added: Room.customProperties and PhotonPlayer.customProperties as getter for the custom properties you set. These sync once set.
    Changed: Custom room properties are no longer automatically listed in the lobby! see CreateRoom() note below.
    Added: CreateRoom() overload that takes string[] propsToListInLobby as last parameter. This defines which custom properties of your room get into the lobby. By default no other props get listed. So if you want to set "map" and have that in the lobby, apply it by CreateRoom().
    Added: Check if values are changed more than a minimum before they are sent. Floating point precision for positions and rotations cause many updates and messages, so these thresholds help skip updates that are too tiny to notice. See note below.
    Added: PhotonNetwork precisionForVectorSynchronization, precisionForQuaternionSynchronization, precisionForFloatSynchronization properties.
    Added: Option to not join the lobby and respective callback. Use PhotonNetwork.autoJoinLobby to set and implement OnConnectedToMaster() instead of OnJoinedLobby(). You can join random games, create or join named games just fine, without the lobby.
    Changed: PhotonNetwork.autoCleanUpPlayerObjects is now done by server and can be set per room. In a room, all clients adhere to the room's setting (as set when the first player calls create). This should solve some rare issues due to racing conditions. The Master is not doing extra work anymore for this.
    Added: Room.autoCleanUp. This property tells each client if the room actually cleans up buffers for players that leave. Set when the room is created to the then current value of PhotonNetwork.autoCleanUpPlayerObjects.
    Changed: PhotonNetwork.autoCleanUpPlayerObjects fires an error when changed while in a room
    Fixed: isMasterClient and PhotonNetwork.masterClient for some rare conditions.
    Fixed: PhotonPlayer.ToString() returned null, if no name was set. This now returns "".
    Added: PhotonNetwork.unreliableCommandsLimit which could be used to fine tune how many of the most recent unreliable messages should be dispatched while the rest is skipped. This has a useful default, so you don't really have to care.
    Added: Initial version of PhotonStatsGui script, which shows messages total and for a interval. This is giving a first impression of the message-usage of your games. This will be extended.
    Added: Profiler samples to SendOutgoingCommands and DispatchIncomingCommands. These tell you how often they run (in some frames only) and how long.
    Changed: Internally, SendOutgoingCommands() is now called as long as there are outgoing commands queued. This will produce UDP packets when absolutely needed but stabilizes the connection, especially when joining games and getting a lot of messages.
    Changed: The connectionStateDetailed is now changed before PUN calls your OnFailedToConnectToPhoton(), so you could re-connect from inside of that method.
    Updated: To Photon Unity3d client lib v3.0.1.1

    Get Photon Unity Networking from the Asset Store
     
  50. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Update notice: The update should be painless, just import the latest package from the asset store.
    There is only 1 change AFAIK: PhotonNetwork.GetRooms(); now returns RoomInfo instead of Room.
    So change your code to e.g.: