openAsynch
openAsynch(receiver: Object; msg: String);
The openAsynch method of the Connection class establishes a connection to a remote application and returns immediately. When the connection is established, the object specified in the receiver parameter is sent the name of the callback method specified in the msg parameter.
The openAsynch method can be called only when the state property is Disconnected (0). When this method is called, the value of the state property is changed to Connecting (1).
On asynchronous calls, the state may not change immediately, and it may remain Disconnected (0) for a short period until JADE has rescheduled the request.
The following example shows the use of the openAsynch method.
buttonOpenAsynch_click(btn: Button input) updating; vars conlog : ConnectionLog; begin // Sets the conlog variable to reference a ConnectionLog object. // If none exists, it is created and its properties initialized. beginTransaction; conlog := ConnectionLog.firstInstance; if conlog = null then create conlog; conlog.numberOfListenCalls := 0; conlog.numberOfOpenCalls := 0; conlog.numberOfCloseCalls := 0; conlog.numberOfBinaryReads := 0; conlog.numberOfBinaryWrites := 0; endif; commitTransaction; // Attempts to connect to the current port and returns immediately. // If a connection is made, the ConnectionLog object referenced by // conlog is called and told to run the updateOpenCalls method. self.connection.openAsynch(conlog, "updateOpenCalls"); end;
When the openAsynch method establishes a connection, the user-written callback method specified in the msg parameter is called.
The callback method must match the signature required by the calling openAsynch method, as follows.
openCallback(connection: Connection);
The following method is an example of a ConnectionLog class callback method for the openAsynch method, which updates the number of method invocations recorded for this method.
updateOpenCalls(connection: Connection) updating; begin beginTransaction; self.numberOfOpenCalls := self.numberOfOpenCalls + 1; commitTransaction; self.connection.readBinaryAsynch(1024, connection, "readCallback"); end;