csWebDotNetLib.Subscription.JSON C# (CSharp) Method

JSON() public method

public JSON ( ) : Newtonsoft.Json.Linq.JObject
return Newtonsoft.Json.Linq.JObject
        public JObject JSON()
        {            
            return JObject.FromObject(new {id = id, target = target, type = type});            
        }

Usage Example

Exemplo n.º 1
0
Arquivo: Api.cs Projeto: TNOCS/csTouch
        private Subscription Subscribe(string target, string type)
        {
            Subscription s;
            if (!this.subscriptions.ContainsKey(target))
            {
                s = new Subscription() {id = Guid.NewGuid().ToString(), target = target, type = type};

                this.socket.Emit("subscribe", s.JSON());
                this.subscriptions[s.id] = s;
                this.socket.On(s.id, (dynamic d) =>
                {
                    switch ((string) d.action)
                    {
                        case "subscribed":
                            Console.WriteLine("subscription : " + s.id);
                            break;
                        case "layer":
                            //var l = new LayerCallback();
                            var l = JsonConvert.DeserializeObject<LayerCallback>(d.data.ToString());
                            s.TriggerLayerCallback(l);
                            
                            break;
                    }

                });
            }
            else
            {
                s = this.subscriptions[target];

            }
            return s;            
        }