Some questions of Photon Server

Options
Arkdurath
edited February 2010 in DotNet
Hi all

I recently started a development project that will use Photon Server to make a multiplayer game.

To start learning Photon Server i downloaded "Photon-Server-SDK_v1-6-2" and "Photon-Unity_v5-6-1_SDK".

Then, in "Photon-Server-SDK_v1-6-2", i executed 'PhotonControl.exe' (64-bit) and of course, i started it.

In my Unity3D project, i coded a script that holds the connection with the server. To make this script i use the sample code of "Photon-Unity_v5-6-1_SDK" project and re-write it again for learning purpose.

But i have problems with connection.

I can connect with Photon Server, i use:
m_nPeer.nNetConnect(m_sStrIp, m_sAppID);

m_sAppId is hardcoded to "Lite".

Then, server responds correctly to me that i am connected to it.

After this, i make a Join:
m_nPeer.opJoin(m_sAsid);

m_sAsid is hardcoded to "realtimeDemoGame000".

Then server and i were ready to send info each other.

After this join operation, i enter in a somekind of 'game loop' for net purpose and start to send position information to server.

Every 50ms i send my position to server, but i dont know why after a 10s or 20s i always been disconnected from the server.
And if any other client connect to server, i have an instantly disconnected message from the server too.

Why i am beeing disconnected after few seconds of my connection to server ??

Another problem i have is I dont know if Photon Server can be scripted over it, i mean, can i control how Photon Server response to clients or all stuff is only configurable via events ??

Thanks for your time

Comments

  • Tobias
    Options
    My first guess is a timeout. In your game loop, do you call peer.service() regularly? For a Unity game you could call it every 20 to 100ms. Without this, the client will not communicate (as we don't start a thread for it).

    And yes, you can control how Photon will respond to the clients. You can define your own operations (which we show in the framework) or you can come up with something else entirely.
  • Hi

    Thnaks for your herlp. The problem was that i reseted accidentaly a time variable which allow the sending of packets, so, packets never call 'service()'.

    Going further, wich is the best way to learn how to put scripts o C# code over Photon Server to change its functionality ?? I saw Photon SDK, and i dont know if must start over 'Lite' project, or over 'Lite.SocketApplication' or 'Photon.SocketServer' or something.
  • dreamora
    Options
    You would likely either use the Lite application directly or subclass the corresponding "nicified" classes for your purpose.
    But you can naturally also write it all from ground up yourself should you want to but I guess one wouldn't do it.

    What you need to have is an Application, everything else is up to you.
    If you compare the Lite application with the MMO example, you will get a good idea on how much it can differ.
  • Hi

    Im checking MMO example, but i noticed that if i compile server part, it compiles into a *.DLL, so, what i need to do with this DLL? Is it the only way to 'communicate' with Photon Server executable ?

    I think i am like a fish over desert now, so sorry by my noob questions :)

    Thnaks in advance
  • dreamora
    Options
    All code you write will always compile to dll.
    these .net assemblies then are used by the socket server to execute your "server application" (you can have various different applications running on the same server).

    You don't need to do anythin with the dll. Given you just extracted the server all is already setup at that point, just start the socket server and you are fine to go.
    If you want to put both onto the same server, thats possible too. For that copy the Mmo folder to the other server folder where you currently have the Lite application (you will then have the folder with Lite and Mmo). After that you need to edit the PhotonSocketServer.xml in your bin_Winxx folder and add the Mmo application as another application and restart the photon socketserver service


    The SocketServer is what makes your server a server at all. it handles all the networking, heavy lifting on the threading end etc.
    The .NEt code you write is the "functionality" that you put into that server, or as its class name indicates, the Application, that serves the users that connect to your server with the corresponding backend