private Receiver CreateReceiver(SpeckleStream stream, Transform parent, bool autoReceive, bool deleteOld)
        {
            string     streamID         = stream.id;
            GameObject streamGameObject = Instantiate(streamParentPrefab, Vector3.zero, Quaternion.identity, parent);

            streamGameObject.name = $"Receiver-{streamID}";

            Receiver receiver = streamGameObject.AddComponent <Receiver>();

            receiver.Init(streamID, autoReceive, deleteOld,
                          onDataReceivedAction: (go) =>
            {
                // when the stream has finished being received
                go.transform.parent = receiver.transform;

                {     //Dissable revit group objects
                    Transform room = go.transform.Find("@Rooms");
                    if (room)
                    {
                        room.gameObject.SetActive(false);
                    }
                    Transform model = go.transform.Find("@Model Groups");
                    if (model)
                    {
                        model.gameObject.SetActive(false);
                    }
                }

                Debug.Log($"Finished receiving {stream}");
                busyReceivers.RemoveItem(receiver);
                HideReceiver(receiver, true);
                OnStreamReceived?.Invoke(stream, receiver);
            },
                          onTotalChildrenCountKnown: (count) => { receiver.TotalChildrenCount = count; },
                          onProgressAction: (dict) =>
            {
                //Run on a dispatcher as GOs can only be retrieved on the main thread
                Dispatcher.Instance().Enqueue(() =>
                {
                    //When a part of the model has been received.
                    double val = dict.Values.Average() / receiver.TotalChildrenCount;
                    OnReceiverUpdate?.Invoke(stream, receiver, val);
                });
            });



            return(receiver);
        }
Example #2
0
 public void PushStream(IncomingStream incStream)
 {
     OnStreamReceived?.Invoke(incStream);
 }