@@ -18,6 +18,8 @@ Property corePID As %Numeric [ InitialExpression = 0 ];
1818/// The last known namespace in child process.
1919Property childNamespace As %String ;
2020
21+ Property StartupRoutine As %String ;
22+
2123/// Output flag
2224Property echo As %Boolean [ InitialExpression = 1 ];
2325
@@ -117,6 +119,10 @@ Method RequireAuthorization() As %List
117119 do ##class (Security.Users ).Get (username , .userProps )
118120 znspace ns
119121
122+ if ($get (userProps (" Routine" )) '= " " ) {
123+ set ..StartupRoutine = userProps (" Routine" )
124+ }
125+
120126 if $get (userProps (" Enabled" )) '= 1 {
121127 return $LB (" User " _ username _ " is not enabled in the system" )
122128 }
@@ -145,14 +151,20 @@ Method ProcessRequest(handler As %String, data) As %Status [ Private ]
145151/// Main method for every new client.
146152Method ClientLoop () As %Status [ Private ]
147153{
148- job ##class (WebTerminal.Core ).Loop ():($NAMESPACE )
154+ job ##class (WebTerminal.Core ).Loop (.. StartupRoutine ):($NAMESPACE )
149155 if ($TEST '= 1 ) {
150156 do ..Send (" error" , " %noJob" )
151157 return $$$NOTOK
152158 }
153159 set ..corePID = $ZCHILD
154160 set ..childNamespace = $NAMESPACE
155- do ..Send (" prompt" , ..childNamespace )
161+ if (..StartupRoutine = " " ) {
162+ do ..Send (" prompt" , ..childNamespace )
163+ } else {
164+ set message = ##class (%ZEN.proxyObject ).%New ()
165+ set status = $CLASSMETHOD (" WebTerminal.Handlers" , " Execute" , $this , " " , 1 )
166+ goto loopEnd
167+ }
156168 //try { // temp
157169 for {
158170 set message = ..GetMessage ()
@@ -171,7 +183,9 @@ Method ClientLoop() As %Status [ Private ]
171183 continue
172184 }
173185 }
186+ loopEnd
174187 //} catch (e) { do ..Send("o", $System.Status.GetErrorText(e)) } // temp
188+ return $$$OK
175189}
176190
177191/// This method sends basic login info to the user. Use this method to set client variables
@@ -203,12 +217,11 @@ Method Server() As %Status
203217 set ..CurrentNamespace = $Namespace
204218 do ..SendLoginInfo ()
205219 do ..ClientLoop ()
206- do ..Send (" oLocalized" , " %wsAbnormal " )
220+ do ..Send (" oLocalized" , " %wsNormalClose " _ $C ( 13 , 10 ) )
207221 } else {
208222 do ..Send (" oLocalized" , " %wsRefuse(" _ authMessage _ " )" )
209- do ..EndServer ()
210223 }
211-
224+ do .. EndServer ()
212225 quit $$$OK
213226}
214227
0 commit comments