public void TestJsonLinkRequestWriteRead2() { // Arrange ProxySocketAddress address = new ProxySocketAddress(); address.Port = 443; address.Host = "myhosttolinkto"; SocketInfo props = new SocketInfo(); props.Address = address; props.Family = AddressFamily.InterNetwork; props.Protocol = ProtocolType.Udp; props.Type = SocketType.Stream; props.Flags = (UInt32)SocketFlags.Passive; for (Int32 i = 0; i < 10; i++) { var ov = new SocketOptionValue(); ov.Option = (SocketOption)(13 - i); ov.Value = (UInt64)i; props.Options.Add(ov); } Message request = new Message(null, null, null, new LinkRequest(props)); MemoryStream stream = new MemoryStream(); // Act request.Encode(stream, CodecId.Json); byte[] buf = Interop.MessageDecodeEncode(CodecId.Json, 1, stream.GetBuffer(), stream.Length, buffer, buffer.Length); Message returned = Message.Decode(new MemoryStream(buf), CodecId.Json); // Assert Assert.IsTrue(request.Equals(returned)); }
public void TestJsonGetOptResponseWriteRead() { // Arrange SocketOptionValue optionValue = new SocketOptionValue(); optionValue.Option = SocketOption.Broadcast; optionValue.Value = 1; Message response = new Message(null, null, null, new GetOptResponse(optionValue)); MemoryStream stream = new MemoryStream(); // Act response.Encode(stream, CodecId.Json); byte[] buf = Interop.MessageDecodeEncode(CodecId.Json, 1, stream.GetBuffer(), stream.Length, buffer, buffer.Length); Message returned = Message.Decode(new MemoryStream(buf), CodecId.Json); // Assert Assert.IsTrue(response.Equals(returned)); }
/// <summary> /// Convinience constructor /// </summary> public GetOptResponse(SocketOptionValue optionValue) { OptionValue = optionValue; }
/// <summary> /// Convinience constructor /// </summary> public SetOptRequest(SocketOptionValue optionValue) { OptionValue = optionValue; }