Converts a client Leadtools.Jpip.RequestFields and parameters into an System.Net.HttpWebRequest object.
public class HttpRequestEncoderPublic Class HttpRequestEncoderpublic ref class HttpRequestEncoderUse this class to create an System.Net.HttpWebRequest which holds the JPIP parameters to be sent to the server.
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.JpipImports Leadtools.Jpip.CachingImports Leadtools.Jpip.HttpServerImports Leadtools.Jpip.RequestDecoderImports Leadtools.Jpip.RequestEncoderImports Leadtools.Jpip.Client.WinFormsImports Leadtools.Jpip.Client.InteractiveDecoderImports Leadtools.Jpip.ServerImports Leadtools.Jpip.LoggingPublic Class HttpClientCommunicationPublic Sub SendClientRequest()Dim fields As RequestFields = New RequestFields()Dim cacheModleItem As ModelItemDim binDescriptor As ExplicitBinDescriptorDim cacheModleElement As ModelElementfields.RequestTargetFields = New TargetFields("0", "image1.jp2", Nothing)fields.RequestChannelFields.NewChannel = New String() {"http"}fields.RequestDataLimitFields.DataLength = 16384cacheModleItem = New ModelItem()binDescriptor = New ExplicitBinDescriptor(ExplicitBin.MetaBin, 0, Nothing) 'indicate that metadata bin 0 is locally cached and need not be sent.cacheModleElement = New ModelElement(False, binDescriptor)cacheModleItem.BinDescriptors.Add(cacheModleElement)cacheModleItem.CodeStreamRange.Add(New Range(0, 0))fields.RequestCacheManagementFields.ModelItems.Add(cacheModleItem)Dim imageType As ImageReturnType = New ImageReturnType(ImageTypes.JppStream, False)fields.RequestServerControlFields.ImageReturnTypes = New ImageReturnType() {imageType}fields.RequestViewWindowFields.FrameSize = New LeadSize(500, 300)fields.RequestViewWindowFields.RegionOffset = New LeadPoint(0, 100)fields.RequestViewWindowFields.FrameSizeRoundingDirection = RoundingDirection.ClosestDim codeStreamRange As SampleRange = New SampleRange()codeStreamRange.Range = New Range(0, 0)fields.RequestViewWindowFields.CodeStream.Add(codeStreamRange)Dim encoder As HttpRequestEncoder = New HttpRequestEncoder(IPAddress.Parse("127.0.0.1"), 49201)Dim request As HttpWebRequest = encoder.Encode(fields, "jpip", Nothing)Console.WriteLine(request.Address.ToString())Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)Console.WriteLine("Server response received.")Console.WriteLine(response.Headers.ToString())End SubPrivate Function GetClientSocket() As SocketDim listenSocket As Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)Dim hostIP As IPAddress = IPAddress.Parse("127.0.0.1")Dim port As Integer = 107Dim ep As IPEndPoint = New IPEndPoint(hostIP, port)listenSocket.Bind(ep)' start listeninglistenSocket.Listen(10)'a client should send a request to the listening addressDim client As Socket = listenSocket.Accept()listenSocket.Close()Return clientEnd FunctionEnd Class
using Leadtools;using Leadtools.Codecs;using Leadtools.Jpip;using Leadtools.Jpip.Caching ;using Leadtools.Jpip.HttpServer;using Leadtools.Jpip.RequestDecoder;using Leadtools.Jpip.RequestEncoder;using Leadtools.Jpip.Client.WinForms;using Leadtools.Jpip.Client.InteractiveDecoder;using Leadtools.Jpip.Server;using Leadtools.Jpip.Logging;public void SendClientRequest(){#if LEADTOOLS_V175_OR_LATERLeadtools.Examples.Support.SetLicense();#elseLeadtools.Examples.Support.Unlock();#endif // #if LEADTOOLS_V175_OR_LATERRequestFields fields = new RequestFields();ModelItem cacheModleItem;ExplicitBinDescriptor binDescriptor;ModelElement cacheModleElement;fields.RequestTargetFields = new TargetFields("0", "image1.jp2", null);fields.RequestChannelFields.NewChannel = new string[] { "http" };fields.RequestDataLimitFields.DataLength = 16384;cacheModleItem = new ModelItem();binDescriptor = new ExplicitBinDescriptor(ExplicitBin.MetaBin, 0, null); //indicate that metadata bin 0 is locally cached and need not be sent.cacheModleElement = new ModelElement(false, binDescriptor);cacheModleItem.BinDescriptors.Add(cacheModleElement);cacheModleItem.CodeStreamRange.Add(new Range(0, 0));fields.RequestCacheManagementFields.ModelItems.Add(cacheModleItem);ImageReturnType imageType = new ImageReturnType(ImageTypes.JppStream, false);fields.RequestServerControlFields.ImageReturnTypes = new ImageReturnType[] { imageType };fields.RequestViewWindowFields.FrameSize = new LeadSize(500, 300);fields.RequestViewWindowFields.RegionOffset = new LeadPoint(0, 100);fields.RequestViewWindowFields.FrameSizeRoundingDirection = RoundingDirection.Closest;SampleRange codeStreamRange = new SampleRange();codeStreamRange.Range = new Range(0, 0);fields.RequestViewWindowFields.CodeStream.Add(codeStreamRange);HttpRequestEncoder encoder = new HttpRequestEncoder(IPAddress.Parse("127.0.0.1"), 108);HttpWebRequest request = encoder.Encode(fields, "jpip", null);Console.WriteLine(request.Address.ToString());HttpWebResponse response = (HttpWebResponse) request.GetResponse();Console.WriteLine("Server response received.");Console.WriteLine(response.Headers.ToString());}public Socket GetClientSocket(){Socket listenSocket = new Socket( AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);IPAddress hostIP = IPAddress.Parse("127.0.0.1");int port = 107;IPEndPoint ep = new IPEndPoint(hostIP, port);listenSocket.Bind(ep);// start listeninglistenSocket.Listen(10);//a client should send a request to the listening addressSocket client = listenSocket.Accept();listenSocket.Close();return client;}
|
Products |
Support |
Feedback: HttpRequestEncoder Class - Leadtools.Jpip |
Introduction |
Help Version 19.0.2017.3.22
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.