VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "c_ServerCoordinatorImplTie"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'Generated by IDL2VB v120. Copyright (c) 1999 Martin.Both
'Source File Name: ../demos/callback/server.idl
'Target File Name: c_ServerCoordinatorImplTie.cls

Option Explicit

'You can use this class as a tie to your servant or as a servant example.
'Using as a tie:
' Your servant has to implement c_ServerCoordinator
' To activate a servant via tie write following:
'  Dim oServerCoordinatorImplTie As c_ServerCoordinatorImplTie
'  Set oServerCoordinatorImplTie = New c_ServerCoordinatorImplTie
'  Call oServerCoordinatorImplTie.setDelegate(oServant)
'  Call oOrb.Connect(oServerCoordinatorImplTie)
'Using as a servant example:
' Rename class to c_ServerCoordinatorImpl and save the file as c_ServerCoordinatorImpl.cls.
' Remove delegate stuff and write your own servant operations.
' To activate a servant write following:
'  Dim oServerCoordinatorImpl As c_ServerCoordinatorImpl
'  Set oServerCoordinatorImpl = New c_ServerCoordinatorImpl
'  Call oOrb.Connect(oServerCoordinatorImpl)

Implements cOrbSkeleton
Implements c_ServerCoordinator

'interface ::Server::Coordinator
Const sTypeId As String = "IDL:Server/Coordinator:1.0"
Private oObjRef As cOrbObjRef
Private oDelegate As c_ServerCoordinator

'Each tie contains a delegate object, to which all operations are forwarded.
'You can remove this if you use this class as an example for your servant.
Public Sub setDelegate(ByVal Delegate As c_ServerCoordinator)
    Set oDelegate = Delegate
End Sub

Public Function getDelegate() As c_ServerCoordinator
    Set getDelegate = oDelegate
End Function

Friend Property Get ObjRef() As cOrbObjRef
    Set ObjRef = oObjRef
End Property

Friend Property Get This() As c_ServerCoordinator
    Dim oObj As cOrbObject
    Set oObj = New c_ServerCoordinator
    If oObj.setObjRef(oObjRef, False) Then
        Set This = Nothing
    Else
        Set This = oObj
    End If
End Property

Private Property Get cOrbSkeleton_TypeId(ByVal Item As Integer) As String
    Select Case Item
    Case 0: cOrbSkeleton_TypeId = sTypeId
    Case 1: cOrbSkeleton_TypeId = "IDL:omg.org/CORBA/Object:1.0"
    End Select
End Property

Private Property Get cOrbSkeleton_ObjRef() As cOrbObjRef
    Set cOrbSkeleton_ObjRef = oObjRef
End Property

Private Property Set cOrbSkeleton_ObjRef(ByVal newObjRef As cOrbObjRef)
    Set oObjRef = newObjRef
End Property

'Helper
Private Function cOrbSkeleton_execute(ByVal sOperation As String, _
    ByVal oIn As cOrbStream, ByVal oOut As cOrbStream) As Long
    On Error GoTo ErrHandler
    Dim oImpl_ As c_ServerCoordinator
    Set oImpl_ = IIf(oDelegate Is Nothing, Me, oDelegate)
    Select Case sOperation
    Case "register"
        Dim a1_clientObjRef As c_ClientControl
        Set a1_clientObjRef = m_ClientControl.narrow(oIn.readObject())
        Dim register As c_ServerCounter
        Set register = oImpl_.register(a1_clientObjRef)
        Call oOut.writeObject(register)
    Case "unregister"
        Dim a2_clientObjRef As c_ClientControl
        Set a2_clientObjRef = m_ClientControl.narrow(oIn.readObject())
        Call oImpl_.unregister(a2_clientObjRef)
    Case Else
        Call VBOrb.raiseBADOPERATION(1, VBOrb.CompletedNO, sOperation)
    End Select
    cOrbSkeleton_execute = 0 'NO_EXCEPTION
    Exit Function
ErrHandler:
    Call VBOrb.ErrReraise(Err, "Coordinator.execute(" & sOperation & ")")
End Function

'Implements c_ServerCoordinator

'register()
Private Function c_ServerCoordinator_register( _
    ByVal clientObjRef As c_ClientControl) As c_ServerCounter
    On Error GoTo ErrHandler
    'Please write your own code here if using as servant example
    If oDelegate Is Nothing Then
        Call VBOrb.raiseNOIMPLEMENT(0, VBOrb.CompletedNO)
    Else
        Set c_ServerCoordinator_register = oDelegate.register(clientObjRef)
    End If
    Exit Function
ErrHandler:
    Set c_ServerCoordinator_register = Nothing
    Call VBOrb.ErrReraise(Err, "register")
End Function

'unregister()
Private Sub c_ServerCoordinator_unregister(ByVal clientObjRef As c_ClientControl)
    On Error GoTo ErrHandler
    'Please write your own code here if using as servant example
    If oDelegate Is Nothing Then
        Call VBOrb.raiseNOIMPLEMENT(0, VBOrb.CompletedNO)
    Else
        Call oDelegate.unregister(clientObjRef)
    End If
    Exit Sub
ErrHandler:
    Call VBOrb.ErrReraise(Err, "unregister")
End Sub
