Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

MES Stateful API

Starting Sessions

After you create an aaFactMES.aaClientSession object, you can use it to start a session with the MES middleware. The MES middleware requires a session for most functions to work.

You can call the Init script to start a session, initialize any attributes and log on a user. The Init script should be called one time by one Application Object.

If you use the Init script to log on a user, you must change the user and password in the Login method.

You can use the Init script as either an OnScan or Execute script with some attribute-based trigger. If you use it as an Execute script, you should mark it as an asynchronous script.

Init Script Example (CS)

' Init Script
dim clientSession As aaFactMES.aaClientSession;
dim result As aaFactMES.Result;
' Get the singleton client session - if one doesn't exist yet,
' it will be created
result = aaFactMES.aaClientSession.GetInstance();
clientSession = result.Value;

if ( clientSession <> null and clientSession.SessionId == -1) then
       ' Start the session. Only do this if a session isn't already started
    result = clientSession.StartSession (aaFactMES.aaClientTypes.clientOperator);
        if (result.Success == true) then
        LogMessage("Session Started!");
                ' Login a user - this should cause a UserChanged event (see MonitorEvents script)
        result = clientSession.Login("fact_user", "fact_user_pswd");
              if (result.Success == true) then
              LogMessage("Login succeeded!");
              endif;
              else
              LogMessage("Session failed to start!");
       endif;
endif;

TitleResults for “How to create a CRG?”Also Available in