Example #1
0
        public virtual void Client_OnWsMessage(object source, SpeckleEventArgs e)
        {
            if (Paused)
            {
                Context.NotifySpeckleFrame("client-expired", StreamId, "");
                return;
            }

            switch ((string)e.EventObject.args.eventType)
            {
            case "update-global":
                UpdateGlobal();
                break;

            case "update-meta":
                UpdateMeta();
                break;

            case "update-name":
                UpdateName();
                break;

            case "update-object":
                break;

            case "update-children":
                UpdateChildren();
                break;

            default:
                Context.NotifySpeckleFrame("client-log", StreamId, JsonConvert.SerializeObject("Unkown event: " + (string)e.EventObject.args.eventType));
                break;
            }
        }
        public virtual void OnWsMessage(object source, SpeckleEventArgs e)
        {
            if (Paused)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Update available since " + DateTime.Now);
                Expired = true;
                return;
            }

            switch (( string )e.EventObject.args.eventType)
            {
            case "update-global":
                UpdateGlobal();
                break;

            case "update-meta":
                UpdateMeta();
                break;

            case "update-name":
                UpdateMeta();
                break;

            case "update-children":
                UpdateChildren();
                break;

            default:
                CustomMessageHandler(( string )e.EventObject.args.eventType, e);
                break;
            }
        }
 public virtual void OnReady(object source, SpeckleEventArgs e)
 {
     Debug.WriteLine("Sender ready:::" + (string)e.Data.streamId + ":::" + (string)e.Data.wsSessionId);
     this.ready       = true;
     this.streamId    = e.Data.streamId;
     this.wsSessionId = e.Data.wsSessionId;
 }
        public virtual void OnWsMessage(object source, SpeckleEventArgs e)
        {
            try
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, e.EventObject.args.eventType + "received at " + DateTime.Now + " from " + e.EventObject.senderId);
                switch ((string)e.EventObject.args.eventType)
                {
                case "get-definition-io":
                    if (EnableRemoteControl == false)
                    {
                        return;
                    }

                    Dictionary <string, object> message = new Dictionary <string, object>();
                    message["eventType"]   = "get-def-io-response";
                    message["controllers"] = DefaultSpeckleInputs;
                    message["outputs"]     = DefaultSpeckleOutputs;

                    Client.SendMessage(e.EventObject.senderId, message);
                    break;

                case "compute-request":
                    if (EnableRemoteControl == true)
                    {
                        var requestClientId = (string)e.EventObject.senderId;
                        if (JobQueue.Contains(requestClientId))
                        {
                            JobQueue[requestClientId] = e.EventObject.args.requestParameters;
                        }
                        else
                        {
                            JobQueue.Add(requestClientId, e.EventObject.args.requestParameters);
                        }

                        AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, Document.SolutionState.ToString());

                        if (JobQueue.Count == 1) // means we  just added one, so we need to start the solve loop
                        {
                            Rhino.RhinoApp.MainApplicationWindow.Invoke(ExpireComponentAction);
                        }
                    }
                    else
                    {
                        Dictionary <string, object> computeMessage = new Dictionary <string, object>();
                        computeMessage["eventType"] = "compute-request-error";
                        computeMessage["response"]  = "Remote control is disabled for this sender";
                        Client.SendMessage(e.EventObject.senderId, computeMessage);
                    }
                    break;

                default:
                    Log += DateTime.Now.ToString("dd:HH:mm:ss") + " Defaulted, could not parse event. \n";
                    break;
                }
            }
            catch
            {
            }
            Debug.WriteLine("[Gh Sender] Got a volatile message. Extend this class and implement custom protocols at ease.");
        }
Example #5
0
    public virtual void Client_OnWsMessage(object source, SpeckleEventArgs e)
    {
        //Debug.Log("Client WsMessage");
        //Debug.Log(JsonConvert.SerializeObject(e.EventData));

        //Set refresh to true to prompt recreating geometry
        bRefreshDisplay = true;
    }
Example #6
0
        public virtual void OnMetadata(object source, SpeckleEventArgs e)
        {
            Name = NickName = (string)e.Data.name;
            DiffStructure(e.Data.layers);
            Layers = e.Data.layers;

            Debug.WriteLine("metadata event");
        }
