- Home /
Upgrading from Legacy Networking to new networking 2019.1
I am struggling for a few days now getting my asset from 2017.4 to 2019.1 and new version support.
I have fixed all non networking issues but I have no idea how to fix the networking issues since the legacy networking was removed.
I can no where find any information about the new networking but a colleague found a Github folder with the under development network code.
Since my C# knowledge is very low am I unable to get it setup without proper documentation.
I hope some people here can help me fixing the problems I have.
I will post down below the code I need help with.
if !(UNITY_METRO || UNITY_WP8 || UNITY_NACL_CHROME || UNITY_WEBGL)
/// <summary>Called on the client when the connection was lost or you disconnected from the server.</summary>
public virtual void OnDisconnectedFromServer(NetworkDisconnection info) { }
/// <summary>Called on the client when a connection attempt fails for some reason.</summary>
public virtual void OnFailedToConnect(NetworkConnectionError error) { }
/// <summary>Called on clients or servers when there is a problem connecting to the MasterServer.</summary>
public virtual void OnFailedToConnectToMasterServer(NetworkConnectionError info) { }
/// <summary>Called on clients or servers when reporting events from the MasterServer.</summary>
public virtual void OnMasterServerEvent(MasterServerEvent msEvent) { }
/// <summary>Called on objects which have been network instantiated with Network Instantiate.</summary>
public virtual void OnNetworkInstantiate(NetworkMessageInfo info) { }
/// <summary>Called on the server whenever a new player has successfully connected.</summary>
public virtual void OnPlayerConnected(NetworkPlayer player) { }
/// <summary>Called on the server whenever a player disconnected from the server.</summary>
public virtual void OnPlayerDisconnected(NetworkPlayer player) { }
/// <summary>Used to customize synchronization of variables in a script watched by a network view.</summary>
public virtual void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) { }
#endif
}
}
Thats one of the 3 scripts that have troubles.
#if !(UNITY_METRO || UNITY_WP8 || UNITY_NACL_CHROME || UNITY_WEBGL)
Subject<NetworkDisconnection> onDisconnectedFromServer;
/// <summary>Called on the client when the connection was lost or you disconnected from the server.</summary>
public override void OnDisconnectedFromServer(NetworkDisconnection info)
{
if (onDisconnectedFromServer != null) onDisconnectedFromServer.OnNext(info);
}
/// <summary>Called on the client when the connection was lost or you disconnected from the server.</summary>
public IObservable<NetworkDisconnection> OnDisconnectedFromServerAsObservable()
{
return onDisconnectedFromServer ?? (onDisconnectedFromServer = new Subject<NetworkDisconnection>());
}
Subject<NetworkConnectionError> onFailedToConnect;
/// <summary>Called on the client when a connection attempt fails for some reason.</summary>
public override void OnFailedToConnect(NetworkConnectionError error)
{
if (onFailedToConnect != null) onFailedToConnect.OnNext(error);
}
/// <summary>Called on the client when a connection attempt fails for some reason.</summary>
public IObservable<NetworkConnectionError> OnFailedToConnectAsObservable()
{
return onFailedToConnect ?? (onFailedToConnect = new Subject<NetworkConnectionError>());
}
Subject<NetworkConnectionError> onFailedToConnectToMasterServer;
/// <summary>Called on clients or servers when there is a problem connecting to the MasterServer.</summary>
public override void OnFailedToConnectToMasterServer(NetworkConnectionError info)
{
if (onFailedToConnectToMasterServer != null) onFailedToConnectToMasterServer.OnNext(info);
}
/// <summary>Called on clients or servers when there is a problem connecting to the MasterServer.</summary>
public IObservable<NetworkConnectionError> OnFailedToConnectToMasterServerAsObservable()
{
return onFailedToConnectToMasterServer ?? (onFailedToConnectToMasterServer = new Subject<NetworkConnectionError>());
}
Subject<MasterServerEvent> onMasterServerEvent;
/// <summary>Called on clients or servers when reporting events from the MasterServer.</summary>
public override void OnMasterServerEvent(MasterServerEvent msEvent)
{
if (onMasterServerEvent != null) onMasterServerEvent.OnNext(msEvent);
}
/// <summary>Called on clients or servers when reporting events from the MasterServer.</summary>
public IObservable<MasterServerEvent> OnMasterServerEventAsObservable()
{
return onMasterServerEvent ?? (onMasterServerEvent = new Subject<MasterServerEvent>());
}
Subject<NetworkMessageInfo> onNetworkInstantiate;
/// <summary>Called on objects which have been network instantiated with Network.Instantiate.</summary>
public override void OnNetworkInstantiate(NetworkMessageInfo info)
{
if (onNetworkInstantiate != null) onNetworkInstantiate.OnNext(info);
}
/// <summary>Called on objects which have been network instantiated with Network.Instantiate.</summary>
public IObservable<NetworkMessageInfo> OnNetworkInstantiateAsObservable()
{
return onNetworkInstantiate ?? (onNetworkInstantiate = new Subject<NetworkMessageInfo>());
}
Subject<NetworkPlayer> onPlayerConnected;
/// <summary>Called on the server whenever a new player has successfully connected.</summary>
public override void OnPlayerConnected(NetworkPlayer player)
{
if (onPlayerConnected != null) onPlayerConnected.OnNext(player);
}
/// <summary>Called on the server whenever a new player has successfully connected.</summary>
public IObservable<NetworkPlayer> OnPlayerConnectedAsObservable()
{
return onPlayerConnected ?? (onPlayerConnected = new Subject<NetworkPlayer>());
}
Subject<NetworkPlayer> onPlayerDisconnected;
/// <summary>Called on the server whenever a player disconnected from the server.</summary>
public override void OnPlayerDisconnected(NetworkPlayer player)
{
if (onPlayerDisconnected != null) onPlayerDisconnected.OnNext(player);
}
/// <summary>Called on the server whenever a player disconnected from the server.</summary>
public IObservable<NetworkPlayer> OnPlayerDisconnectedAsObservable()
{
return onPlayerDisconnected ?? (onPlayerDisconnected = new Subject<NetworkPlayer>());
}
Subject<Tuple<BitStream, NetworkMessageInfo>> onSerializeNetworkView;
/// <summary>Used to customize synchronization of variables in a script watched by a network view.</summary>
public override void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
{
if (onSerializeNetworkView != null) onSerializeNetworkView.OnNext(Tuple.Create(stream, info));
}
/// <summary>Used to customize synchronization of variables in a script watched by a network view.</summary>
public IObservable<Tuple<BitStream, NetworkMessageInfo>> OnSerializeNetworkViewAsObservable()
{
return onSerializeNetworkView ?? (onSerializeNetworkView = new Subject<Tuple<BitStream, NetworkMessageInfo>>());
}
#endif
}
}
Thats the second script.
public class uFrameNetworkComponent : NetworkBehaviour, IDisposableContainer
Thats the last conflicting code which plays in NetworkBegaviour.
It would be awesome if some of you can help me fixing this!
Thanks!!
Your answer
Follow this Question
Related Questions
Networking - Unity stuck by pressing play button in editor 2018 2 1 Answer
Spawn networked player then add local object references [UNET] 1 Answer
Different movement speeds over network 1 Answer
Network command is running on client? 1 Answer
Trying to send command for object without authority. - change color of object from client 0 Answers