Search Unity

[NO CCU LIMIT] Forge Networking now OPEN SOURCE

Discussion in 'Assets and Asset Store' started by Brent_Farris, Dec 22, 2014.

  1. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    To make everything simple, I want to send everything to HandleRawDataRead for processing on the server. If this isn't possible and simple, I guess I can call the method directly.
    Actually, yeah, calling the method directly would be really easy.
     
  2. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Well what we can do on our side is to have the server call the raw data read event as it sends the data off to the clients. I have added this as a feature request on the site. Once this is in (the next build) you will be able to do something like:

    Code (CSharp):
    1. if (OwningNetworker.IsServer && sender == OwningNetworker.Me) { /* Do super awesome stuff */ }
     
  3. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    How do you tell if the Networking.Host call works, I cant see any error reporting, is it that it just returns a null? Also when how is socket.Connected used, it never seems to be set for hosting, struggling at the moment to get the simple cube demo working so not having much luck with Forge so far, the exceptions and the severe lack of any docs or proper examples is starting to drive me towards something that has some proper help and source code as its very frustrating to get exceptions in the console and not being able to look at any code to see why.
     
  4. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hi there. You can hook into any errors/exceptions with our error handler. When you try to connect a host on a port that is already in use you will get a "NetworkException" called on the error event handler. Sorry for the lack of docs on this handler, I will add it to the list of tutorials I do today.

    Code (CSharp):
    1. socket = Networking.Host((ushort)port, protocolType, playerCount, isWinRT);
    2.  
    3. socket.error += MyErrorHandler;
    4.  
    5. //...
    6.  
    7. private void MyErrorHandler(NetworkException exception)
    8. {
    9.     // My awesome code here.
    10. }
    EDIT: In version 13.3 this has been changed to any kind of exception, here is the code from the example scene:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. using BeardedManStudios.Network;
    5.  
    6. namespace BeardedManStudios.Forge.Examples
    7. {
    8.     public class ForgeExample_ErrorHandling : MonoBehaviour
    9.     {
    10.         private void Start()
    11.         {
    12.             Networking.PrimarySocket.error += PrimarySocket_error;
    13.             Networking.WriteRaw(Networking.PrimarySocket, null);
    14.         }
    15.  
    16.         private void PrimarySocket_error(System.Exception exception)
    17.         {
    18.             if (exception is System.Net.Sockets.SocketException)
    19.                 Debug.Log("This is somekind of socket exception, could be that the port is already in use?");
    20.             else if (exception is NetworkException)
    21.                 Debug.Log("This is a Forge Networking specific exception");
    22.             else if (exception is System.Exception)
    23.                 Debug.Log("It is a system exception");
    24.             else
    25.                 Debug.Log("What is this exception?");
    26.  
    27.             Debug.Log("We are now going to log the exception with Unity Debug.LogException");
    28.             Debug.LogException(exception);
    29.         }
    30.     }
    31. }
    I am very sorry to hear of these problems :(. If there is any way we can help you we will do anything we can. In fact I will spend the greater part of the day today working on tutorials. The majority of our developers come from other systems and say the other systems are very slow at updating, have little to no documentation, or have no support. We wish to not be anything like that on any level. We are still in our beta and I know that you said that you are new to networking so that combination should usually have some bumps along the way. We actually have at least 10 beta testers who have never touched networking before who are getting some cool projects and sailing through learning networking through our system, we only hope that this could be the case for you.

    Is there anything that our team can do more to help with your situation? I personally will be making tutorials and auditing our exceptions today in result of this as we do not wish anyone to have frustrations with the system in this way. Thank you very much for your honest feedback and I look forward to working in anything that you need. :)
     
    Last edited: Feb 22, 2015
  5. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,932
    Farrisarts, hopefully you are still accepting beta requests! I opened a conversation here as I was not sure where to send an email. :) Hope to hear from you soon.
     
  6. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Yes we are! :)

    I am actually pushing out version 13.3 now. You can either send me a PM with your email or you can send an email to support@beardedmangames.com with the subject "Forge Networking Beta". Thanks for the interest! We are super excited to have you testing out the system. If there is anything you need, just let us know and we will do our best to help out! :)
     
  7. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,932
    I sent a PM but will email you as well. :) Thank you! I am excited too!
     
  8. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    Thanks for the help, added in the exception but I cant see in your example how I can use that to find out any errors when trying to create a host since it needs a socket to able to add to the error event ie reporting that the prot is already being used for hosting? I assume that if the Networking.Host() method does not return null that it has created a hosting socket? If so can you see what is wrong with my create client method below as it never connects, only the Debug.Log("3"); is called the other two debugs are not called so does that mean it is not connecting?
    Code (csharp):
    1.  
    2.   void StartClient()
    3.    {
    4.      hosting = false;
    5.      Debug.Log("client port " + port);
    6.  
    7.      socket = Networking.Connect(ip, (ushort)port, protocolType, isWinRT);
    8.  
    9.      Debug.Log("client connected " + socket.Connected);
    10.  
    11.      if ( proximityBasedUpdates )
    12.        socket.MakeProximityBased(proximityDistance);
    13.  
    14.      socket.serverDisconnected += delegate(string reason)
    15.      {
    16.        NetworkingManager.CallOnMainThread(delegate(object[] args)
    17.        {
    18.          Debug.Log("The server kicked you for reason: " + reason);
    19.  
    20.        }, null);
    21.      };
    22.  
    23.      if ( socket.Connected )
    24.      {
    25.        Debug.Log("1");
    26.        ready = true;
    27.      }
    28.      else
    29.      {
    30.        Debug.Log("3");
    31.        socket.connected += delegate() { ready = true; Debug.Log("2"); };
    32.      }
    33.  
    34.      Networking.SetPrimarySocket(socket);
    35.    }
    36.  
    This is the StartHosting method.
    Code (csharp):
    1.  
    2.   bool StartHosting()
    3.    {
    4.      int tries = 10;
    5.      hosting = true;
    6.  
    7.      Debug.Log("players " + playerCount);
    8.      Debug.Log("protocol " + protocolType);
    9.      Debug.Log("winrt " + isWinRT);
    10.  
    11.      while ( socket == null && tries > 0 )
    12.      {
    13.        socket = Networking.Host((ushort)port, protocolType, playerCount, isWinRT);
    14.  
    15.        if ( socket != null )
    16.        {
    17.          Debug.Log("socket " + socket);
    18.          Debug.Log("con " + socket.Connected);
    19.        }
    20.        else
    21.        {
    22.          Debug.Log("no sock");
    23.        }
    24.  
    25.        if ( socket == null || socket.Connected == false )
    26.        {
    27.          port++;
    28.          tries--;
    29.        }
    30.      }
    31.  
    32.      Debug.Log("con " + socket.Connected);
    33.  
    34.      Debug.Log("Connected to port " + port);
    35.  
    36.      if ( socket == null )
    37.      {
    38.        Debug.Log("Could not start hosting");
    39.        return false;
    40.      }
    41.  
    42.      Networking.SetPrimarySocket(socket);
    43.  
    44.      Networking.PrimarySocket.error += PrimarySocket_error;
    45.  
    46.      if ( proximityBasedUpdates )
    47.        socket.MakeProximityBased(proximityDistance);
    48.  
    49.      socket.serverDisconnected += delegate(string reason)
    50.      {
    51.        NetworkingManager.CallOnMainThread(delegate(object[] args)
    52.        {
    53.          Debug.Log("The server kicked you for reason: " + reason);
    54.          Application.Quit();
    55.        }, null);
    56.      };
    57.  
    58.      if ( socket.Connected )
    59.      {
    60.        Debug.Log("h1");
    61.        ready = true;
    62.      }
    63.      else
    64.        socket.connected += delegate() { ready = true; Debug.Log("h2"); };
    65.  
    66.      return true;
    67.    }
    68.  
    Tried posting this on the forum on your site but I cant see any button to click to start a new topic.
     
    Last edited: Feb 22, 2015
  9. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    I will check out the code now. The only thing I can think of before testing it is the possibility that there is a race condition where the exception is thrown before you have the chance to register the error event. I should have mentioned that our Host and Connect methods are asynchronous. So when you call Host or Connect the library doesn't lock up the main thread until an error is thrown or a connection is established. The response of Host should never be null since it doesn't wait for connections.

    I will take your sample code and make sure it works with some modifications. If it is a race condition, then expect to see version 13.4 hotfix within the hour :)
     
  10. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hello, I have a solution :)

    Here is the full class and I have attached the sample (forgive my re-arrangement):
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using BeardedManStudios.Network;
    4.  
    5. public class Hoster : MonoBehaviour
    6. {
    7.     public bool hosting = false;
    8.     public string ip = "127.0.0.1";
    9.     public int port = 15937;
    10.     public Networking.TransportationProtocolType protocolType = Networking.TransportationProtocolType.UDP;
    11.  
    12. #if UNITY_WINRT && !UNITY_EDITOR
    13.     private bool isWinRT = true;
    14. #else
    15.     private bool isWinRT = false;
    16. #endif
    17.  
    18.     private NetWorker socket = null;
    19.  
    20.     public bool proximityBasedUpdates = false;                                                                // Only send other player updates if they are within range
    21.     public float proximityDistance = 5.0f;                                                                    // The range for the players to be updated within
    22.  
    23.     public bool ready = false;
    24.  
    25.     public int playerCount = 32;
    26.     public int maxHostTries = 10;
    27.     private int currentHostTries = 0;
    28.  
    29.     private void Update()
    30.     {
    31.         if (Input.GetKeyDown(KeyCode.C))
    32.             StartClient();
    33.         else if (Input.GetKeyDown(KeyCode.S))
    34.             AttemptHosting();
    35.     }
    36.  
    37.     void StartClient()
    38.     {
    39.         hosting = false;
    40.         Debug.Log("client port " + port);
    41.  
    42.         socket = Networking.Connect(ip, (ushort)port, protocolType, isWinRT);
    43.  
    44.         Debug.Log("client connected " + socket.Connected);
    45.  
    46.         if (proximityBasedUpdates)
    47.             socket.MakeProximityBased(proximityDistance);
    48.  
    49.         socket.serverDisconnected += delegate(string reason)
    50.         {
    51.             NetworkingManager.CallOnMainThread(delegate(object[] args)
    52.             {
    53.                 Debug.Log("The server kicked you for reason: " + reason);
    54.  
    55.             }, null);
    56.         };
    57.  
    58.         if (socket.Connected)
    59.         {
    60.             Debug.Log("1");
    61.             ready = true;
    62.         }
    63.         else
    64.         {
    65.             Debug.Log("3");
    66.             socket.connected += delegate() { ready = true; Debug.Log("2"); };
    67.         }
    68.  
    69.         Networking.SetPrimarySocket(socket);
    70.     }
    71.  
    72.     void AttemptHosting()
    73.     {
    74.         if (currentHostTries++ >= maxHostTries)
    75.             throw new System.Exception("Unable to establish host connection, max port attempts reached");
    76.  
    77.         int tries = 10;
    78.         hosting = true;
    79.  
    80.         Debug.Log("players " + playerCount);
    81.         Debug.Log("protocol " + protocolType);
    82.         Debug.Log("winrt " + isWinRT);
    83.  
    84.         socket = Networking.Host((ushort)port, protocolType, playerCount, isWinRT);
    85.         socket.error += PrimarySocket_error;
    86.         socket.connected += socket_connected;
    87.     }
    88.  
    89.     void socket_connected()
    90.     {
    91.         Debug.Log("Connection established on port: " + port);
    92.         Networking.SetPrimarySocket(socket);
    93.  
    94.         if (proximityBasedUpdates)
    95.             socket.MakeProximityBased(proximityDistance);
    96.  
    97.         socket.serverDisconnected += delegate(string reason)
    98.         {
    99.             NetworkingManager.CallOnMainThread(delegate(object[] args)
    100.             {
    101.                 Debug.Log("The server kicked you for reason: " + reason);
    102.                 Application.Quit();
    103.             }, null);
    104.         };
    105.  
    106.         Debug.Log("h1");
    107.         ready = true;
    108.     }
    109.  
    110.     private void PrimarySocket_error(System.Exception exception)
    111.     {
    112.         if (exception is System.Net.Sockets.SocketException)
    113.         {
    114.             // Trying to connect to same port error code is 10048, we only want to retry on that one
    115.             if (((System.Net.Sockets.SocketException)exception).ErrorCode == 10048)
    116.             {
    117.                 Debug.Log("Port " + port + " is in use, trying next port");
    118.                 port++;
    119.                 AttemptHosting();
    120.             }
    121.             else
    122.                 Debug.LogException(exception);
    123.         }
    124.         else
    125.         {
    126.             Debug.LogException(exception);
    127.         }
    128.     }
    129. }
    How to use: Build out the scene, run exe and press the "S" key to start a server. Go into Unity and press play and then press the "S" key to start the server in Unity. Check the output logs.

    Note: To verify that the ports are indeed bound you can use "netstat -an" in your console and look in UDP section for the bound ports.
     

    Attached Files:

  11. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    Thanks for that, got that working so now get the error messages so can correctly move the port on, but for some reason I still can't get a client to connect to a host, the connected event never fires and the socket.Connected is false. Tried ip addresses of 127.0.0.1 as well as the lan ip but just cant get the editor to connect to a build exe. It seems to be to do with the fact I start hosts in both and then I start a client to connect to the exe. If I don't create a host in the editor version I get the connected event firing so it will connect, the cube doesn't update but I'll get to that. Is there a problem having a client running at the same time as a host in the same exe?
     
  12. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    No problem :D

    Very strange... I am assuming that you are using the sample code you have provided above. I will test it out to see if there is anything that is missed.

    Edit: I just debug logged it and I got the "2" logged into the editor with the same package I sent. Is your Unity Editor allowed through your Windows Firewall?

    Working Image:
    screen_2.jpg
     
  13. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    Yes, also oddly using the arrow keys I can move the cube as in your simple example in the host build but cant in the client so looks like the network is controlling the cube somehow.
     
  14. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    So you are able to control the cube over the network but your connection events are not firing for the client? Also is this a cube that is already in the scene. In that case, the host owns the object and the client will not be able to change it (unless you do coding to change that).
     
  15. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    I am just following the step by step video on your site which has the DemoMove.cs script to move a cube so the cube is in the scene as it is in your video. Just want to get that working before I start doing some proper scenes and object moving etc.
     
  16. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Okay, I will audit this video tutorial right now to make sure that there hasn't been any major changes that could cause it to have in-correct information.
     
  17. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    I just played through the video and followed from scratch without any issues on my end. Are you using the "ForgeQuickStartMenu" scene as the loading scene or a custom one? Also if you click "Find on LAN" on the client and it loads the scene with the cube, then it has established a connection successfully.

    I did notice that in the older build there wasn't any of the new Find on LAN or Server Browser stuff so I added in a helper annotation on YouTube. Thanks for making me re-visit that tutorial so that I could make that change :)
     
  18. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    Not using the scenes, I am starting the host and clients in the current scene. It's a bit of a pain while testing to be adding scripts etc to the demo scene to then have to save that, find and load the startup scene then hit play, just want to have a test scene that when it starts it starts a host and if the player presses a key it will start a client and join the other game.
     
  19. Sezerza

    Sezerza

    Joined:
    Aug 9, 2013
    Posts:
    27
    Hello everyone!

    If I wanted to create a game where you login with an account, select character, friends list, talk, and join lobbies, etc, and then you can start a game, but the server is still the host, could I, or should I have the game lobby and then all the actual games all be hosted from a single application or should each actual game have its own serverside application running? The server would not be playing nor need visuals.

    Sorry if the question is unclear, I'm pretty new to networking, and I'm still wrapping my head around networking models and concepts, and I'm not sure how to word my question so that i can look it up on Google.

    The best example i can think of off the top of my head would be something like League of Legends. You log in, queue up, then join a game with 9 others that actually launches the game.

    Also, this would be a turn based game, so not a ton of information moving around.

    Thanks in advanced!
     
  20. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hello!

    So it really can be done in the way that you design (I know that doesn't help much). However, something that you can do is have the login and character selection completely separated out from actually connecting to the game server. You then can do the lobby in a couple of ways. One would be that you just have a lobby server that waits for people to join, when it is ready then it kicks off the game. The other way would be that the players connect to the server which is playing a lobby scene, the server then sends an RPC to all of the clients to tell them that they need to go to "this scene" and then they all load up the level (the server should load the level first, then tell the players to join in).

    With server/client communication, the client/server do not need to have the scene open. In fact, Bare Metal never loads a Unity scene because it is independent of Unity.

    Let me know if this makes sense or if you need more information, we are happy to help out :D
     
  21. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    No problem, this is how we often test ourselves, we do not go through the Demo Menu scene. I will try out the code that we were using earlier in an isolated instance while following along with the Step by Step example. Hopefully I can replicate the issue :)
     
  22. imgodot

    imgodot

    Joined:
    Nov 29, 2013
    Posts:
    212
    Open Issues:
    1) Authoritative movement.
    2) RPC on another "networking object".
    3) List of events developers can hook into.

    -- Paul
     
  23. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    What is wrong with authoritative movement, is there a bug?

    @farrisarts Could we have an authoritative movement demo scene?
    So the client's just send key input to the server as an RPC, and the server handles this input, and sends the resulting transforms back to the client.

    I think this will help imgodot and myself as I am starting now to look at authoritative movement now that I have the rigidbodies working in Forge.

    I am also finding the documentation a bit lacking. None of the classes or properties really have any useful descriptions.

    For example :
    NetworkedMonoBehavior.isPlayer Field : Get whether this is a player or not

    Ok nice, but what exactly does this mean? What does it change? When should it be used, when shouldn't it? If the server is authoritative, would the server owned player objects still be marked as isPlayer?
     
  24. Sezerza

    Sezerza

    Joined:
    Aug 9, 2013
    Posts:
    27
    Very informative, Thank You!

    Can You send RPCs to only certain players?
    for example, 30 players are connected to a server at the initial lobby scene, 10 start a game. Can I rpc just those 10 to move onto game scene?
     
  25. imgodot

    imgodot

    Joined:
    Nov 29, 2013
    Posts:
    212
    No bug (that I'm aware of).
    This references a prior post where I included some code that wasn't working and Brent was going to look into it.
    My "list" post was a way for me to bump issues from prior posts.
    -- Paul

    P.S. I second the motion on more docs and demo scenes, though I also realize these guys are trying to implement new features, quash bugs, update docs, and reply to posts while working jobs and (possibly) having lives.
     
  26. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Yes, you can do this with the "AuthoritativeRPC" method

    Code (CSharp):
    1. // SimpleNetworkedMonoBehavior
    2.  
    3. public void AuthoritativeRPC(string methodName, NetWorker socket, NetworkingPlayer player, bool runOnServer, params object[] arguments)
    4.  
    5. This will allow you to send updates to a particular player from the server.
     
  27. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hey! Thanks for the bump, it helped group what we needed all in one place. I'll be adding them to the website feature request as well so I we can make sure to track them.
     
  28. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Yes :) there is nothing "wrong" that we know of, as stated this was just something we needed to look into for Paul

    Yes! I am very sorry about this. I actually haven't had the time to go back through the docs and clean that up. I will make sure to prioritize it now.
     
  29. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    No problem, I can see that these are critical to have better documentation on them. Also we haven't built them in a few days so we need to update them anyway.

    Hehe :)
     
  30. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    310
    We try to do our best! Glad to know that our work is getting noticed and that people can be understanding of our situation. As long as we are both wanting to better this system to be used on any type of project, I think we will lose a bit of sleep as long as it puts a smile in your heart and in your wallet. :)
     
    Zaddo67 likes this.
  31. imgodot

    imgodot

    Joined:
    Nov 29, 2013
    Posts:
    212
    Brent, I've seen that method in the docs and wondered about it.

    However, is it really relevant to my previous posts on authoritative movement, where I was using networked variables to send player input to the server, having the server apply forces to the player object's rigidbody and letting the pos/rot changes update automatically on the clients via NetMonoBehavior scripts on their objects?

    =====================================================
    Regarding AuthoritativeRPC:
    Where/when is it called?
    You said server (so OwningNetworker.IsServer=TRUE?), but when should it be called, where IsOwner = FALSE or ...?
    Does it get mixed into the networked object code in the Update() or FixedUpdate() methods.

    -- Paul
     
  32. imgodot

    imgodot

    Joined:
    Nov 29, 2013
    Posts:
    212
    Putting what in my wallet!?
    Is Forge putting things in my wallet?
    How is Forge getting access to my wallet when it's sitting on a shelf in my living room?
    Does the NSA have some wireless access point built into the velcro on my wallet that you've hacked into?
    Now, you have me worried!
    Lucky I don't have a paranoid personality.
     
    Cranick and Brent_Farris like this.
  33. Sezerza

    Sezerza

    Joined:
    Aug 9, 2013
    Posts:
    27
    Ahh ok. I saw this in the docs, but wasn't too clear on it.
    So how can I keep track of NetworkingPlayers as they connect to the server? Where can I get this variable from?

    I saw "OnPlayerConnected(
    NetworkingPlayer player)" in the docs. Is this my best/only option?

    EDIT
    Ah I also saw that someone reported in the feedback on the dev portal that currently using OnPlayerConnected conflicts with a monobehaviour method so the forge one is inaccessible for now?
     
    Last edited: Feb 23, 2015
  34. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    On the server you have access to all of the players that have connected to the server. You can do this with:
    Code (CSharp):
    1. Networking.PrimarySocket.Players
    :) This is a List<NetworkingPlayer> of all of the players that have connected to the server

    This is actually should be an internal method that you should not need to call. What we gave you guys for capturing player connectsion is http://www.beardedmanstudios.com/forge/Help/html/00f02383-2315-f7bd-14d5-455a4399f2e7.htm
    This is an event that you can register a method of your own to in order to capture any player connections on the server.

    Actually this wasn't really a bug. They were registering the "playerConnected" event to a method that they named "OnPlayerConnected", basically since Unity reserves this method name it will throw an error. So all that they needed to do is change the name of their method to something else.

    Let me know if this helps or if you need some more information :)
     
  35. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    I actually just sent an email to @Meltdown about autoritative movements being simulated on the server. I will paste a portion of it here, please let me know if it helps :) *Guess I should have done it here in the first place*.

    Quoting Emal:
    For the AuthoritativeRPC. This is actually called as soon as it is received from the network. You will make a "[BRPC]" method and then call that method via the AuthoritativeRPC.

    Please let me know if this helps :)
     
  36. Sezerza

    Sezerza

    Joined:
    Aug 9, 2013
    Posts:
    27

    Ah I see. Does a client have access to it's own NetworkingPlayer?
     
  37. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    The client (and server) has access to Networking.PrimarySocket.Me which is a NetworkingPlayer. :)
     
  38. Sezerza

    Sezerza

    Joined:
    Aug 9, 2013
    Posts:
    27
    Ah OK, great! While I was reading the docs on the NetWorker class, it said "Me --- This is the servers reference to it's own player (NOT used by client)" so that threw me off.
     
  39. imgodot

    imgodot

    Joined:
    Nov 29, 2013
    Posts:
    212
    Thanks for the code, I can't wait to get home and try it out!

    However, the authoritative RPC is still eluding me.
    I'm not sure what the "it "is that is received from the network.
    Perhaps you could throw a couple of lines of pseudocode to show what you mean?
    Thanks
    -Paul
     
  40. imgodot

    imgodot

    Joined:
    Nov 29, 2013
    Posts:
    212
    I set up my code as you showed and now I get no movement for the client OR the server!
    And, honestly, I am getting discouraged.
    Code (CSharp):
    1. void FixedUpdate() {
    2.         if (!IsOwner && OwningNetWorker.IsServer) {
    3.             // Server logic
    4.             MovePlayer(horizontalInput, verticalInput);
    5.         } else {
    6.             // Client logic
    7.             horizontalInput = Input.GetAxis("Horizontal");
    8.             verticalInput = Input.GetAxis("Vertical");
    9.         }
    10.  
    Here is my setup [a Frankenstein of the start scene and the ForgeHelloCubeResources (FHCR) scene]:
    A) I took the menu canvas from the start scene and copied it to the FHCR scene.
    B) First: In the "GO()" method, the menu canvas is disabled.
    C) Second: In the "GO()" method, the networking manager (which starts off disabled) is enabled.
    D) Third: In the "GO()" method, I network instantiate an object (that has a rigidbody).
    When testing, I have one object network instantiated on the server and one on the client.

    I truly appreciate all effort and time that you guys invest in this endeavor day after day and, I'd really like to make something with Forge to help beta test more features, but I can't even get past the basics.
    It just feels like I am stymied at every turn.

    ALSO:
    Something odd I just noticed, the rigidbody of the "other" player has its position and rotation frozen, and NOT by me.
    I.e. On the server, the client's rigidbody has everything frozen and, on the client, the server's rigidbody is frozen.
    This seems to have nothing to do with movement because, I tried setting rigidbodies to be unfrozen in the Start() of the networked objects and, still, no-one moves.
     
    Last edited: Feb 24, 2015
    Meltdown likes this.
  41. zapoutix

    zapoutix

    Joined:
    Jan 2, 2015
    Posts:
    44
    Hi guys,

    I have an issue on android with Good ol' Sockets.

    server side is on windows, client side on android using UDP protocol.
    After used a WriteCustom client side, then the client disconnect, i don't get the playerDisconnected event on the server side.

    It works if both client and server are on windows

    Regards,
     
  42. CathyR

    CathyR

    Joined:
    Feb 23, 2015
    Posts:
    4
    Where do we buy this?
     
  43. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    310
    It is currently in Open Beta right now as we are still developing it. :)

    Please send us an email at support@beardedmangames.com if you would like to join!
     
  44. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    310
    I will look into this issues and make it my top priority. Must have been somethig on the mobile platform that needs a simple tweak. Thanks for letting me know!
     
  45. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    How do I go about sending a large amount of data to a specific client? In case a client missed some packets, I need the server to send all the packets missed which can hit 86,400 B maximum but will be much closer to 17,200 B at high points. Can this amount of data be sent over in a short a mount of time and if so, how should I do it? If multiple packets are needed, I don't need correct packet order - just that the contents inside packets are intact.
     
    Last edited: Feb 24, 2015
  46. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hey, I am sorry to hear about the problems :(. Do you think that you can send us a sample scene to work with? Maybe we can better assist to see what all is going on. If you can't send us a sample scene we can go by what you have said and try to build up something ourselves. One of us will be able to check it out tonight if you can send it.
     
  47. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hmmm, well if you are doing this all through write raw you will need to make some header packets yourself. If you send it through the standard system then they will auto-magically be split into packets and sent across the network in chunks, then re-constructed on the other side.
     
  48. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    Auto-magically sounds awesome :cool:.
    Which method would you recommend? I prefer something similar to WriteRaw where I can hook onto the event to get the data.
     
  49. imgodot

    imgodot

    Joined:
    Nov 29, 2013
    Posts:
    212
    I exported the scene and resources with dependencies.
    If you need something, I missed, let me know.

    Thanks for the help.
    -- Paul
     

    Attached Files:

  50. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hmm, the closest thing that you can hook into to get the data would be the WriteCustom. This can be done with reliable headers and will take care of the packet chunking for you. :)