Example #7
0
        public virtual void Client_OnReady(object source, SpeckleEventArgs e)
        {
            Context.NotifySpeckleFrame("client-add", StreamId, JsonConvert.SerializeObject(new { stream = Client.Stream, client = Client }, Interop.camelCaseSettings));

            Context.UserClients.Add(this);

            UpdateGlobal();
        }
Example #8
0
        public virtual void OnReady(object source, SpeckleEventArgs e)
        {
            Debug.WriteLine("[Gh Receiver] Got a ready message. Extend this class and implement custom protocols at ease.");

            Name = NickName = (string)e.Data.name;
            DiffStructure(e.Data.layers);
            Layers  = e.Data.layers;
            Objects = e.Data.objects;

            Debug.WriteLine("ready event");
            Rhino.RhinoApp.MainApplicationWindow.Invoke(ExpireComponentAction);
        }
Example #9
0
        public virtual void OnData(object source, SpeckleEventArgs e)
        {
            Debug.WriteLine("RECEIVER: Received live update event: " + e.EventInfo);
            Name = NickName = (string)e.Data.name;
            DiffStructure(e.Data.layers);
            Layers  = e.Data.layers;
            Objects = e.Data.objects;

            Debug.WriteLine("data event");
            Message = "Loaded update.";
            Rhino.RhinoApp.MainApplicationWindow.Invoke(ExpireComponentAction);
        }
        /// <summary>
        /// Invoked whenever this client is notified of updates to the stream from the server.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        /// <remarks>NOTE: At the time of writing, coroutines can't be invoked via event
        /// callbacks for some reason. Until this is resolved, the <c>OnWsMessageCheck ()</c>
        /// method can't be called directly and instead, the manager instance will
        /// check on each frame whether the method needs to be called in response
        /// to this method being invoked.</remarks>
        protected override void ClientOnWsMessage(object source, SpeckleEventArgs e)
        {
            if (!receiveUpdates)
            {
                return;
            }

            if (e == null)
            {
                return;
            }
            //if (e.EventObject == null) return;

            WSMessageData wSMessageData = JsonUtility.FromJson <WSMessageData> (e.EventData);

            //Events aren't firing coroutines directly, so using boolean value to trigger firing in update
            messageReceived = true;
            messageContent  = wSMessageData.args.eventType;

            //OnWsMessageCheck ();
        }
Example #11
0
        public override void OnWsMessage(object source, SpeckleEventArgs e)
        {
            base.OnWsMessage(source, e);
            switch (( string )e.EventObject.args.eventType)
            {
            case "get-defintion-io":

                List <SpeckleInputParam>  inputControllers  = null;
                List <SpeckleOutputParam> outputControllers = null;
                GetDefinitionIO(ref inputControllers, ref outputControllers);

                Dictionary <string, object> message = new Dictionary <string, object>();
                message["eventType"]   = "get-def-io-response";
                message["controllers"] = inputControllers;
                message["outputs"]     = outputControllers;

                mySender.SendMessage(e.EventObject.senderId, message);
                break;

            case "compute-request":
                var key = ( string )e.EventObject.senderId;
                if (JobQueue.Contains(( string )e.EventObject.senderId))
                {
                    JobQueue[key] = e.EventObject.args.requestParameters;
                }
                else
                {
                    JobQueue.Add(key, e.EventObject.args.requestParameters);
                }

                Rhino.RhinoApp.MainApplicationWindow.Invoke(ExpireComponentAction);
                break;

            default:
                Log += DateTime.Now.ToString("dd:HH:mm:ss") + " Defaulted, could not parse event. \n";
                break;
            }
        }
Example #12
0
 public override void OnVolatileMessage(object source, SpeckleEventArgs e)
 {
     base.OnVolatileMessage(source, e);
     System.Diagnostics.Debug.WriteLine("I've Inherited this method and now i can do whatever I want here, like my own extra protocol.");
     System.Diagnostics.Debug.WriteLine((string)e.Data.args);
 }
Example #13
0
 public virtual void OnError(object source, SpeckleEventArgs e)
 {
     AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.EventInfo);
 }
Example #14
0
 private void OnDataMessage(object source, SpeckleEventArgs e)
 {
     Message = "Update in progress.";
 }
