Network System Help

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Network System Help

      Hey Guys,

      I have been working with the network system and have figured out how the system for listening and connecting server and client sockets work, but I need some clarification though on how the system proceeds from there. The two events I see next that seem to set up the actors/views are, EvtData_Remote_Client
      which is created and queued on the server side immediately after a client's connection is accepted. Now, this is where the confusion starts for me, the first comment in the only delegate which listens for this event says

      Source Code

      1. // This event is always sent from clients to the game server.


      I was initially thinking this somehow meant that the client socket had streamed an event over to the server, but when looking at it closer, I think it means that the client attempts to connect, is then accepted, and the server side generates an event with the socket ID and IP address of the client, correct? The event is then listened to on the server side by the game logic, which attempts to find an unused NetworkView which should be created by the server prior to connection (in a network game setup screen or something). Now that the server side has successfully associated a local network view with a client socket ID, it then sends a 'NetMsg_PlayerLoginOK', which is a signal that the client was succesful in its connection. This message is then streamed back to the client which uses the data to construct an 'EvtData_Network_Player_Actor_Assignment'.

      This event is listened to by the game logic as well on the client side, first off though, what is the point of this line

      Source Code

      1. if (pCastEventData->GetActorId()==INVALID_ACTOR_ID)
      2. {
      3. m_remotePlayerId = pCastEventData->GetSocketId();
      4. return;
      5. }


      Is it for cases where the player does not necessarily associate with an actor, like a puzzle game? What confuses me more is this,

      Source Code

      1. if (m_remotePlayerId == pCastEventData->GetSocketId())
      2. {
      3. pHumanView->VSetControlledActor(pCastEventData->GetActorId());
      4. }


      So the first code block says, if the actor ID is invalid, then set m_remotePlayerID to the socketID, however the next code block says, if the remote player ID is equal to the socket ID (which assumes that the actorID was invalid in the previous block), then set the views controlled actor to...invalid? I am unsure about
      how this code works as it seems like the actor ID must be invalid, only to set the views controlled actor to the invalid ID.

      At this point I think I understand these points

      - The Server has listened on a port, and a client has connected, associating a human view and a network view both on the client and server sides with a socketID, which is uniquely generated on the server side
      - Both of these views are also associated with an ActorID which is also generated on the server, which leaves me to wonder, is this assuming that both the server and the actor have identical actor objects, I mean, if an actor was loaded on one machine and got a different number, this could be bad, like possibly
      the server attaching the clients human view to a table or something instead of the actual player actor, am I wrong here, or is this something that needs to be kept in sync completely.
      - I understand that a network event forwarder is created in response to a EvtData_Remote_Client on the server side, but where is created on the client side, how does the client side human view forward events to the server?

      I had considered using networking for our current game, but I think I will hold off until a future project, however I would like to figure this out anyway as it is really confusing.

      Thanks again
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • Hey there - sorry it took me so long to respond - but after reading your question I got a little confused too!

      The whole idea about Actor IDs and Socket IDs is simply a way to figure out which actor in the game is controlled by which view. This could be done in a lot of different ways - but it was just a standard I settled on.

      What makes this a little confusing (my bad by the way) is how there is a client side and a server side of this "hooking up" problem.

      On both the client side and the server side, there is an actor. The client side actors aren't controlled by anything local. The server side actors are controlled by the server logic as it interprets events streaming in from the views. I think the confusion you see here comes from the fact that on both the client side and the server side, actors must get "hooked up" the right way.

      I could have done a much better job calling this out though comments or naming conventions.
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • Thanks Mike, like I said I won't likely be implementing multiplayer in this game, but I look forward to using it in my next game which will be much more suited for it.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz