usergw
UserGW is the gateway point between a user's browser and MAE via HTTP protocol. All external URL requests are converted into MAE message requests and send to the appropriate MAE application. All internal MAE requests are converted into HTML to be processed by the user's browser.
For a user's browser, UserGW serves
From a user's browser, it handles
From a MAE application's perspective, UserGW is like a basic device driver that converts abstracted UI requests into HTML and JavaScript, whereas MAE internally knows nothing of either. For fancy GUI interaction, see guibroker, which tracks and manages interactive UI component prompts and responses.
UserGW reads these commhub attributes (that originate from the commhub.ini file):
Keyword |
Value |
httpport |
TCP port number to listen for HTTP connections. Default: 8048. Note that ports under 4096 can only be used by root user. |
loginpage |
When an unauthenticated user requests a page, present this URL as the login page. Since UserGW only allows unauthenticated users to access files under /pub, the file should be there. For example: /pub/login.html |
servername |
The external name of the host where usergw listens. Default: maeserver |
firstapp |
After a user logs in, this is the first app the user will see. It is the home app. Default: userman |
accesslog |
Specifies where all page queries are recorded. Default: /usr/mae/log/access.log |
Communication with UserGW is done via messages through the UserDevice class; behind the scenes, the UserDevice class uses UserGW's DisplayAPI interface.
Typically, an application waits for the user to initiate a session (so it has a handle to the user's session) before sending content to display to that user. When the user initiates a session, GuiBroker will send the userstart message to your application; your application needs a #userstart command in your .mreg file for genmae to convert the message into a method call.
usergw uses these database tables:
Table Name |
Description |
Table of users allowed to login, password, and stats. | |
Table of application-specific user properties. | |
A database of images where uploaded images are stored. |
Directory |
Usage |
MAEDIR/html/pub |
All content located in this directory are accessible via GET without prior user login authorization. This is useful for the login page itself and public content. |
MAEDIR/html/record |
Content referenced by the record message is pulled from this directory. |
MAEDIR/html/form |
Content referenced by the form message is pulled from this directory. |
MAEDIR/html/doc |
Documentation folder for MAE envirfonment. Querying any URL beginning with /doc/ will pull from this directory. |
MAEDIR/html/template |
Content used by docgen, not UserGW. |
Requests may be for HTML content or a REST query using HTTP 2.0.
UserGW handles these HTTP commands
Command |
Value |
Notes |
GET |
URL headers |
The URL is a series of keywords separated by forward slash, optionally followed by a question mark and series of key/value pairs. The headers are standard HTTP headers. |
POST |
URL headers content |
The URL is a series of keywords separated by forward slash, optionally followed by a question mark and series of key/value pairs. The headers are standard HTTP headers. The content format is specified by headers and contains payload data for the request. |
Note that PUT, DELETE, and PATCH are also supported if a MAE App enables them for REST API requests.
UserGW only processes these HTTP headers
Header |
Value |
Description | ||||||||||||||
Cookie: |
A series of key/value pairs, separated by spaces. |
Cookies used by user experience. Expected cookies are ID (user id) and SID (session id).
| ||||||||||||||
User-Agent: |
Name of the browser. |
|||||||||||||||
Host: |
Server name. |
The hostname of the (virtual) MAE HTTP server. | ||||||||||||||
X-Forwarded-For: |
IP address |
When HTTP content is forwarded by a proxy, this is the real IP address of the user's browser. | ||||||||||||||
Content-Type: |
category/type |
Used to recognize multi-part documents with boundaries. | ||||||||||||||
Content-Length: |
integer |
This header specifies the number of bytes in the content section. | ||||||||||||||
Connection: |
Connection type. |
The connection type keep-alive is recognized, so browsers can send multiple requests in the same TCP connection. | ||||||||||||||
Content-Disposition: |
Meta data about content. |
This is a series of key/value pairs, semi-colon delimited. For example: Content-Disposition: form-data; name="files[]"; filename="Gambit Cover Letter.docx" |
The URL tells UserGW whether to provide content it manages or to send messages to MAE applications.
URL |
Description |
response |
User is providing a response of some sort; , send the value to guibroker to process. URL input paramters. xid - transaction id (previously provided) value - the value typed/selected/chosen by the user tag - the name of the region wid - tenant id |
update |
Send back any outstanding Updater commands to update the UI. This makes the user's view in their browser current with the MAE's state. |
key |
The user has pressed a key. Route it to guibroker. Input parameters: key - The key value. tag - the name of the region wid - tenant id |
click |
Register a click on a specifically named region in the UI, sending to guibroker. This is not a region with a pre-registered callback like a hotspot. Input parameters: tag - the name of the region wid - tenant id |
chat |
Receive a message to chat to another user. Input parameters: text - The text content of a specific chat message. wid - tenant id |
mouse |
Register a mouse button click at a specific point inside a named region, sending to guibroker. Input parameters: pos - the (x,y) of the click. (0,0) is the upper left; x increases to the right; y increases downward. Parenthesis not specified. dir - direction of button press - whether up or down. button - id of button used. 0 for left, 1 for right. tag - the name of the region wid - tenant id |
hotspot |
A named region of the UI with a registered callback (e.g. a hotspot) has been activated, send to guibroker. Input parameters: tag - the name of the region (hotspot name) wid - tenant id |
select |
The user has chosen an option from a selection pull-down, reported to guibroker. Input parameters: value - the value in the pull-down that the user selected tag - the name of the region wid - tenant id |
cmd command |
The user has clicked on something that triggers a named UI action; notify guibroker. This may be a button in the UI or selected menu option. Input parameters: cmd - the name of the UI action to take; this command get routed from guibroker to the MAE application that handles it, using the command as a request in a message wid - tenant id |
refresh |
Triggers a refresh of the page for the app mode. Deprecated. Input parameters: appmode - name of the app to refresh |
upload |
Upload a file to MAE, saved to ImageLib, then guibroker is notified. The file type is specified in the ContentType HTTP header. Presently, only image/* file types are supported for svg+xml, svg, jpeg, and jpg. The file itself is in POST content. Input parameters: filename - the name of the content wid - tenant id |
login relogin |
Display the pub/login.html page. |
logout |
Unauthenticate the current session. Cookie SID is set to 0. The pub/logout.html page is displayed. |
doc |
Display a static content documentation page located under MAEDIR/html/doc. |
*.html |
Display a .html page located under MAEDIR/html |
appmode |
Switch the app mode to appmode, display the content of MAEDIR/html/appmode'.html, and notify guibroker that this app mode has started (it's online). |
images/imagename |
Pull an image from MAEDIR/html/images and send back. |
images/groupid/version/imagename |
Pull an image from UserGW's image cache and send back. Note that imager sends images to UserGW to cache. |
imagelib/dbid/checksum |
Pull an image frim the ImageLib and send back. |
Page |
Use |
index.html index.php index.asp ajax.php |
Render the home/primary page for the current app mode. The app associated with the app mode will be notified via guibroker that the app has started. |
pub/login.html |
An unauthenticated user is redirected to this page to login before they can access other authenticated content. |
pub/disabled.html |
Contains the page to display to a user when the user attempts an authenticated operation that is non-public. |
pub/logout.html |
A user is redirected to this page when their session has timed out. |
pub/locked.html |
A user is redirected to this page when their account is locked due to too many login attemps. |
pub/lockeddown.html |
A user is redirected to this page when their account is locked due to way too many login attemps. |
pub/relogin.html |
A user is redirected to this page when their session has timed out and they need to login again. |
The following messages may be received on the display channel.
MsgTag |
Description |
field |
Update/Replace the table and field entry with the value provided device - the end-user's device table - the area with a collection of fields in it field - the specific field within that area value - the string to display @return true if sent successfully |
text |
Replace the display region with the text provided. device - the end-user's device text - the text to put there style - display style for the text @return true if sent successfully |
write |
Append to the display reagion with the provided text for the user specified device - the end-user's device text - the text to append style - display style for the text @return true if sent successfully |
writeln |
Append to the display reagion with the provided text for the user specified, followed by a line break. device - the end-user's device text - the text to append style - display style for the text @return true if sent successfully |
wiki |
Convert the text from wiki text (see wiki2doc) and display to the display region. device - the end-user's device text - the text to append @return true if sent successfully |
hotspot |
Append the tagged area with the provided text for the user specified and make it a hot spot that triggers an action. device - the end-user's device text - the text to append action - the message keyword to send when user clicks on text (aka request) cbdata - data to send along with action message style - the preset way to display the text (color, font, etc) @return true if sent successfully |
hint |
Provide hint text to the end-user for the display region. Exact implementation up to the end interface, but it may be to display text when the user hovers over the display region. device - the end-user's device text - the hint text to show the user @return true if sent successfully |
button |
Append the tagged area with the provided text on a button for the user on the device specified. When clicked, it triggers a a message with the action and callback data. device - the end-user's device text - the text on the button action - the message keyword to send when user clicks on text (aka request) cbdata - data to send along with action message |
control |
DEPRECATED - use style() instead. Update the current display style state. device - the end-user's device control - the UI state keyword to update, e.g. strong, emphasis, bold, italic, underline, color:color on - flag to say turn the control on or off @return true if sent successfully |
newregion |
Create a new display region inside device's current display region. device - the end-user's device newtag - the new region's name styleName - the preset way to display the text (color, font, etc) size - the number of characters wide for the new region (suggestion) @return true if sent successfully |
style |
Set the named display style for device's current display region. See the configured properties of the style in the appropriate end-user display type (e.g. usergw uses HTML CSS). device - the end-user's device styleName - the new region's name @return true if sent successfully |
attention |
Display a message to get the user's attention. device - the end-user's device text - the text for the user to see @return true if sent successfully |
selection |
When a display region contains a selector, set the active selection to the value provided. If the value is not a valid selection, behavior is undefined. device - the end-user's device value - the value to show on the selector @return true if sent successfully |
chat |
Send a chat message to the end-user's device. device - the end-user's device from - name of user whom the message is from text - the message to display @return true if sent successfully |
clear |
Clear all displayed objects and text from the current display region of the device. device - the end-user's device @return true if sent successfully |
show |
Display the objects and text inside the current display region of the device. device - the end-user's device @return true if sent successfully |
hide |
Hide the objects and text inside the current display region of the device. Make them non-visible. device - the end-user's device @return true if sent successfully |
newtable |
Create a table display region on the user'd device. It will be setup with the rows and columns specified. Note that referencing one column more to the right will create that column; and referencing one more row below will create that row. device - the end-user's device tableName - the name of the table tableType - the type of table, e.g. left, center, right rows - the number of rows in the table columns - the number of columns in the table @return true if sent successfully |
newlist |
Create a bulleted list that can contains items. Note that adding a list item immediately beyond the end will expand the list. device - the end-user's device name- the name of the list items - a count of the expected number of list items (suggestion) @return true if sent successfully |
record |
Output a record of information using a templte to map old UI ids to new ones. For idmap, the key is the old id and the value is the new id device - the end-user's device recordName - the record template's name (this corresponds to a file under .../html/record) idmap- (optional) mapping of template field names to actual ids to use values - key/value paris of id/values to fill in values in the record overwrite - flag: true to replace existing display region, false to append @return true if sent successfully |
report |
FUTURE USE. Output a report of information device - the end-user's device reportName - the name of the report to output table - the name of the table to ...? table_id - the id for the table ...? @return true if sent successfully |
prompt |
Present the user with a question and response (text entry) box. The xid parameter ties back to the appropriate response action and callback data to use when replying (see GuiAPI). device - the end-user's device query - (optional) the question text for the user value - the default value promptType - the type of prompt, e.g. text, yn, int, etc. xid - a transaction id maintained by the calling app (guibroker) style - the style to use for the query @return true if sent successfully |
select |
Present the user with a selection of choices. The xid parameter ties back to the appropriate response action and callback data to use when replying (see GuiAPI). device - the end-user's device option0 - The visible question that is the first option on the list - and the default if no value is given. If the user actually selects this option, the app will be given the value $NA options - the list of options to show the user. They key is show; the value is returned as the reply. xid - a transaction id maintained by the calling app (guibroker) selected - the selected option @return true if sent successfully |
checkbox |
Present the user with a selection of choices as checkboxes. The xid parameter ties back to the appropriate response action and callback data to use when replying (see GuiAPI). device - the end-user's device query - (optional) the question text for the user value - the default value xid - a transaction id maintained by the calling app (guibroker) style - the style to use for the query @return true if sent successfully |
textarea |
Present the user with an area to type a lot of text. The xid parameter ties back to the appropriate response action and callback data to use when replying (see GuiAPI). device - the end-user's device text - the initial text in the box xid - a transaction id maintained by the calling app (guibroker) style - the style to use for the query saveLabel - the label on the button for the user to click on to send the revised text @return true if sent successfully |
form |
Present the user with input form template. The xid parameter ties back to the appropriate response action and callback data to use when replying (see GuiAPI). device - the end-user's device formName - the name of the form (relates to .../html/form files) vars - key/value paris of id/values to fill in default values xid - a transaction id maintained by the calling app (guibroker) @return true if sent successfully |
screen |
Create a terminal screen of the specified size on the user's device. device - the end-user's device name - the name of the screen for reference rows - number of rows in the screen columns - the number of columns in the screen @return true if sent successfully |
scrattr |
Set the current terminal screen attributes for the next character(s) to be written. device - the end-user's device attributes - a comma separated list of styles, e.g. cursor, bold, underline, reverse, red, blue, etc @return true if sent successfully |
scrchar |
Write a character to the terminal screen previously defined at device's display region. device - the end-user's device row - the terminal row column - the terminal column letter - a numerical value for the letter to write, e.g. ASCII. Note that letters 0-31 are non-printable. amount - the number of letters to write out (repeating letters) @return true if sent successfully |
setmenu |
Configure the end-user's device with the menu option under the specified menu. When the end-user selects it, the specified command will be sent as a message request of the app. device - the end-user's device menu - the menu heading that contains menu options option - the menu option text command - the request keyword to send to the app @return true if sent successfully |
unsetmenu |
Remove the menu option under the specified menu on the end-user's device. device - the end-user's device menu - the menu heading that contains menu options option - the menu option text @return true if sent successfully |
setwindow |
Configure the end-user's device with a window, titled with the name provided. device - the end-user's device windowName - the name of the window; it appears as the window's title @return true if sent successfully |
unsetwindow |
Remove/Close the named window from the end-user's device. device - the end-user's device windowName - the name of the window; it appears as the window's title @return true if sent successfully |
setindex |
Configure the end-user's device with the index (tab). device - the end-user's device indexName - the name of the index; it appears as the index's title @return true if sent successfully |
unsetindex |
Remove the named index from the end-user's device. device - the end-user's device indexName - the name of the index; it appears as the index's title @return true if sent successfully |
newsection |
Add a section the the UI. Sections can be manipulated, for example expanded/collapsed. device - the end-user's device title - the section title sectionType - a comma separated list of section qualities, e.g. collabsable, h2, h3 newtag - the tag for the section (must begin with Section_) @return true if sent successfully |
section |
Collapse the section identified as the current display region. device - the end-user's device @return true if sent successfully |
image |
Display the referenced buffered image that has already been transferred to display channel. If an action is provided, the image can be clicked on to trigger the action with its callback data. device - the end-user's device imageName - the Image's name (see Image class) image_type - the image type, e.g. svg, gif action - (optional) if specified, then image is a hot spot; when the user clicks on it, a message will be send with this action/request keyword cbdata - (optional) if an action was specified, then image is a hot spot; when the user clicks on it, a message will be send with this callback data append - Add the image or replace the contents of the device's current region. Default: false/replace. @return true if sent successfully |
imagelib |
Display the referenced buffered image that has already been transferred to display channel. If an action is provided, the image can be clicked on to trigger the action with its callback data. device - the end-user's device image_id - the image id from the ImageLib library action - (optional) if specified, then image is a hot spot; when the user clicks on it, a message will be send with this action/request keyword cbdata - (optional) if an action was specified, then image is a hot spot; when the user clicks on it, a message will be send with this callback data append - Add the image or replace the contents of the device's current region. Default: false/replace. @return true if sent successfully |
download |
Request that the user send the app a file. device - the end-user's device query - the question/prompt to the user fileclass - a comma separated list of file types, e.g. html, pdf, svg, etc. xid - a transaction id maintained by the calling app (guibroker) @return true if sent successfully |
upload |
Send a file to the end-user's device that has already been transferred to display channel. device - the end-user's device imageName - the Image's name (see Image class) image_type - the image type, e.g. svg, gif @return true if sent successfully |
imagelib-pre |
Pre-fetch and image from ImageLib. device - the end-user's device id - the image's id in ImageLib @return true if sent successfully |
bufimage |
Send a chunk of data to the display chennel (to fit within a message max size). device - the end-user's device imageName - the Image's name (see Image class) image_type - the image type, e.g. svg, gif width - image width, in pixels height - image height, in pixels size - size of image, in bytes binary - flag set to true if data is binary (hex encoded) chunk - chunk #, starting at 0, increasing with subsequent chunks totalChunks - total number of chunks being sent chunksize - size of this chunk of data, in bytes data - the data of this chunk @return true if sent successfully |
setvar |
Alter a end-user device built-in variable value. device - the end-user's device variable - the end-user device variable to set, e.g. wid (tenant id), pc value - the new value of the variable @return true if sent successfully |
Alter a end-user device built-in variable value. device - the end-user's device variable - the end-user device variable to set, e.g. wid (tenant id), pc value - (output) the current value of the variable @return true if sent successfully |
UserGW transmits updates to a JavaScript program (updater.js) that runs in the browswer. Each command has three parts, separated by vertical bars:
command|region|data
These are the commands it sends:
Command |
Description |
html |
Replace the DOM component identified by the region with the contents of data. |
html+ |
Append the DOM component identified by the region with the contents of data. |
class |
Change the class of the DOM component identified by the region to the value in data. |
attn |
The message in data is a line that requires the user's attention. Does not require user confirmation. |
color |
Set the color of the DOM component identified by the region to the value in data. |
bgcolor |
Set the background color of the DOM component identified by the region to the value in data. |
select |
Set the active selection of the pull-down identified by the region to the value in data. |
show |
If previously hidden, now show the contents of the DOM component identified by the region to the value in data. |
hide |
Hide the contents of the DOM component identified by the region to the value in data. |
focus |
Move the user's input focus to the DOM component identified by the region. |
mouseover |
Show the text in data when the user's mouse hovers over the DOM component identified by the region. |
setmenu |
Define an application menu and menu option. When the user selects the option, a request keyword is set back to usergw. Here, region is the menu name and data is the menu option text and request keyword, separated by a comma. |
unsetmenu |
Remove an application menu option. Here, region is the menu name and data is the menu option text. |
screen |
Create a virtual terminal screen at region. data is name, rows, and columns of the screen. |
scrattr |
Specify the virtual terminal character attribute in a defined screen location. |
scrchar |
Speicify the virtual terminal character to display at a defined screen location. |
setwindow |
Bring the named window (identified by region) forward or create a new window with the name provided. The window name is displayed after underscores are replaced with spaces. |
unsetwindow |
Remove the named window from display (identified by region). |
setindex |
An index is a tab stacked at the left with content. Bring the named index (identified by region) forward or create a new tab with the name provided. The tab name is displayed after underscores are replaced with spaces. |
unsetindex |
Remove the named index/tab from display (identified by region). |
setcollpsable |
Create a named collaspable display region. The user controls whether the region is displayed (expanded) or collapsed (hidden). |
reauth |
Notify the user that the session has expired and re-authentication is required to continue. |
setvar |
Set a local browser variable value. The variable name is in region; the variable value is in data. |
run |
Change the actively displayed page to the URL provided in data. |
page |
Open another page in the browser with the URL provided in data. |
stop |
Instructs updater.js to stop querying usergw for updates. After issuing, asynchronous UI updates will not be timely, if they ever arrive. |