public void SendFrom(string clientId, Vector3 _position, Quaternion _rotation) { GameObject prefab = Instantiate(References.defaults.SERVER_PLAYER_PREFAB, _position, _rotation); ServerPlayerManager.AddPlayerPrefab(prefab, clientId); // spawn new client onn all existing clients SendPackageFrom(clientId, new SpawnFlowServerPackage() { position = _position, rotation = _rotation }).SendAll(SendMethod.ReliableOrdered); // spawn already existing clients on the newly connected client FlowServer.IterateConnectedClients((FlowClientServer client) => { if (client.id != clientId) { SendPackageFrom(client.id, new SpawnFlowServerPackage() { position = _position, rotation = _rotation }).Send(SendMethod.ReliableOrdered, clientId); } return(true); }); }
/// <summary> /// Sends the package to all connected peers /// </summary> /// <param name="method"></param> public void SendAll(SendMethod method) { if (isClient) { throw new NotSupportedException("SendAll is not supported on the client."); } FlowServer.IterateConnectedClients((FlowClientServer client) => { client.peer.Send(writer, (DeliveryMethod)method); return(true); }); }
/// <summary> /// Sends the package to only the clients defined in clientIds /// </summary> /// <param name="method"></param> /// <param name="clientIds"></param> public void SendExclusively(SendMethod method, string[] clientIds) { if (isClient) { throw new NotSupportedException("SendMultiple is not supported on the client."); } FlowServer.IterateConnectedClients((FlowClientServer client) => { if (StringInArray(clientIds, client.id)) { client.peer.Send(writer, (DeliveryMethod)method); } return(true); }); }