Hello World,

I'm trying to use the following code to build a client-server app (cleaned up the code a bit/lot). Works fine till now, But.....
I want to make the client connect to multiple servers.
So best thing to do (I Think) is make one collection of the client-objects, where the different servers will call back upon.
Can anyone help me with this code, coz I don't seem to get it right?
If you want the full example I used please let me know & i'll mail it to you.

GREETINX,

Don

CLIENT-vbp :

form :
Code:
Dim objCbSvr As Object
Dim objMyClassInstance As Object


Private Sub cmdconnect_Click
  
  Set objMyClassInstance = New CbClientProj.CbClientClass
  Set objCbSvr = CreateObject("CbServerProj.CbServerClass")
  
  if objCbSvr.AddObjectReference(objMyClassInstance) Then
	objCbSvr.MyServerMethode(test)
  end if

end sub


Private Sub cmddisconnect_Click
 
If objCbSvr.DropObjectReference(objMyClassInstance) Then
         
        Set objMyClassInstance = Nothing
        Set objCbSvr = Nothing
end if

end sub
class:
Code:
Private Sub Class_Terminate()
  Debug.Print "CbClientProj.CbClientClass Terminated."
End Sub

Private Sub Class_Initialize()
  Debug.Print "CbClientProj.CbClientClass Initialized."
End Sub

Public Sub MyclientSub(test As String)
  'This is the *public* method the server calls (-back onto)
  'more code     
End Sub



SERVER-vbp :

module:
Code:
Global gObjRef As Object
class:
Code:
Private Sub Class_Terminate()
'  Debug.Print "CbServerProj.CbServerClass has terminated"
End Sub
Private Sub Class_Initialize()
'  Debug.Print "CbServerProj.CbServerClass has intialized"
End Sub

Public Function AddObjectReference(Caller As Object) As Boolean
  
  Set gObjRef = Caller
  
  AddObjectReference = True
  
End Function

Public Function DropObjectReference(Caller As Object) As Boolean

If gObjRef Is Caller Then
        DropObjectReference = True
  Else
'    Debug.Print "Caller not the same as ObjRef.  Unable to quit."
    DropObjectReference = False
  End If
End Function

Public sub MyServermethode(test) 
    
    'more code on server which later on triggers following code
    gObjRef.MyclientSub (serverdata)	  
	
End Sub