-
Notifications
You must be signed in to change notification settings - Fork 4
/
zcg_conway_timer_ws.prog.abap
86 lines (57 loc) · 1.66 KB
/
zcg_conway_timer_ws.prog.abap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
*&---------------------------------------------------------------------*
*& Report z_test_send_amc
*&---------------------------------------------------------------------*
*& Gol Timer via Websocket
*&---------------------------------------------------------------------*
REPORT zcg_conway_timer_ws.
PARAMETERS: mil_sec TYPE i DEFAULT 1000 OBLIGATORY,
times TYPE i DEFAULT 10 OBLIGATORY.
CLASS send_amc DEFINITION CREATE PUBLIC.
PUBLIC SECTION.
METHODS:
constructor
RAISING
cx_amc_error,
start
RAISING
cx_amc_error.
PRIVATE SECTION.
DATA:
_producer TYPE REF TO if_amc_message_producer_text.
METHODS:
_wait_n_milliseconds
IMPORTING
i_milliseconds TYPE i.
ENDCLASS.
CLASS send_amc IMPLEMENTATION.
METHOD constructor.
_producer ?= cl_amc_channel_manager=>create_message_producer( i_application_id = 'ZAMC_WAKEUP'
i_channel_id = '/channel' ).
ENDMETHOD.
METHOD start.
DO times TIMES.
_wait_n_milliseconds( mil_sec ).
_producer->send( || ).
ENDDO.
ENDMETHOD.
METHOD _wait_n_milliseconds.
DATA: ts1 TYPE timestampl,
ts2 TYPE timestampl,
ts3 TYPE timestampl.
DATA(seconds) = i_milliseconds / 1000.
GET TIME STAMP FIELD ts1.
DO.
GET TIME STAMP FIELD ts2.
ts3 = ts2 - ts1.
IF ts3 > seconds.
EXIT.
ENDIF.
ENDDO.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
TRY.
NEW send_amc( )->start( ).
CATCH cx_amc_error INTO DATA(error).
MESSAGE error TYPE 'S' DISPLAY LIKE 'E'.
ENDTRY.