So what do you do if you want to broadcast messages, but you don't have a form to place the SRP DirectConnect Control on? The answer is COM. When you register the SRPControls.ocx, a special COM object is made available to you, which you can use to send message to the SRP Synchronization Server directly.

The ProgID of this COM object is "SRP.DirectConnectSync". Before you call one of the methods listed here, you first must create an instance of the COM object itself:

ServerSendObj = OleCreateInstance("SRP.DirectConnectSync")


Once you've successfully created the object, then you can use the OleCallMethod routine to call the methods. For example, this is how you would call the Validate method:

OleCallMethod(ServerSendObj, "Validate""127.0.0.1""25000")


Here are the methods you can call:

Broadcast

OleCallMethod(Obj, "Broadcast", Server, Port, Message)

The Broadcast method sends a message to all connected DirectConnect controls. It does this by connecting to the server, sending the message, and disconnecting.

The Server, and Port parameters provide the information needed to find the SRP Synchronization Server. The Server is the IP or URL address describing the server's location on the network. The Port is the port upon which the SRP Synchronization Server is listening.

NOTE: Avoid calling the Validate method frequently since doing so takes several seconds per call (if the server is not running). It's always best to check if the server is running early in the application and cache the results.

// Broadcast a message
ServerSendObj = OleCreateInstance("SRP.DirectConnectSync")
If OleStatus() else
OleCallMethod(ServerSendObj, "Broadcast""127.0.0.1""25000", "Hello, World!")
end

Validate

Result = OleCallMethod(Obj, "Validate", Server, Port)

The Validate method verifies that the SRP Synchronization Server is running. It does this by connecting to the server, sending a validation request, verifying a response, and disconnecting. If any of these steps fail, then the the result is 0. If all steps succeed, then the result is 1.

The Server, and Port parameters provide the information needed to find the SRP Synchronization Server. The Server is the IP or URL address describing the server's location on the network. The Port is the port upon which the SRP Synchronization Server is listening.

NOTE: Avoid calling the Validate method frequently since doing so takes several seconds per call (if the server is not running). It's always best to check if the server is running early in the application and cache the results.

// Validate the server
ServerSendObj = OleCreateInstance("SRP.DirectConnectSync")
If OleStatus() else
OleCallMethod(ServerSendObj, "Validate""127.0.0.1""25000")
end

Quit

OleCallMethod(Obj, "Quit", Server, Port)

The Quit method closes the SRP Synchronization Server. Everything connected to the server is disconnected before it is shutdown. Therefore, calling this method ends all synchronization.

The Server, and Port parameters provide the information needed to find the SRP Synchronization Server. The Server is the IP or URL address describing the server's location on the network. The Port is the port upon which the SRP Synchronization Server is listening.

// Shutdown the server
ServerSendObj = OleCreateInstance("SRP.DirectConnectSync")
If OleStatus() else
   OleCallMethod(ServerSendObj, "Quit""127.0.0.1""25000")
end

  • No labels