NetSync + LiteLobby and how to write highscores in mysql

Nolex
edited March 2011 in Photon Server
hi

I’m exploring "NetSync", and got two questions:
1. I want to use the "LiteLobby" system in "NetSync" - how to connect it to this particular example?
2. How to write highscores from "NetSync" in mysql (user name, speed, and etc..)?

tnx :)

Comments

  • LiteLobby system is prettry straight forwards and you can just export the sample chatV1 to integrate to other applications. to store highscores in mysql, you have to write some serverside script like PHP and you can use WWW function in unity to post and request data from mysql..
  • 1. Your client has to use "NetSync" as app id in Connect(). That's where you define the server app to connect to.
    2. You could do this directly from the server's application. Use any DB and maybe a database abstraction layer like nHibernate or Lightspeed. We can't support you in that direction but maybe someone of the community can help you. In any case, it should be easy to find tutorials for this on more DB related pages.
  • Tobias wrote:
    1. Your client has to use "NetSync" as app id in Connect(). That's where you define the server app to connect to.
    Can you be more specific pls? Should I rewrite NetSync server, or may I use both applications - NetSync and LiteLobby simultaneously?
  • Oh. I just realize I misunderstood your first post...

    NetSync is extending Lite. If you want to use Lite Lobby as your base, you need to refactor NetSync:
    Add the Lite Lobby project (right click the solution, "add", "existing project") to the NetSync solution.
    For the NetSync project add a LiteLobby reference.
    The lobby rooms should not support the syncing operations Id say, so make your NetSyncGame inherit LiteLobbyGame instead of LiteGame.
    You need to adjust the NetSyncGame constructor, as it changed from LiteGame to LiteLobbyGame.

    From there on, it builds again. I didn't test it with a client, so you should make sure when you join a game it still creates a room of type NetSyncGame.

    For the lobby part, you could take a look at the Lite Lobby Chat sample. Once you're in a game, you should be able to use netsync operations.


    Hope that helps.
  • Tobias wrote:
    Oh. I just realize I misunderstood your first post...

    NetSync is extending Lite. If you want to use Lite Lobby as your base, you need to refactor NetSync:
    Add the Lite Lobby project (right click the solution, "add", "existing project") to the NetSync solution.
    For the NetSync project add a LiteLobby reference.
    The lobby rooms should not support the syncing operations Id say, so make your NetSyncGame inherit LiteLobbyGame instead of LiteGame.
    You need to adjust the NetSyncGame constructor, as it changed from LiteGame to LiteLobbyGame.

    From there on, it builds again. I didn't test it with a client, so you should make sure when you join a game it still creates a room of type NetSyncGame.

    For the lobby part, you could take a look at the Lite Lobby Chat sample. Once you're in a game, you should be able to use netsync operations.


    Hope that helps.
    Okay, Thanks!

    Btw, NetSync example uses authoritative or non-authoritative server? What's about cheating? Is it possible?
  • The NetSync Application is not authoritative on the server. It does not check anything and does not know the physical world.
    Currently, we don't gave a cheating prevention showcase.
  • Tobias, Thank!

    I want to send the variable from a photon-server to the unity-client.
    For example - I created the variable in c:\Photon\src-server\NetSyncObjects\Server\NetSyncGame.cs

    How can I get this variable in client-unity?

    Can you explain in details?

    Thank you!
  • Help me, please..! :?
  • I've solved my problem and created the Custom Event!

    1)
    In c:\Photon\src-server\NetSyncObjects\Server\Events\ I created the file: EvStatusServer.cs
    namespace Photon.NetSyncObject.Server.Events
    {
        using Lite.Events;
    
        using Shared;
    
        using SocketServer.Rpc;
    
    
        public class EvStatusServer : LiteEventBase
        {
    
            public EvStatusServer(string tester, int actorNr)
                : base(actorNr)
            {
                this.Code = (byte)EventCode.StatusServer;
                this.Tester = tester;
            }
    
            /// <summary>
            /// Gets or sets nolex.
            /// </summary>
            [EventParameter(Code = (short)ParameterKey.Tester)]
            public string Tester { get; set; }
    
    
        }
    }
    

    2)
    In c:\Photon\src-server\NetSyncObjects\Server\NetSyncGame.cs I added my event code::
    var tester = "sendinfo";
                  var @event = new EvStatusServer(tester, this.Actors.GetActorByPeer(peer).ActorNr);
    
    	this.PublishEvent(@event, this.Actors, Reliability.Reliable);
    

    3)
    Added to Client(PhotonManager.cs) a new case for my event — StatusServer.
    case (byte)EventCode.StatusServer:
    		  nolexnew = (string)eventParams[(byte)ParameterKey.Tester];
                    break;
    

    4) Added the EventCode and ParameterKey to c:\Photon\src-server\NetSyncObjects\Shared\.

    After compiling, all began to work! I get my information from server!

    But I have two questions.
    1 ) How can I send an information(event) from server every 10 seconds?
    2) What does "Reliability.Reliable" parameter in this.PublishEvent(@event, this.Actors, Reliability.Reliable); mean?
  • 1) you can use a timer or a [Pool]Fiber for instance
    2) it means that the event must arrive at the client (you can rely on it)- vs unreliable where it might not arrive.
  • About 1) again/: I believe every Room has a schedule method you can use.
  • Two more questions on NetSync

    1. How can I set aaditional parametrs (for example player color) for each user?
    2. If i pressed "connect" and connected photon, but the game isn't yet created - does it count as 1 CCU?
  • Boris
    Boris ✭✭
    Nolex wrote:
    2. If i pressed "connect" and connected photon, but the game isn't yet created - does it count as 1 CCU?
    yes, each connection is one CCU