Example #15
0
 public virtual void OnWsMessage(object source, SpeckleEventArgs e)
 {
     Debug.WriteLine("[Gh Sender] Got a volatile message. Extend this class and implement custom protocols at ease.");
 }
Example #16
0
 public virtual void Client_OnError(object source, SpeckleEventArgs e)
 {
     //Debug.Log("Client Error");
     //Debug.Log(JsonConvert.SerializeObject(e.EventData));
 }
        public virtual void OnDataSent(object source, SpeckleEventArgs e)
        {
            Debug.WriteLine("Data was sent. Stop the loading bar :) Wait. What loading bar? The one luis wanted! Where is it? I dunno");

            this.Message = "Data sent.";
        }
Example #18
0
 private static void SpkClient_A_OnWsMessage(object source, SpeckleEventArgs e)
 {
     Console.WriteLine();
     Console.WriteLine($"(Client A) Event name: {e.EventName}; Raw: {e.EventData}.");
 }
 private void Client_OnError(object source, SpeckleEventArgs e)
 {
     Context.NotifySpeckleFrame("client-error", StreamId, JsonConvert.SerializeObject(e.EventData));
 }
 private void Client_OnWsMessage(object source, SpeckleEventArgs e)
 {
     Context.NotifySpeckleFrame("client-log", StreamId, JsonConvert.SerializeObject("WS message received and ignored."));
 }
 private void Client_OnReady(object source, SpeckleEventArgs e)
 {
     Context.NotifySpeckleFrame("client-log", StreamId, JsonConvert.SerializeObject("Ready Event."));
 }
Example #22
0
 /// <summary>
 /// Base implementation of the "OnLogData" event response. It's empty at this level and intended to be
 /// overriden.
 /// </summary>
 /// <param name="source">Source object passed from the event.</param>
 /// <param name="e">Arguments passed from the event.</param>
 protected virtual void ClientOnLogData(object source, SpeckleEventArgs e)
 {
     //Debug.Log ("INTERNAL LOG: " + e.EventData);
 }
Example #23
0
 public virtual void OnHistory(object source, SpeckleEventArgs e)
 {
     Debug.WriteLine("Received history update event: " + e.EventInfo);
 }
 public virtual void CustomMessageHandler(string eventType, SpeckleEventArgs e)
 {
     Debug.WriteLine("Received {0} type message.", eventType);
 }
Example #25
0
 public virtual void Client_OnLogData(object source, SpeckleEventArgs e)
 {
     Context.NotifySpeckleFrame("client-log", StreamId, JsonConvert.SerializeObject(e.EventData, Interop.camelCaseSettings));
 }
Example #26
0
 /// <summary>
 /// Base implementation of the "OnWsMessage" event response. It's empty at this level and intended to be
 /// overriden.
 /// </summary>
 /// <param name="source">Source object passed from the event.</param>
 /// <param name="e">Arguments passed from the event.</param>
 protected virtual void ClientOnWsMessage(object source, SpeckleEventArgs e)
 {
 }
Example #27
0
 public virtual void Client_OnReady(object source, SpeckleEventArgs e)
 {
     Debug.Log("Client ready");
     //Debug.Log(JsonConvert.SerializeObject(e.EventData));
 }
Example #28
0
 private static void SpkClient_B_OnWsMessage(object source, SpeckleEventArgs e)
 {
     // Note, the dynamic object with the "parsed" event data is in e.EventObject.
     Console.WriteLine();
     Console.WriteLine($"(Client B) Event name: {e.EventName}; Raw: {e.EventData}.");
 }
Example #29
0
 public virtual void OnBroadcast(object source, SpeckleEventArgs e)
 {
     Debug.WriteLine("[Gh Receiver] Got a volatile broadcast. Extend this class and implement custom protocols at ease.");
 }
Example #30
0
 /// <summary>
 /// Base implementation of the "OnReady" event response. It's empty at this level and intended to be
 /// overriden.
 /// </summary>
 /// <param name="source">Source object passed from the event.</param>
 /// <param name="e">Arguments passed from the event.</param>
 protected virtual void ClientOnReady(object source, SpeckleEventArgs e)
 {
     //Debug.Log ("INTERNAL READY EVENT: " + e.EventData);
 }