playMaker

Author Topic: Master Server Example  (Read 5017 times)

charmandermon

  • Playmaker Newbie
  • *
  • Posts: 7
Master Server Example
« on: October 20, 2012, 03:22:46 AM »
Hi there, Im semi new to networking.  I am a super fast learner and the networking samples were fantastic.  Also Playmaker as a whole is just absolutely amazing.

Im looking to see if someone can create an example scene using a master server.  Basically im looking for the ability to register the game on a master server then have all clients see in a gui window the list of all of the current games.  Similar to how Unity's networking example does it.

 function MakeClientWindow(id : int)
{
   GUILayout.Space(5);

   var data : HostData[] = MasterServer.PollHostList();
   var count = 0;
   for (var element in data)
   {
      GUILayout.BeginHorizontal();

      // Do not display NAT enabled games if we cannot do NAT punchthrough
      if ( !(filterNATHosts && element.useNat) )
      {
         var connections = element.connectedPlayers + "/" + element.playerLimit;
         GUILayout.Label(element.gameName);
         GUILayout.Space(5);
         GUILayout.Label(connections);
         GUILayout.Space(5);
         var hostInfo = "";
         
         // Indicate if NAT punchthrough will be performed, omit showing GUID
         if (element.useNat)
         {
            GUILayout.Label("NAT");
            GUILayout.Space(5);
         }
         // Here we display all IP addresses, there can be multiple in cases where
         // internal LAN connections are being attempted. In the GUI we could just display
         // the first one in order not confuse the end user, but internally Unity will
         // do a connection check on all IP addresses in the element.ip list, and connect to the
         // first valid one.
         for (var host in element.ip)
            hostInfo = hostInfo + host + ":" + element.port + " ";
         
         //GUILayout.Label("[" + element.ip + ":" + element.port + "]");   
         GUILayout.Label(hostInfo);   
         GUILayout.Space(5);
         GUILayout.Label(element.comment);
         GUILayout.Space(5);
         GUILayout.FlexibleSpace();
         if (GUILayout.Button("Connect"))
            Network.Connect(element);
      }
      GUILayout.EndHorizontal();   
   }
}


Thanks in advanced!!!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Master Server Example
« Reply #1 on: October 22, 2012, 03:36:06 AM »
Hi,

 "games" in your example are "rooms" isn't it?

 I think the sample provided with photon is about this, and you don't need a master server to do that, each client has access to this kind of information.

in the sample, when you create a "room", you are basically creating a new game completly independant from another room/game created by someone else that you haven't joined yourself at this moment. Is it what you are after?

bye,

 Jean

charmandermon

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Master Server Example
« Reply #2 on: October 23, 2012, 12:57:27 AM »
Thanks actually I figured it out and wrote some pretty amazing playmaker actions that connect to the Master Server and List each current game.  I also reworked all the networking actions to work much more smoothly. I had many RPC errors that I fixed from the logic from the network examples.

Ive used photon before and It has it's pros and cons, Photon cloud is really nice for any turn based game or chat system but it has on average 500 round trip ping because they host the photon cloud in Germany. ( I am in america)

The custom Photon Server System is fantastic (in theory) but so far its been a nightmare to set it up.  It also doesn't have the ability to host a master server system to allow peer to peer connections.

In my case I needed realtime low ping Master server set up that connected a client directly to the host of the game.

So far my testing has been phenomenal.  I have been playing friends (beta testers) 800 miles away from myself and we can get over 500 network views (objects with physics) instantiated and it works very smooth and very fast.

When I deploy I wont ever have over 50 network view objects.(its just good to know my boundaries)

Also Its all iOS! Thank you so much Playmaker!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Master Server Example
« Reply #3 on: October 23, 2012, 03:19:51 AM »
Ah, sorry, you meant the Unity server, not the photon one. Sorry for the misunderstanding.

Yes the Unity Network Actions are not as in depth and optimised as the photon counter parts. I think because it doesn't really make sense for the average PlayMaker community to get involved with anything more complicated than the photon cloud server.

 Tho I did not had any rpc errors as far as I remember. Could you explain more about what they were?

 I am glad you have progressed on that. I have been to Unite in august with the Photon Crew, and the feedback they got from developers was actually quite the opposite regards setting up the server. I think you should really get in touch with them, to get to the bottom of your problems, they are very helpful and I am sure they would be interested in hearing your struggle.

Looks like you've been working very hard :) congrats on your results!


bye,

 Jean