public Message(object obj, string topic, string controller, IXSocketJsonSerializer serializer)
 {
     this._serializer = serializer;
     this.Data        = _serializer.SerializeToString(obj);
     this.Topic       = topic.ToLower();
     this.Controller  = controller.ToLower();
     this.MessageType = MessageType.Text;
 }
Exemple #2
0
        //public Message(object obj, string topic, string controller, IXSocketJsonSerializer serializer)
        //{
        //    this._serializer = serializer;
        //    this.Data = _serializer.SerializeToString(obj);
        //    this.Topic = topic.ToLower();
        //    this.Controller = controller.ToLower();
        //    this.MessageType = MessageType.Text;
        //}

        //public Message(string json, string topic, string controller)
        //{
        //    this.Blob = null;
        //    this.Data = json;
        //    this.Topic = topic.ToLower();
        //    this.Controller = controller.ToLower();
        //    this.MessageType = MessageType.Text;
        //}

        /// <summary>
        /// Ctor for object based message
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="topic"></param>
        /// <param name="controller"></param>
        /// <param name="serializer"></param>
        public Message(object obj, string topic, string controller, IXSocketJsonSerializer serializer)
        {
            _serializer = serializer;
            if (obj is string && !serializer.IsValidJson((string)obj))
            {
                Data = (string)obj;
            }
            else
            {
                Data = serializer.SerializeToString(obj);
            }
            Topic       = topic.ToLower();
            Controller  = controller.ToLower();
            MessageType = MessageType.Text;
        }
Exemple #3
0
 /// <summary>
 /// Send any object, with an eventname... will be transformed into a ITextArgs
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="eventname"></param>
 public void Send(object obj, string eventname)
 {
     Send(new TextArgs {
         @event = eventname.ToLower(), data = _jsonSerializer.SerializeToString(obj)
     });
 }