/// <summary> /// Initializes the channel with the given socket, using /// the given encoding for messages. /// </summary> public ScpNativeFeedChannel(IReactiveSocket socket) { this._socket = socket; Receiver = from packet in socket.Receiver.Buffer(ScpHidReport.Length) select packet.ToArray(); }
/// <summary> /// Initializes the channel with the given socket, using /// the given encoding for messages. /// </summary> public StringChannel(IReactiveSocket socket, Encoding encoding) { this.socket = socket; this.encoding = encoding; Receiver = from header in socket.Receiver.Buffer(sizeof(int)) let length = BitConverter.ToInt32(header.ToArray(), 0) let body = socket.Receiver.Take(length) select Encoding.UTF8.GetString(body.ToEnumerable().ToArray()); }
/// <summary> /// Initializes the channel with the given socket, using /// the given encoding for messages. /// </summary> public ScpNativeFeedChannel(IReactiveSocket socket) { //Receiver = from packet in socket.Receiver.Buffer(ScpHidReport.Length) // select packet.ToArray(); this._socket = socket; Receiver = from header in socket.Receiver.Buffer(4) let length = BitConverter.ToInt32(header.ToArray(), 0) let body = socket.Receiver.Take(length) select body.ToEnumerable().ToArray(); }
/// <summary> /// Initializes a new protocol channel. /// </summary> /// <param name="socket">The <see cref="IReactiveSocket" /> to subscribe to.</param> /// <param name="isCompressed"> /// True to compress the serialized data, false otherwise. /// The default value is false. /// </param> /// <param name="isEncrypted"> /// True to encrypt the serialized data with a static key. /// The default value is false. /// </param> /// <param name="encKey">The static key being used to encrypt/decrypt.</param> public ProtobufChannel(IReactiveSocket socket, bool isCompressed = false, bool isEncrypted = false, string encKey = "") { _socket = socket; _isCompressed = isCompressed; _isEncrypted = isEncrypted; _encKey = encKey; Receiver = from header in socket.Receiver.Buffer(sizeof(int)) let retval = BitConverter.ToInt32(header.ToArray(), 0) let length = (retval >= 0) ? retval : 0 let body = socket.Receiver.Take(length) select Deserialize(body.ToEnumerable().ToArray()); }
/// <summary> /// Initializes the channel with the given socket, using /// the default UTF8 encoding for messages. /// </summary> public StringChannel(IReactiveSocket socket) : this(socket, Encoding.UTF8) { }
public ByteChannel(IReactiveSocket socket, int bufferSize) { this.socket = socket; Receiver = from body in socket.Receiver.Buffer(bufferSize) select body.Take(bufferSize).ToArray(); }
/// <summary> /// Initializes a new protocol channel. /// </summary> /// <param name="socket">The <see cref="IReactiveSocket" /> to subscribe to.</param> /// <param name="isCompressed"> /// True to compress the serialized data, false otherwise. /// The default value is false. /// </param> public ProtobufChannel(IReactiveSocket socket, bool isCompressed) : this(socket, isCompressed, false, null) { }