On Connect - Server Side [Resolved]

edited August 2010 in Photon Server
Resolution
For anyone stumbling upon this thread now wondering about client > server and server > client interaction (blank setup guides)
Boris was kind enough to establish these for us in THIS THREAD!

Original Post
So, Yesterday I went through the UnityGrid demo, including the Photon.MmoDemo.Client.DotNet and the linked unity3d one, completely stripped the solution down to include those 3 for client side, and then the common and server side, then proceeded to remove everything on the client end other than the debug info and the connect/disconnect operations, so that I was left with a project that would only connect or disconnect from the server (clean slate).

The problem is, in the server solution given for that, I cannot figure out where the server does the response for the connect, so I can clean the server solution down to the same bare minimums (extra is not necessary atm). Currently when I connect, I do not get the onconnect response, but when I disconnect, I do get the disconnect response. Or, if the server is offline, I also get the disconnect response; leading me to believe it's working properly.

Is there an easier way to go about doing this than stripping an existing solution? If not, where in the server-side solution should I be looking? I'm guessing that the server bit in the unitygrid demo solution is not the right one eh?

I don't need the client to connect to a world or etc, just to connect, execute registration codes and disconnect. I'd skip this and do it in php, but I'll need it for the login section as well since it's just loading client-side GUI's with populated tables from the server.

Thanks in advance.

