LEADTOOLS JPEG 2000 (Leadtools.Jpip.Server assembly)
LEAD Technologies, Inc

DelegatedServer Class

Example 





Members 
Defines all of the properties needed to delegate a client's requests to another JPIP server.
Object Model
DelegatedServer Class
Syntax
public class DelegatedServer 
'Declaration
 
Public Class DelegatedServer 
'Usage
 
Dim instance As DelegatedServer
public sealed class DelegatedServer 
function Leadtools.Jpip.Server.DelegatedServer()
public ref class DelegatedServer 
Remarks

You create an instance of this class with the properties you want and then you add it to the DelegatedServersCollection collection.

If multiple DelegatedServer are added into the DelegatedServersCollection collection the load is distributed based on a round-robin algorithm until each DelegatedServer receives its share.

Example
 
Public Class ServerDelegationExample
         Private _server As JpipServer
         Private Const LOCAL_IP_ADDRESS As String = "127.0.0.1"
         Private Const PORT_107 As Integer = 107
         Private IMAGE_NAME As String = Path.Combine(LEAD_VARS.ImagesDir, "Earth8000_Precint_4_.j2k")
         Private CACHE_DIRECTORY As String = Path.Combine(LEAD_VARS.ImagesDir, "jpeg2000")

         Public Sub New()
            _server = New JpipServer()
         End Sub


         Public Sub SetServerDelegation()
#If LEADTOOLS_V175_OR_LATER Then
            Leadtools.Examples.Support.SetLicense()
#Else
         Leadtools.Examples.Support.Unlock()
#End If ' #If LEADTOOLS_V175_OR_LATER Then
            Dim delegatedServer1 As DelegatedServer
            Dim delegatedServer2 As DelegatedServer


            delegatedServer1 = New DelegatedServer("127.0.0.1", 108, 6)
            delegatedServer2 = New DelegatedServer("127.0.0.1", 105, 3)

            _server.Configuration.DelegateServers.Clear()
            _server.Configuration.DelegateServers.Add(delegatedServer1)
            _server.Configuration.DelegateServers.Add(delegatedServer2)

            Console.WriteLine("Server requests will be delegated to the following {0} servers:", _server.Configuration.DelegateServers.Count.ToString())

            For Each server As DelegatedServer In _server.Configuration.DelegateServers
               Console.WriteLine("Server: {0}:{1}", server.IpAddress, server.Port.ToString())
            Next server

            _server.Start()

            ' client side 
            Dim jpipViewer As JpipRasterImageViewer = New JpipRasterImageViewer()
            SetViewer(jpipViewer)
            AddHandler jpipViewer.FileOpened, AddressOf jpipViewer_FileOpened
            jpipViewer.Open(IMAGE_NAME)
         End Sub
         Private Sub jpipViewer_FileOpened(ByVal sender As Object, ByVal e As EventArgs)
            Dim jpipViewer As JpipRasterImageViewer = DirectCast(sender, JpipRasterImageViewer)
            jpipViewer.ZoomIn()
            jpipViewer.Close()

            _server.Stop()


         End Sub

         Public Sub SetViewer(ByVal viewer As JpipRasterImageViewer)
            viewer.CacheDirectoryName = CACHE_DIRECTORY
            viewer.PortNumber = PORT_107
            viewer.IPAddress = LOCAL_IP_ADDRESS
            viewer.PacketSize = 16384
            viewer.ChannelType = JpipChannelTypes.HttpChannel
         End Sub

      End Class

   Public NotInheritable Class LEAD_VARS
      Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
   End Class
private JpipServer _server;               
         private const string LOCAL_IP_ADDRESS = "127.0.0.1";
         private const int PORT_107 = 107;
         private string IMAGE_NAME = Path.Combine(LEAD_VARS.ImagesDir, "Earth8000_Precint_4_.j2k");
         private string CACHE_DIRECTORY = Path.Combine(LEAD_VARS.ImagesDir, "jpeg2000");
         public ServerDelegationExample ( )
         {
            _server = new JpipServer ( ) ;
         }


         public void SetServerDelegation ( ) 
         {
#if LEADTOOLS_V175_OR_LATER
            Leadtools.Examples.Support.SetLicense();
#else
            Leadtools.Examples.Support.Unlock();
#endif // #if LEADTOOLS_V175_OR_LATER
            DelegatedServer delegatedServer1;
            DelegatedServer delegatedServer2 ;
            delegatedServer1 = new DelegatedServer ( "127.0.0.1", 108, 6 ) ;
            delegatedServer2 = new DelegatedServer ( "127.0.0.1", 105, 3 ) ;
            _server.Configuration.DelegateServers.Clear ( ) ;
            _server.Configuration.DelegateServers.Add ( delegatedServer1 ) ;
            _server.Configuration.DelegateServers.Add ( delegatedServer2 ) ;
            Console.WriteLine ( "Server requests will be delegated to the following {0} servers:", 
                                _server.Configuration.DelegateServers.Count.ToString ( ) ) ;

            foreach ( DelegatedServer server in _server.Configuration.DelegateServers )
            {
               Console.WriteLine ( "Server: {0}:{1}", server.IpAddress, server.Port.ToString ( ) ) ;
            }
            _server.Start ( ) ;

            /* client side */
            JpipRasterImageViewer jpipViewer = new JpipRasterImageViewer();
            jpipViewer.FileOpened += new EventHandler(jpipViewer_FileOpened);
            SetViewer(jpipViewer);
            jpipViewer.Open(IMAGE_NAME);
         }

         void jpipViewer_FileOpened(object sender, EventArgs e)
         {
            JpipRasterImageViewer jpipViewer = ( JpipRasterImageViewer ) sender ;
            jpipViewer.ZoomIn();
            jpipViewer.Close();
            _server.Stop ( ) ;

         }

         public void SetViewer(JpipRasterImageViewer viewer)
         {
            viewer.CacheDirectoryName = CACHE_DIRECTORY;
            viewer.PortNumber = PORT_107;
            viewer.IPAddress = LOCAL_IP_ADDRESS;
            viewer.PacketSize = 16384;
            viewer.ChannelType = JpipChannelTypes.HttpChannel;
         }
      }

   static class LEAD_VARS
   {
      public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
   }
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

DelegatedServer Members
Leadtools.Jpip.Server Namespace

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.

Leadtools.Jpip.Server requires a Document or Medical license and unlock key as well as a server license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features