Tips_tutorials   >   Studiojs202   >   Introduction

Introduction

Welcome to the Studio JS 202 tutorial.

At the time of writing this tutorial I had not been monitoring my web apps to find out when and how often they were being used. When you create a web app it's nice to get some usage statistics, for yourself, and for your client.

In this tutorial we will delve into the area of monitoring and recording web app usage. It will be a learning experience for both of us!

You will also learn about sending emails from Omnis Studio and using timer objects.

This tutorial is provided to StudioTips Members only. If you are not currently a StudioTips Member please go to
www.studiotips.net and click the link provided for becoming a StudioTips Member. The cost of membership is minimal and helps to cover the time and expense of creating these tutorials and maintaining the studiotips.net website.

Class Wizard

If you use the Omnis Studio Class Wizard to create a remote task in one of the steps is asks if you want to inherit from a Monitor Task. If you select the checkbox it creates a web monitor task and window. Let's give this a try and then look at what the Omnis Studio Class Wizard creates for us.

  1. F2 Browser > Class Wizard > Remote Task
  2. Select the Plain Remote Task, enter rtWizard_Plain as the Remote Task Name, then click the Create button.
  3. The wizard will ask you if you want to inherit from a Monitor Task. Click the checkbox to select it. This will reveal a series of options.
  4. Select Create New Monitor Task.
    • Monitor Task Name: rtWizard_Monitor
    • Window Name: wMonitor
  5. Click through to the Finish.
The class wizard creates 3 new classes for you. rtWizard_Monitor, rtWizard_Plain, wMonitor. We can now study the code generated by the Omnis Studio wizard to figure out how it works.

Monitor Remote Task

The code in the rtWizard_Monitor is what we need to study to figure out how web app monitoring works.

There are 3 methods:

  1. $construct
    1. Checks to see if the wMonitor window is open and stores a reference to it.
    2. Sends it an $addConnection message to the wMonitor window
    3. The window returns a flag as to whether or not the server is busy.

  2. $destruct - Simply sends a $removeConnection message to the wMonitor window.

  3. $event - handles 3 different events.

    1. On evBusy - Sends a $setStatus message to the wMonitor window to indicate that the task is busy.
    2. On evIdle - Sends a $setStatus message to the wMonitor window to indicate that the task is not busy
    3. On evRejected - Calls the built-in $showmessage method to open an OK message on the client (web browser) displaying the pErrorText.

Monitor Window

The wMonitor window is keeping track of the following stats:

  1. Date/Time the server was last started.
  2. Date/Time the server was last paused.
  3. Number of times the server was started,
  4. Number of times the server was paused
  5. Total connections
  6. Total connections completed normally.
  7. Number of server transactions.
  8. Total disconnections.
  9. Total refused connections.
  10. Number of remote task instances.

The wMonitor window has a tasks list which displays each remote task that has been instantiated, the IP address which made the request, time connected, last response, time disconnected.

The wMonitor window has quite a few methods which you can study. We are not going to review the wMonitor window code in this tutorial. Feel free to study it on your own.

The problem I have with the web monitor created by the Omnis Studio Class Wizard is that it is a visual monitor. The code is inside a window class which must be instantiated for any monitoring to occur. If the window is closed, the monitoring ceases. The usage statistics are stored in memory, so when you close the window, the stats are lost.

Many web apps run remotely on a headless server, so it would make sense to create a non-visual object class which handles the web monitoring functions.