Comments

  • BorisBoris ✭✭
    Not sure I fully understand... You are looking for a onconnect hook on the server side, right? That would be the mmopeer constructor or the mmoapplication.createpeer method. If you want the bare minimum create your own ipeer implementation and your own photon.socketserver.application subclass.
    Hope that helps.
  • Boris wrote:
    Not sure I fully understand... You are looking for a onconnect hook on the server side, right? That would be the mmopeer constructor or the mmoapplication.createpeer method. If you want the bare minimum create your own ipeer implementation and your own photon.socketserver.application subclass.
    Hope that helps.
    Problem is I don't quite understand how your server works well enough to do that since the documentation is basically.. well.. documentation. It's not really geared toward people to learn how to make use of your service. The easiest way for me to learn is to dive in to your example projects, tear them down, and then rebuild them up. This was no issue with the client side since everything more or less was named for what it did. But on the server side, there is no OnConnect for example, in the code that I was looking for. As you suggest, it's actually a function that creates a new peer on the server. So now I have to find how that works in order to try and understand anything about the server-side implementation.

    I, obviously, don't have enough experience to just pop this open and understand it's flow, it's taking quite a bit of time to comprehend that. I've got the basis of down fairly decently I think, and I'm just now looking to complete the puzzle or so.

    Does Exit Games have any plans in the future of releasing How-To's or Tutorials for a few basic things like "setting up a clean OnConnect/OnDisconnect implementation of Photon.SocketServer.Application" or "Adding My Custom Operation"?

    Typically I would wager that this is something the community should be doing, but I'm unsure Photon has a large enough community at the moment, and from what I've noticed, everyone is struggling their way through it. I'd love to pitch these in and offer said tuts/how to's, but I clearly don't have enough of an understanding yet. Will research this more over the weekend and see if I can figure out the Photon.SocketServer.Application enough to make a new implementation, or how to tear down the current server-side logic if I cannot.

    The peer creation definitely points me in the correct direction. What I didn't expect when I tore apart the client side was for there to be no response from the server during the initialize, since I didn't actually alter the initialize function itself. But I now get no response that I'm connected, so I sit in the waitingforconnection status indefinitely until I close the connection. Not quite sure what's causing this :p

    Thanks again. Let me know if there may be a better way I could explain this. Hope ya'll understand :)
  • Nyquest wrote:
    I don't need the client to connect to a world or etc, just to connect, execute registration codes and disconnect. I'd skip this and do it in php, but I'll need it for the login section as well since it's just loading client-side GUI's with populated tables from the server.
    So you mean that there is some data in the SERVER that you will need for the login? You mean, maybe player class, or any other type that the player can choose? I believe that you will need those in the database too, so why dont you leave all that for the database and for the php and just join the game with the server when the player is really ready to play? Thats what I am going to do to make my life easier.

    Boris wrote:
    Not sure I fully understand... You are looking for a onconnect hook on the server side, right? That would be the mmopeer constructor or the mmoapplication.createpeer method. If you want the bare minimum create your own ipeer implementation and your own photon.socketserver.application subclass.
    Hope that helps.
    Yea from what I understand, the peer is what makes the server connection, so if you create a new peer instance in the client side, you will be connected.
    But anyway, try this:
    Download the MmoDemo, in the project called Photon.MmoDemo.Client.DotNet, inside the folder GameStateStrategies, open the file, WaitingForConnect.cs.
    In that file look for the function called:
    public void OnEventReceive(Game game, EventCode eventCode, Hashtable eventData)
    
    Try tracing the variables eventCode and eventData.
    I havent tried that but this may answer your question...
    Nyquest wrote:
    Does Exit Games have any plans in the future of releasing How-To's or Tutorials for a few basic things like "setting up a clean OnConnect/OnDisconnect implementation of Photon.SocketServer.Application" or "Adding My Custom Operation"?

    I was planning on doing another step by step tutorial explaining how you can call a custom operation, I have just made my custom operation for shooting, you send the shoot data, and the server creates the projectile instance, as soon as the instance is in photon, unity will create the prefab on the game =)

    Try reading this post:
    viewtopic.php?f=5&t=76
    It helped me to make my call to customOperation

    Good luck =)
  • I appreciate that response. I never actually thought of using the php for the login as well and just linking to the DB that way, mainly because we already did all the c# coding to link the server to the db.

    I just figured there should be an easy way to do a 'clean' connect to the photon server, do the db calls from there, and carry the client where they need to go. I've removed all item creation, world creation, etc from the 'clean' connect and figured I would re-implement that when they 'create' a 'game' instance. That way they could keep the peer ID whever they were, game lobby or in-game. I thought this would be faster for client > server and server > client interaction and would still prefer to do it this way. But the problem now is that progress has basically halted because we cannot seem to grasp how exactly photon is structured. This may actually be our problem is that we are trying to disect the server and understand it in full, instead of using it in it's current instance.

    I will definitely follow that event code and make sure I did not accidentally remove that event listener when I was stripping the client side code. From what I can tell the player does connect, I just am not getting the response from the server to trigger the client side OnConnect () function (which notes in the Debug.Log that the client has successfully connected to the client.

    I'm pretty sure that I am VERY close to succeeding in my current direction, but i'd still like to clean the server side scripts out just as I have the client side.

    Maybe when I'm done if it's ok with Exit Games I can post a zip of the completed *modified* project?

    I'm sorry I rant so much and even more so to Exit Games if I appear to be harsh in some of my comments, but I simply just want to learn this particular style of coding, since networking of this calibur is definitely new to me.
    zoultrex wrote:
    I was planning on doing another step by step tutorial explaining how you can call a custom operation, I have just made my custom operation for shooting, you send the shoot data, and the server creates the projectile instance, as soon as the instance is in photon, unity will create the prefab on the game =)
    This would be awesome btw. If you'd like maybe we can team up a bit and tackle some more tuts for the future community... perhaps after I get a slightly better grasp on things :p

    Thanks again!
  • BorisBoris ✭✭
    It might be easier to understand if you start with / strip lite instead of the mmo demo.
    Will write more on Monday, when I get a chance to look at the code.
  • I agree with Boris.
    The Lite one is far lighter on code and message flow path (it comes in -> Dispatcher -> from there you can use jump to definition from vs to follow the whole path of the message)
  • Boris wrote:
    It might be easier to understand if you start with / strip lite instead of the mmo demo.
    Will write more on Monday, when I get a chance to look at the code.
    This is probably a very good idea, and I'll definitely continue there.

    My current code seems to be working fine (creating peer and etc), but for some reason it's just not echoing back that it's connected. So I guess what I'm left to ask is, what snippet from the server triggers the client side command OnConnect (in RunBehaviour.cs of the Photon.MmoDemo.Client.UnityGrid source)?

    Thanks again,

    going to start trying to pick through the lite code now! Wish me luck :)
  • in case of the MMO, this is handled by the distinct GameStateStrategies in the Photon.MmoDemo.Client.Unity3D project which leads to the assembly that you later on include in the client
  • dreamora wrote:
    in case of the MMO, this is handled by the distinct GameStateStrategies in the Photon.MmoDemo.Client.Unity3D project which leads to the assembly that you later on include in the client
    So then my issue is client side, and not server side. So somewhere along the line I removed 1 to many things? Basically stripping the client of operations should have no effect on the connect?

    Will check more into this, thanks :D
  • Hard to say cause depending on what you cut it will suffer.

    also you can hardly strip operations without messing with the base library which you include thats generated from this client project (and I would definitely recommend to not strip and mess with it too much until you understood the flow, requirements and expectations well enough)

    you can set the whole thing into debug mode through the corresponding flag, that will give you output on every message received basically so you know if it fails on client or server end :)
  • I uploaded a guide to setup a blank server here: viewtopic.php?f=5&t=107&start=0
    It doesn't cover the client side, operations and events yet.
  • dreamora wrote:
    Hard to say cause depending on what you cut it will suffer.

    also you can hardly strip operations without messing with the base library which you include thats generated from this client project (and I would definitely recommend to not strip and mess with it too much until you understood the flow, requirements and expectations well enough)

    you can set the whole thing into debug mode through the corresponding flag, that will give you output on every message received basically so you know if it fails on client or server end :)
    I have not yet had the chance to run it through debug mode, nor did I even give that thought. I'll have to take a look at Boris' guide and then run through this again. Chances are I overlooked something and stripped out one too many things.

    Seems I still got quite a large bit to learn :p
    Boris wrote:
    I uploaded a guide to setup a blank server here: viewtopic.php?f=5&t=107&start=0
    It doesn't cover the client side, operations and events yet.

    I see you also included how to set up custom operations. I will give these docs a very thorough read through tonight/tomorrow and post some feedback for you. I just want you to have the heads up now that I very much appreciate how helpful and quick the Exit Games team is. You all have a great CS team and have been very kind.

    Many Thanks :)


    Edit: Gave them a quick skim now. Going to link it up to the Opening post in this thread so that anyone that searches and finds this will be linked to that.

    Thanks!
  • Thanks back to you (and all active forum users) for posting and the patience to learn Photon.
    We want to make Photon as easy as possible and it's your feedback that tells us where the obstacles are.
Sign In or Register to comment.