1
1
<?xml version =" 1.0" encoding =" UTF-8" ?>
2
- <Export generator =" Cache" version =" 25" zv =" Cache for Windows (x86-64) 2015.1.1 (Build 505U)" ts =" 2015-12-20 11:06:06 " >
2
+ <Export generator =" Cache" version =" 25" zv =" Cache for Windows (x86-64) 2015.1.1 (Build 505U)" ts =" 2015-12-20 11:26:48 " >
3
3
<Class name =" WebTerminal.Engine" >
4
4
<Description >
5
5
Cache WEB Terminal version X.X.X/*build.replace:pkg.version*/ core.
6
6
This class is the server-side core of the terminal application.</Description >
7
- <Super >%CSP.WebSocket,Common</Super >
8
- <TimeChanged >63906,39906.305515 </TimeChanged >
7
+ <Super >%CSP.WebSocket,Common,Trace </Super >
8
+ <TimeChanged >63906,40862.530498 </TimeChanged >
9
9
<TimeCreated >63891,56786.028532</TimeCreated >
10
10
11
11
<Property name =" SharedConnection" >
@@ -32,19 +32,6 @@ connection or over a pool of shared connections. It may be set to one of the fo
32
32
<Type >%String</Type >
33
33
</Property >
34
34
35
- <Property name =" Watches" >
36
- <Description >
37
- Property is used to store watching files/globals. </Description >
38
- <Type >%List</Type >
39
- </Property >
40
-
41
- <Property name =" WatchesCaret" >
42
- <Description >
43
- Watch position in file on global</Description >
44
- <Type >%Numeric</Type >
45
- <MultiDimensional >1</MultiDimensional >
46
- </Property >
47
-
48
35
<Method name =" redirects" >
49
36
<Description >
50
37
Public point entries, using when redirecting i/o</Description >
@@ -272,164 +259,6 @@ rchr(timeout = 86400, data)
272
259
]]> </Implementation >
273
260
</Method >
274
261
275
- <Method name =" Trace" >
276
- <Description >
277
- Chechs for correct watch source and sets watch target to ..Watches
278
- Returns status of this operation</Description >
279
- <FormalSpec >name</FormalSpec >
280
- <ReturnType >%Status</ReturnType >
281
- <Implementation ><![CDATA[
282
- set s = $CHAR(0)
283
- set watches = s _ $LISTTOSTRING(..Watches, s) _ s
284
- if ($FIND(watches, s_name_s) '= 0) q 0 // if watch already defined
285
-
286
- if ($EXTRACT(name,1,1) = "^") { // watching global
287
- s g = 0
288
- try {
289
- if (($data(@name))'=0) s g = 1
290
- } catch { }
291
- set $ZERROR = ""
292
- if (g = 1) {
293
- set ..Watches = ..Watches _ $LISTBUILD(name)
294
- set ..WatchesCaret(name,0) = $QUERY(@name@(""),-1) // last
295
- set ..WatchesCaret(name,1) = "?"
296
- do ..SendData(name, ..#ConstClientTrace)
297
- q 1
298
- }
299
- } else { // watch file
300
- if (##class(%File).Exists(name)) {
301
- set ..Watches = ..Watches _ $LISTBUILD(name)
302
- set file = ##class(%File).%New(name)
303
- set ..WatchesCaret(name,0) = file.Size // current watch cursor position
304
- set ..WatchesCaret(name,1) = file.DateModified
305
- do ..SendData(name, ..#ConstClientTrace)
306
- q 1
307
- }
308
- }
309
-
310
- q 0
311
- ]]> </Implementation >
312
- </Method >
313
-
314
- <Method name =" StopTracing" >
315
- <Description >
316
- Removes watch from watches list
317
- Returns success status</Description >
318
- <FormalSpec >name</FormalSpec >
319
- <ReturnType >%Status</ReturnType >
320
- <Implementation ><![CDATA[
321
- // absurdly, but working
322
- set s = $CHAR(0)
323
- set watches = s _ $LISTTOSTRING(..Watches,s) _ s
324
- set newWatches = $REPLACE(watches, s_name_s, s)
325
- set ..Watches = $LISTFROMSTRING($EXTRACT(newWatches, 2, *-1), s)
326
- if (watches '= newWatches) {
327
- k ..WatchesCaret(name) // really removed
328
- do ..SendData(name, ..#ConstClientStopTrace)
329
- }
330
- quit watches '= newWatches
331
- ]]> </Implementation >
332
- </Method >
333
-
334
- <Method name =" ListWatches" >
335
- <Description >
336
- Returns a list current watches</Description >
337
- <ReturnType >%String</ReturnType >
338
- <Implementation ><![CDATA[
339
- set no=0
340
- set s = "Watching: " _ $CHAR(10)
341
- while $LISTNEXT(..Watches, no, value) {
342
- set s = s_"(pos: "_..WatchesCaret(value,0)_
343
- "; mod: "_..WatchesCaret(value,1)_") "_value_$CHAR(10)
344
- }
345
- q s
346
- ]]> </Implementation >
347
- </Method >
348
-
349
- <Method name =" GetTraceGlobalModified" >
350
- <Description >
351
- Return null string if global hadn't been updated
352
- This method watches only for tail of global and detects if global still alive</Description >
353
- <FormalSpec >watch</FormalSpec >
354
- <ReturnType >%String</ReturnType >
355
- <Implementation ><![CDATA[
356
- set data = ""
357
- if ($data(@watch)=0) {
358
- do ..StopTracing(watch)
359
- q "removed"
360
- }
361
- for {
362
- set query = $QUERY(@..WatchesCaret(watch,0))
363
- quit:query=""
364
- if (data="") set data = "modified"
365
- set ..WatchesCaret(watch,0) = query
366
- set data = data _ $CHAR(13, 10) _ @query
367
- }
368
- q data
369
- ]]> </Implementation >
370
- </Method >
371
-
372
- <Method name =" GetTraceFileModified" >
373
- <FormalSpec >watch</FormalSpec >
374
- <ReturnType >%String</ReturnType >
375
- <Implementation ><![CDATA[
376
- set file=##class(%File).%New(watch)
377
- set size = file.Size
378
- set modDate = file.DateModified
379
- set output = ""
380
- if (size < 0) { // file had been deleted
381
-
382
- do ..StopTracing(watch)
383
- q "removed"
384
-
385
- }
386
-
387
- if (size > ..WatchesCaret(watch, 0)) {
388
-
389
- set output = "updated" _ $CHAR(13, 10)
390
- set stream=##class(%Stream.FileBinary).%New()
391
- set sc=stream.LinkToFile(watch)
392
- do stream.MoveTo(..WatchesCaret(watch, 0) + 1)
393
- set readed = stream.Read(size - ..WatchesCaret(watch, 0))
394
- set output=output_readed
395
- set ..WatchesCaret(watch, 0) = size
396
- set ..WatchesCaret(watch, 1) = file.DateModified
397
-
398
- } elseif ((size < ..WatchesCaret(watch, 0)) || (file.DateModified '= ..WatchesCaret(watch, 1))) {
399
-
400
- set output = "modified" _ $CHAR(13, 10)
401
- set output = output _ "Bytes changed: " _ (size - ..WatchesCaret(watch, 0))
402
- set ..WatchesCaret(watch, 0) = size
403
- set ..WatchesCaret(watch, 1) = file.DateModified
404
-
405
- } // else file not changed
406
- q output
407
- ]]> </Implementation >
408
- </Method >
409
-
410
- <Method name =" CheckTracing" >
411
- <ReturnType >%String</ReturnType >
412
- <Implementation ><![CDATA[
413
- set no = 0
414
- set data = ""
415
- set overal = ""
416
- set watchList = ..Watches // do not remove or simplify: ..Watches can be modified
417
- while $LISTNEXT(watchList, no, value) {
418
- if ($EXTRACT(value, 1, 1) = "^") {
419
- set data = ..GetTraceGlobalModified(value)
420
- } else {
421
- set data = ..GetTraceFileModified(value)
422
- }
423
- if (data '= "") {
424
- set overal = $ZDATETIME($NOW(),1,1) _ " " _
425
- value _ ": " _ data _ $CHAR(10)
426
- }
427
- set data = ""
428
- }
429
- q overal
430
- ]]> </Implementation >
431
- </Method >
432
-
433
262
<Method name =" OnPostServer" >
434
263
<ReturnType >%Status</ReturnType >
435
264
<Implementation ><![CDATA[
0 commit comments