Unity Networking

Classé dans : Non classé | 0

Connexion

using UnityEngine.Networking;

  • Netwok.connect : previous Unity connexion system. doesn’t communicate with the new UNet system
  • NetworkManager use NetworkServer & NetworkClient to handle connections for both client and server side
  • NetworkLobbyManager : herite from NetworkManager. Add lobby scene where clients are registered
  • NetworkDiscovery : handle broadcast signal. Use it to receive ip adress/port and make connexion using NetworkManager

Get all current connexion :

Server side

NetworkServer.RegisterHandler(MsgType.Connect, EventConnectionActionServer);

 

NEED To Test https://forum.unity.com/threads/get-local-players-game-object.332426/#post-3425934

Does ClientScene.localPlayers() do what you need?

You can also use the netId propetry of NetworkBehavior and ClientScene.FindLocalObject(NetworkInstanceId netId)

Client Side

It ONLY knows the Server connexion :

NetworkClient.allClients[0].connection ; valid after connexion is made

This is NOT a list of all clients that are connected to the remote server, it is client instances on the local game.

You can make a client with multiple server (for example, one for chat/login, another for in game mechanism, …)

 

Get local Player prefab

Get Local Player Prefab : NetworkManager.singleton.spawnPrefabs[0] ? Que côté server !

NetworkBehaviour renvoi les infos de connexion/déconnexion côté client !

Send big files

UNet https://answers.unity.com/questions/1113376/unet-send-big-amount-of-data-over-network-how-to-s.html

really not made for it, takes ~10s to send ~1mb

ou TCP Socket avec .Net https://stackoverflow.com/questions/42717713/unity-live-video-streaming

made for it, but you have to manage threads and sockets. take less than 1s to send ~1mb

From client to server:

[Command] public void CmdTakePicture()

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *