/// <summary> /// Will serialize messages /// </summary> /// <param name="message"></param> public virtual void Write(object message) { var formatter = _formatterFactory.CreateSerializer(); var buffer = new BufferSlice(65535); var writer = new SliceStream(buffer); formatter.Serialize(message, writer); writer.Position = 0; Send(buffer, (int)writer.Length); }
/// <summary> /// Send a message /// </summary> /// <param name="message">Message to send</param> /// <remarks>Message will be serialized using the <see cref="IMessageFormatterFactory"/> that you've specified in the constructor.</remarks> public void Send(object message) { if (message == null) { throw new ArgumentNullException("message"); } var serializer = _formatterFactory.CreateSerializer(); var buffer = new BufferSlice(65535); var writer = new BufferWriter(buffer); serializer.Serialize(message, writer); Send(buffer, writer.Count); }