Announcement

Collapse
No announcement yet.

Detect connect, disconnect attempts on network in blueprints

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Detect connect, disconnect attempts on network in blueprints

    Hi is there any way to know when you successfully connect and disconnect from a server in blueprints, for example i have a main menu that has connect or host on it, when you click connect it sends a console command to connect to an ip address, then loads a level, the screen remains black until it connects by default, and there is no way to know whether it fails to connect to the server so that i can take them back to the main menu.

    Ideally what i would like to do is on connect, show a hud saying trying to connect, once connected hide the hud and start game, if it fails to connect say failed to connect on hud with option to go back to main menu.

    Is this only possible in C++, my C is extremely limited, and networking can be complex with c++, specially if you dont know c++.

    I dont see any events in the blueprint to do with this problem.
    http://www.leopardx.net

    #2
    If your connect works, nearly all BeginPlay events will call in the new Level. I just use the Level to disable my loading screen. Also in the GameMode, the server gets the Event Post Login which fires when a player has a valid PlayerController spawned and ready.

    For connection errors there should be an Event for network errors in the GameInstance class which you can use.
    Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

    My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
    (Including 100+ Pages Multiplayer Network Compendium to get you started.)

    Comment


      #3
      Thanks for that I included a GameInstance class and the network error event is there, so thanks for that i still need to hook it up with some code to see if it works but i dont see why it wont!

      Click image for larger version

Name:	SNAG-0022.jpg
Views:	1
Size:	10.5 KB
ID:	1076136

      Im not sure how to check what type of error it is yet but will search for that, Im not sure how to get the gamemode event post login though, but like you say the event beginplay should be a good enough indication that its connected.

      Big thanks for your help Exi!
      http://www.leopardx.net

      Comment


        #4
        Drag out the Failure Type and release on an empty spot. Type in "Switch" and it should how something like "Switch on EFailerType" or so (don't know what the Enum is called exaclty).

        you will then get a node that has an exec for each enum type and you can just set a Text variable or call a function or what ever you want based on the failure type.
        Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

        My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
        (Including 100+ Pages Multiplayer Network Compendium to get you started.)

        Comment


          #5
          Oh i was just trying to find out that, you saved me a lot of hassle, it was called ENetworkFailure, was the only one that came up and lists the errors, nice one thanks again eXi !!

          Click image for larger version

Name:	SNAG-0023.jpg
Views:	1
Size:	40.4 KB
ID:	1076154

          I can confirm the event fires. in my case i tested it connecting to a port that was not open and got a time out error, which is exactly what I need!
          Last edited by LeopardX; 05-11-2015, 12:50 PM.
          http://www.leopardx.net

          Comment


            #6
            Interesting . I'm currently trying to work on a migrate host functionality for listen/server model . So for example in theory could you write a function that would fire from the event network error enum "connection lost " which I'm assuming gets called when a client or host disconnects ??

            Then inside this function you Get a list of all the currently connected player controllers and then use one of these controllers to start a new session. Then for the remaining player controllers you call the leave game /destroy session function then reconnect them to the newly created session that now has a new host ??

            Comment


              #7
              Originally posted by EniGmaa View Post
              Interesting . I'm currently trying to work on a migrate host functionality for listen/server model . So for example in theory could you write a function that would fire from the event network error enum "connection lost " which I'm assuming gets called when a client or host disconnects ??

              Then inside this function you Get a list of all the currently connected player controllers and then use one of these controllers to start a new session. Then for the remaining player controllers you call the leave game /destroy session function then reconnect them to the newly created session that now has a new host ??
              Nothing to add here just curious about the function you are trying to write.

              Would this be like a roaming wifi connection? So you lose connection at one access point and connect at another and get reconnect as the player you where at disconnect or something to that effect?
              Inphidel / Brian - Developer of Ultraball
              http://www.ultraballgame.com

              Don't shy away from bugs in your game. Don't play it as intended. Break your game so you can fix it!

              Comment


                #8
                Well yeah essentially the players can only connect to one session at a time . So if the host drops then my theory is to find out / store all the players that are connected and then start a new session rejoin the players . Then the only hard bit would be to transfer all the data back in for example the score/ deaths / kills etc at the time the host disconnected . Which if it's not possible internally I was thinking of using an exsternal database and then va rest rest plugin to send and retrieve the player data from the old session and populate it into the new session .

                Comment

                Working...
                X