Events



OnAuthentication(AUserName, APassword as String; ByRef AIsOK as Variant)

You must implement this event for checking username and password when a new client connects to the server. If this event not implemented - all client connections dropped. Function must assign True to the AIsOK if successful else assign False.

Note: in the demo version value of AIsOK is ignored and any clients can connect always! For security reason please use demo version of Routix.RPC for testing purposes only!

OnRequestObject(AObjectIDString as String; ByRef AResult as Variant)

You must implement this event to control objects which clients requested. If this event not implemented - all objects created via system API by default.

If AResult is Null - Routix.RPC will try to create and return object via system API.

If AResult is Object - this object returned to client.

If AResult is String - error returned to client with this string as a description.

Note: in the demo version return value of this event is ignored and any clients can create any registered in the system objects! For security reason use demo version of Routix.RPC for testing purposes only!

 

VBScript example:

 

'OnAuthentication called when client connects to the server.

'You must check username and password in this event.

'If returned value is True - login for this client is allowed.

'If return value is False - login denied, on client-side

'autentication error raised and connection will be closed.

'NOTE: in the demo version result of this event function is

'ignored and client authenticated in any case! Be careful!

 

Function RPCServer_OnAuthentication(AUserName, APassword, ByRef AIsOK)

 

    WScript.Echo "RPCServer_OnAuthentication: " & AUserName & ", " & APassword

 

    If (AUserName = "RoutixUser") And (APassword = "Secret") Then

        AIsOK = True

    Else

        AIsOK = False

    End If

 

End Function

 

 

 

'OnRequestObject called when connected and authenticated

'client requests some object with ProgID specified by

'AProgID parameter. If this event function returns NULL

'then RPC server will try to create registered in the system

'object via CoCreateInstance Windows system function.

'To deny object creation with the specified AppID you

'must return some error string. On client side exception

'will be raised with this error string.

'NOTE: in the demo version result of this event function

'is ignored. Also ignored returned error string. In other 

'words client can create any registered in the system 

'object and you can not return your own object to client.

 

Function RPCServer_OnRequestObject(AProgID, ByRef AResult)

    

    WScript.Echo "RPCServer_OnRequestObject: " & AProgID

    If (AProgID = "WScript.Shell") Then

      'If return NULL - RPC server will try to create this object

      'via CoCreateInstance windows API

        AResult = NULL

    ElseIf (AProgID = "FSysObj") Then

        'or you can return your custom object

        Set AResult = WScript.CreateObject("Scripting.FileSystemObject")

    Else

        AResult = "You can not create object " & AProgID

    End If

 

End Function