grass valley developers

Home > APIs > AppServer API > Tutorial > Suspending and Closing AppServers

Suspending and Closing AppServers

AppService is designed so that when a client application exits it can either:

1) shutdown all of the resources it acquired, or
2) leave the resources up-and-running so that it can reacquire the same resources the next time the application runs

One use for this would be an application that keeps a player or recorder running even when the application is not running. This feature is implemented by calling theCloseConnection or SuspendConnection functions on the AppServer object.

Note: it is up to the application to manage the behavior of these resources. If an application exits and leaves a recorder suspended in a recording state, the recorder will continue to use disk space until it either uses up the rest of the drive space or until the application reconnects and tells it to stop.

Note: AppServers will not remain suspended if the AppService is restarted or if the K2 is rebooted.

Reaquiring a Suspended AppServer:
To reacquire a suspended AppServer, call CreateAppServer on the AppServerMgrProxy passing in the same suite string as before.

AppServerMgrProxy method:

public IAppServer CreateAppServer(string suiteName, string app,
out bool isNewConnection);

AppService will then find the matching AppServer object, set its state back to "active", and return it. If the AppServer object returned was previously suspended, the variable "isNewConnection" will return with a FALSE value. If AppService creates a new AppServer object, the variable "isNewConnection" will return with a TRUE value.

Reaquiring a Suspended Controller:
To reaquire a suspended controller, call CreateController on the AppServer object. If the channel was previously suspended, the variable "isNewConnection" will return with a FALSE value. If the AppServer creates a new Controller object, the variable "isNewConnection" will return with a TRUE value.

AppServer method:

public ISimpleController CreateController(string app, object channelId, 
out bool isNewConnection);


Note: remember that channels can be stolen by other applications. So even though you suspended your AppServer, until the time that your application reconnects, other applications may steal the channel away from your suspended AppServer. So check the value of the "isNewConnection" variable to make sure that you are really getting back the controller that you previously had.