public RhinoSender(string _payload, Interop _Context)
        {
            Context = _Context;

            dynamic InitPayload = JsonConvert.DeserializeObject <ExpandoObject>(_payload);

            Client = new SpeckleApiClient(( string )InitPayload.account.restApi, true);

            StreamName = ( string )InitPayload.streamName;

            SetClientEvents();
            SetRhinoEvents();
            SetTimers();

            Display         = new SpeckleDisplayConduit();
            Display.Enabled = true;

            Context.NotifySpeckleFrame("set-gl-load", "", "true");

            Client.IntializeSender(( string )InitPayload.account.apiToken, Context.GetDocumentName(), "Rhino", Context.GetDocumentGuid())
            .ContinueWith(res =>
            {
                StreamId           = Client.Stream.StreamId;
                Client.Stream.Name = StreamName;

                Context.NotifySpeckleFrame("set-gl-load", "", "false");
                Context.NotifySpeckleFrame("client-add", StreamId, JsonConvert.SerializeObject(new { stream = Client.Stream, client = Client }));
                Context.UserClients.Add(this);

                InitTrackedObjects(InitPayload);
                DataSender.Start();
            });
        }
        protected RhinoReceiver(SerializationInfo info, StreamingContext context)
        {
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            Display         = new SpeckleDisplayConduit();
            Display.Enabled = true;

            Objects = new List <SpeckleObject>();

            byte[] serialisedClient = Convert.FromBase64String(( string )info.GetString("client"));

            using (var ms = new MemoryStream())
            {
                ms.Write(serialisedClient, 0, serialisedClient.Length);
                ms.Seek(0, SeekOrigin.Begin);
                Client   = (SpeckleApiClient) new BinaryFormatter().Deserialize(ms);
                StreamId = Client.StreamId;
            }

            Client.OnReady     += Client_OnReady;
            Client.OnLogData   += Client_OnLogData;
            Client.OnWsMessage += Client_OnWsMessage;
            Client.OnError     += Client_OnError;
        }
Пример #3
0
        protected RhinoSender(SerializationInfo info, StreamingContext context)
        {
            byte[] serialisedClient = Convert.FromBase64String(( string )info.GetString("client"));

            using (var ms = new MemoryStream())
            {
                ms.Write(serialisedClient, 0, serialisedClient.Length);
                ms.Seek(0, SeekOrigin.Begin);
                Client   = (SpeckleApiClient) new BinaryFormatter().Deserialize(ms);
                StreamId = Client.StreamId;
            }

            SetClientEvents();
            SetRhinoEvents();
            SetTimers();

            Display         = new SpeckleDisplayConduit();
            Display.Enabled = true;
        }
Пример #4
0
        public RhinoReceiver(string _payload, Interop _parent)
        {
            Context = _parent;
            dynamic payload = JsonConvert.DeserializeObject(_payload);

            StreamId = ( string )payload.streamId;

            Client = new SpeckleApiClient(( string )payload.account.restApi, true);

            Client.OnReady     += Client_OnReady;
            Client.OnLogData   += Client_OnLogData;
            Client.OnWsMessage += Client_OnWsMessage;
            Client.OnError     += Client_OnError;

            Client.IntializeReceiver(( string )payload.streamId, Context.GetDocumentName(), "Rhino", Context.GetDocumentGuid(), ( string )payload.account.token);

            Display         = new SpeckleDisplayConduit();
            Display.Enabled = true;

            Objects = new List <SpeckleObject>();
        }
Пример #5
0
        protected RhinoReceiver(SerializationInfo info, StreamingContext context)
        {
            Display         = new SpeckleDisplayConduit();
            Display.Enabled = true;

            Objects = new List <SpeckleObject>();

            byte[] serialisedClient = Convert.FromBase64String(( string )info.GetString("client"));

            using (var ms = new MemoryStream())
            {
                ms.Write(serialisedClient, 0, serialisedClient.Length);
                ms.Seek(0, SeekOrigin.Begin);
                Client            = (SpeckleApiClient) new BinaryFormatter().Deserialize(ms);
                Client.ClientType = "Rhino";
                StreamId          = Client.StreamId;
            }

            Client.OnReady     += Client_OnReady;
            Client.OnLogData   += Client_OnLogData;
            Client.OnWsMessage += Client_OnWsMessage;
            Client.OnError     += Client_OnError;
        }