RoutixRPCCOM.Server



NOTE: For registered users will be created custom build with different ProgID's and GUID's.

 

Example of using in VBScript:

 

'  DEMO version restrictions:

'    1. Login user name and password are ignored;

'    2. Listen port and host can not be changed. Default value is "0.0.0.0:40404";

'    3. Max simultaneous connections to the server can't be more than 2;

'    4. OnRequestObject is ignored: requested objects will be created via windows API.

 

 

'Define events handlers:

 

'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

 

 

 

'Greate RPC server and connect events

Set RPCServer = WScript.CreateObject("RoutixRPCCOM.Server", "RPCServer_")

 

 

'Start listen

RPCServer.StartListen "0.0.0.0:40404"

 

 

Do While True

  WScript.Sleep 1000

Loop