MobiLink Synchronization User's Guide
Server-Initiated Synchronization
Set up the Listener
Configures and starts the Listener on Windows devices, including Windows CE.
dblsn [ options ] -l message-handler [ -l message-handler... ]
message-handler : [ filter;...];action
filter :
[ message = string | message_start = string ]
[ sender = string ]
action :
action = command[;altaction = command ]
[ ;continue = { yes | no } ]
[ ;maydial = { yes | no } ]
command :
{ start program [ program-arguments ]
| run program [ program-arguments ]
| post window-message to window-class
| tcpip-socket-action
| DBLSN FULL SHUTDOWN }
tcpip-socket-action :
socket port=app-port
[ ;host=app-host ]
[ ;sendText=text1 ]
[ ;recvText= text2 [ ;timeout=num-sec ] ]
Options The following options can be used to configure the Listener. If you are creating a configuration file for a Palm device, you must use -n. The rest are optional.
dblsn options | Description |
---|---|
-a option |
Specifies Listener dll options. To specify multiple options, repeat -a. For example, -a port=2439 -a ShowSenderPort. To see options for your dll, type:
dblsn -d filename.dll -a ? The default dll is lsn_udp.dll. |
-d filename | Specifies the Listener dll that you want to use. On Windows you can specify lsn_swi510.dll. The default is lsn_udp.dll. |
-i seconds | Sets the polling interval in seconds. This is the frequency at which the Listener listens for messages. The default is 30 seconds. |
-m | Turns on message logging. The default is off. |
-n [ filename ] | Creates a Palm Listener configuration file. If you use -n, dblsn generates the file and then shuts down. When you use -n, options such as -a, -d, -i, -m, and -p are ignored. If you use -n but omit the filename, the Palm configuration file is called lsncfg.pdb. |
-o filename | Logs output messages to a file. |
-os bytes | Specifies a maximum size for the log file in bytes. The minimum size is 10 000. By default, there is no limit. |
-ot filename | Logs output messages to file, but first truncates the file. |
-p | Allows automatic idle power-off. This option has an effect only on CE devices. Use it to allow the device to shut down when idle. By default, the Listener prevents the device from shutting itself down. |
-q | Runs in a minimized window. |
-r bytes | Specifies the minimum number of bytes per record in the Palm Listener configuration file. The default is 1 000. |
-v [ level ] |
Sets the verbosity level for the dblsn log and console. The level can be 0, 1, 2, or 3:
|
-l message-handler -l allows you to specify a message handler, which is a filter-action pair. The filter determines which message should be handled, and the action is invoked when the filter matches a message. You can specify multiple instances of -l. Each instance of -l specifies a different message handler.
Filters You specify a filter to compare to an incoming message. If the filter matches, the action you specify is invoked.
There are three types of filter you can specify:
message compares the entire message to text you specify. To match, this filter must also be the exact same length as the message.
The Listener translates non-printable characters to a tilde (~), so if there are non-printable characters, the pattern to match must also use tildes.
The format of messages is carrier-dependent. For example, you may want to match a message from a sender named Bob@mail.com with the subject Help and the message Me. In UDP, this would appear as [Help]Me
. On Bell Mobility's e-mail to SMS conversion service, it would be Bob@mail.com[Help]Me
. On Fido's e-mail to SMS conversion service, it would be sent as Bob@mail.com\n(Help)\nMe
, but would be translated by the Listener to Bob@mail.com~(Help)~Me
. You must test with your carrier to determine the appropriate format, using the dblsn options -v and -m.
message_start compares a portion of the message (from the beginning) to text that you specify. When you specify message_start, the Listener creates the action variables $message_start and $message_end. For more information, see Action variables, below.
The Listener translates non-printable characters to a tilde (~) so if there are non-printable characters, the pattern match must also use tildes.
sender is the sender of the message. You can only specify one sender. For UDP gateways, the sender is the IP address of the host of the gateway. For SMTP gateways, the sender is optionally specified with the sender SMTP property.
The filter is optional. If you do not specify a filter, the action is performed when any message is received.
Action and altaction Each filter is associated with an action and, optionally, an alternative action called the altaction. If a message meets the conditions of the filter, the action is invoked. You must specify an action. If you specify an altaction, the altaction is invoked only if the action fails. Palm devices do not recognize altaction.
The action and altaction are specified as { action | altaction }= command. For each action and altaction, there can be one command, and it can be one of start, run, post, socket, or DBLSN FULL SHUTDOWN.
start spawns a process. When you start a program, the Listener continues listening for more messages.
The following example starts dbmlsync with some command line options, parts of which are obtained from the message.
"action=start dbmlsync.exe @dbmlsync.txt -n $message_end -wc dbmlsync_$message_end -e sch=INFINITE"
run runs the program and waits for it to finish. The Listener resumes listening after the process is complete. You cannot use run on Palm devices.
The following example runs dbmlsync with some command line options, parts of which are obtained from the message.
"action=run dbmlsync.exe @dbmlsync.txt -n $message_end"
post posts a message to a window class. This is required by dbmlsync when scheduling is on. Use the dbmlsync -wc option to specify the window class name. Post is also used when signaling applications that use Windows messages. You cannot use post on Palm devices.
The following example posts a Windows message registered as dbas_synchronize to a dbmlsync instance registered with the class name dbmlsync_FullSync.
action=post dbas_synchronize to dmblsync_FullSync
socket notifies an application by making a TCP/IP connection. This is especially useful for Java and eMbedded Visual Basic applications, because Java and eVB don't support custom window messaging, and eVB doesn't support command line parameters. You can connect to a local socket by specifying just a port, or you can connect to a remote socket by specifying the host along with the port. Using sendText, you can send a string. You can optionally verify that the response is as expected with recvText. When you use recvText, you can also specify a timeout to avoid hanging if the case of application or network problems.
The following example forwards the string in $sender=$message to a local application that is listening on port 12345, and expects the application to send back "beeperAck" as an acknowledgement.
-l "action='socket port=12345; sendText=$sender=$message; recvText=beeperAck; timeout=5'"
DBLSN FULL SHUTDOWN After shutdown, the Listener stops handling inbound messages. The remote user must restart the Listener in order to continue with server-initiated synchronization. This feature is mostly useful during development.
For example, action='DBLSN FULL SHUTDOWN'
You can also specify the following action options:
continue {yes|no} specifies whether the Listener should continue after finding the first match. This is useful when you specify multiple -l clauses to cause one message to initiate multiple actions. This option is not recognized by Palm devices. The default is no.
maydial {yes|no} specifies whether the action can dial the modem. This provides information to the Listener to decide whether to release the modem or not before the action. This option is useful when the action or altaction need exclusive access to the modem used by the Listener. This option is not recognized by Palm devices. The default is yes.
The escape character for action and altaction is a dollar sign ($), so to specify a single dollar sign as plain text, type $$.
The Listener determines that an action has failed (and then invokes the altaction) in the following ways:
When you run a program, the Listener determines that the program has failed if the program doesn't exist or if it returns a non-zero return code.
When you start a program, the Listener doesn't wait for a return code, so it can only tell that the action has failed if the program does not exist.
When you post to a window class, the Listener determines that the action has failed if no window class has been registered with the given name or the operating system has reported that the post failed.
When you perform a socket action, the Listener determines that the action has failed if it failed to connect, send, or receive expected acknowledgement before timeout.
You can only specify one action and one altaction in each instance of -l. You can also write a cover program or batch file that contains multiple actions, and run it as the action.
Following is an example of the specification of altaction. In this example, the $message_end that matches the filter is the stream parameter for connecting to MobiLink. The primary action is to post the dbas_synchronize Windows message to the dbmlsync_FullSync window. The example uses altaction to start (not run) dbmlsync with the window class name dbmlsync_FullSync if the primary action fails. This is the standard way to make the Listener work with dbmlsync scheduling.
-l "message_start=[sync]; action='post dbas_synchronize to dbmlsync_FullSync'; altaction='start dbmlsync.exe @dbmlsync.txt -wc dbmlsync_FullSync -e adr=$message_end;sch=INFINITE'"
The following Listener action variables can be used anywhere in the action or altaction.
An action variable is replaced just before the action or altaction is performed.
Listener action variables start with a dollar sign ($). The escape character is also a dollar sign, so to specify a dollar sign as plain text, type $$. For example, type $$message_start when you don't want $message_start to be substituted.
Action variable | Description |
---|---|
$sender | The sender of the message. |
$message_start | A portion of the text of the message from the beginning, as specified in -l message_start. This variable is only available if you have specified -l message_start. |
$message | The content of the message. |
$message_end | The part of the message that is left over after the part specified in -l message_start is removed. This variable is only available if you have specified -l message_start. |
$year | The meaning of this variable is carrier library dependent. Not available on Palm. |
$month | The meaning of this variable is carrier library dependent. Values can be from 1-12. Not available on Palm. |
$day | The meaning of this variable is carrier library dependent. Values can be from 1-31. Not available on Palm. |
$hour | The meaning of this variable is carrier library dependent. Values can be from 0-23. Not available on Palm. |
$minute | The meaning of this variable is carrier library dependent. Values can be from 0-59. Not available on Palm. |
$second | The meaning of this variable is carrier library dependent. Values can be from 0-59. Not available on Palm. |
$type | The meaning of this variable is carrier library dependent. Not available on Palm. |
$priority | The meaning of this variable is carrier library dependent. Not available on Palm. |
$time | Palm only. This is the current time in seconds since 12:00 AM, January 1, 1904. |
Default parameters file dblsn.txt