3.5 Opening a session

Once a connection between an application and the XFS Manager has successfully been negotiated (via WFSStartUp), the application establishes a virtual session with a service provider by issuing a WFSOpen (or WFSAsyncOpen) request. Opens are directed towards “logical services” as defined in the WOSA/XFS configuration. A service handle (hService) is assigned to the session, and is used in all the calls to the service in the lifetime of the session.

Note that applications may optionally choose to explicitly manage the concept of “application identity” when they need to use interdependent compound devices (see Section 3.8.2). This is achieved by using the WFSCreateAppHandle function to get an application handle (hApp), which is unique within the system. This function can be called multiple times to obtain multiple unique handles. An application handle parameter is then used in the WFSOpen function, directing the service provider to bind the specified application handle to the session being initiated. This allows a single application process (potentially multi-threaded) to act as multiple applications to the WOSA/XFS subsystem, to allow effective use of interdependent compound devices. An example of a case in which this could be useful is an application using the Multiple Document Interface (MDI); the application could associate an application handle with each MDI child window. See Section 3.8.2 for additional discussion of the use of application handles with compound devices. Note that neither service nor application handles may be shared among two or more applications.

The actions performed by the XFS Manager on an open are as follows:

The service provider does the following:

Note that even if the service is locked by another application, the open function succeeds, as defined in Section 3.8, “Exclusive Service and Device Access.”

An application programmer has at least two obvious choices as to when to perform the WFSOpen (and the complementary WFSClose) of the services it utilizes:

Each technique has its own advantages. For example, while the first example might provide better performance, the second might be easier to program. In any case, upon a successful completion of an open, the WOSA/XFS subsystem returns a service handle which must be used for all subsequent communication with the service.

Note that an application must perform an open for each logical service that it wishes to utilize, even if the services are of the same type. For example, if an application wishes to utilize two separate receipt printers, it must open two separate logical services.

Furthermore, an application may need to open multiple logical services, even when a set of devices are housed in a single device. For example, consider a compound printer which includes both a receipt and a journal printer. If the application requires access to both the receipt and journal printer functions, it must open both a receipt logical service and a journal logical service.