Commit e753f5e8c1ea185989a5f2d9f22f06b66f8cf0b9
1 parent
ffacfd77
- added standard attributes to textarea
- NetServices : added TIMESTAMP field into service negotiation answer - Renaming 'service' and 'version' fields to their upper case value.
Showing
4 changed files
with
71 additions
and
26 deletions
Show diff stats
calexium_lib/net_services/CXM_generic_client.anubis
| ... | ... | @@ -93,7 +93,7 @@ define Maybe($T) |
| 93 | 93 | } |
| 94 | 94 | }. |
| 95 | 95 | |
| 96 | -public define (MessageQueue) -> Maybe($T) | |
| 96 | +public define (MessageQueue, String) -> Maybe($T) | |
| 97 | 97 | make_generic_handler |
| 98 | 98 | ( |
| 99 | 99 | Int32 timeout, |
| ... | ... | @@ -101,7 +101,7 @@ public define (MessageQueue) -> Maybe($T) |
| 101 | 101 | (Message) -> Maybe($T) handler, |
| 102 | 102 | (String) -> One logger |
| 103 | 103 | ) = |
| 104 | - (MessageQueue queue) |-> | |
| 104 | + (MessageQueue queue, String timestamp) |-> | |
| 105 | 105 | generic_handler(queue, timeout, msg_to_send, handler, logger). |
| 106 | 106 | |
| 107 | 107 | define Maybe($T) |
| ... | ... | @@ -110,12 +110,12 @@ define Maybe($T) |
| 110 | 110 | MessageQueue queue, |
| 111 | 111 | Int32 service_id, |
| 112 | 112 | Int32 service_version, |
| 113 | - (MessageQueue) -> Maybe($T) handler, | |
| 113 | + (MessageQueue, String) -> Maybe($T) handler, | |
| 114 | 114 | (String) -> One logger |
| 115 | 115 | )= |
| 116 | 116 | with test_msg = message(_CXM_REQUEST_FOR_SERVICE), |
| 117 | - forget(add_int32(test_msg, "service", service_id)); | |
| 118 | - forget(add_int32(test_msg, "version", service_version)); | |
| 117 | + forget(add_int32(test_msg, "SERVICE", service_id)); | |
| 118 | + forget(add_int32(test_msg, "VERSION", service_version)); | |
| 119 | 119 | queue.add_Message_to_send(test_msg); |
| 120 | 120 | if queue.get_next_received_Message(10) is |
| 121 | 121 | { |
| ... | ... | @@ -124,10 +124,20 @@ define Maybe($T) |
| 124 | 124 | msg(msg) then |
| 125 | 125 | if find_int32(msg, "STATUS") is |
| 126 | 126 | { |
| 127 | - failure then logger("["+queue.get_name(unique)+"]: requesting service status not found");failure, | |
| 127 | + failure then logger("["+queue.get_name(unique)+"]: requesting service STATUS not found");failure, | |
| 128 | 128 | success(v) then |
| 129 | 129 | if v = _CXM_OK then |
| 130 | - handler(queue) | |
| 130 | + if find_message(msg, "RESULT") is | |
| 131 | + { | |
| 132 | + failure then logger("["+queue.get_name(unique)+"]: requesting service RESULT not found");failure, | |
| 133 | + success(result) then | |
| 134 | + if find_string(msg, "TIMESTAMP") is | |
| 135 | + { | |
| 136 | + failure then logger("["+queue.get_name(unique)+"]: requesting service TIMESTAMP not found");failure, | |
| 137 | + success(timestamp) then | |
| 138 | + handler(queue, timestamp) | |
| 139 | + } | |
| 140 | + } | |
| 131 | 141 | else |
| 132 | 142 | logger("["+queue.get_name(unique)+"]: requested service started won't start");failure |
| 133 | 143 | } |
| ... | ... | @@ -141,7 +151,7 @@ public define Maybe($T) |
| 141 | 151 | Int32 port, |
| 142 | 152 | Int32 service_id, |
| 143 | 153 | Int32 service_version, |
| 144 | - (MessageQueue) -> Maybe($T) handler, | |
| 154 | + (MessageQueue, String) -> Maybe($T) handler, | |
| 145 | 155 | (String) -> One logger |
| 146 | 156 | ) |
| 147 | 157 | = | ... | ... |
calexium_lib/net_services/CXM_generic_protocol.anubis
| ... | ... | @@ -14,9 +14,10 @@ read tools/basis.anubis |
| 14 | 14 | read system/message_queue.anubis |
| 15 | 15 | read calexium_lib/CXM_message_constants.anubis |
| 16 | 16 | |
| 17 | -public define Int32 _CXM_OK = 0. | |
| 18 | -public define Int32 _CXM_ERROR = 1. | |
| 19 | -public define Int32 _CXM_UNKNOW_CMD = 2. | |
| 17 | +public define Int32 _CXM_OK = 0. | |
| 18 | +public define Int32 _CXM_ERROR = 1. | |
| 19 | +public define Int32 _CXM_UNKNOW_CMD = 2. | |
| 20 | +public define Int32 _CXM_UNKNOW_SERVICE = 2. | |
| 20 | 21 | |
| 21 | 22 | public type ProtocolResult: |
| 22 | 23 | failure, |
| ... | ... | @@ -30,14 +31,26 @@ public define One |
| 30 | 31 | send_ACK_error |
| 31 | 32 | ( |
| 32 | 33 | MessageQueue queue, |
| 33 | - Int32 cmd_id | |
| 34 | + Int32 cmd_id, | |
| 35 | + Int32 error_code, | |
| 36 | + String error_string, | |
| 34 | 37 | )= |
| 35 | 38 | with err_msg = message(_CXM_ACK), |
| 36 | 39 | forget(add_int32(err_msg, "CMD", cmd_id)); |
| 37 | - forget(add_int32(err_msg, "STATUS", _CXM_ERROR)); | |
| 40 | + forget(add_int32(err_msg, "STATUS", error_code)); | |
| 41 | + (if error_string /= "" then forget(add_string(err_msg, "STATUS_STR", error_string)) | |
| 42 | + else unique); | |
| 38 | 43 | forget(queue.add_Message_to_send(err_msg)). |
| 39 | 44 | |
| 40 | 45 | public define One |
| 46 | + send_ACK_error | |
| 47 | + ( | |
| 48 | + MessageQueue queue, | |
| 49 | + Int32 cmd_id | |
| 50 | + )= | |
| 51 | + send_ACK_error(queue, cmd_id, _CXM_ERROR, ""). | |
| 52 | + | |
| 53 | +public define One | |
| 41 | 54 | send_ACK_ok |
| 42 | 55 | ( |
| 43 | 56 | MessageQueue queue, | ... | ... |
calexium_lib/net_services/CXM_net_services.anubis
| ... | ... | @@ -21,7 +21,7 @@ public type NetService: |
| 21 | 21 | Int32 version, |
| 22 | 22 | Int32 id, |
| 23 | 23 | String name, |
| 24 | - (MessageQueue, String) -> One handler | |
| 24 | + (MessageQueue, String, String) -> One handler // Parameters are MessageQueue, peer IP and timestamp string | |
| 25 | 25 | ). |
| 26 | 26 | |
| 27 | 27 | define One |
| ... | ... | @@ -67,16 +67,34 @@ define Maybe(NetService) |
| 67 | 67 | Message msg, |
| 68 | 68 | List(NetService) net_services |
| 69 | 69 | )= |
| 70 | - if find_int32(msg, "service") is | |
| 70 | + if find_int32(msg, "SERVICE") is | |
| 71 | 71 | { |
| 72 | - failure then send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE); failure, | |
| 72 | + failure then //send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE); failure, | |
| 73 | + // old names... should be removed soon | |
| 74 | + if find_int32(msg, "service") is | |
| 75 | + { | |
| 76 | + failure then send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE); failure, | |
| 77 | + success(service_id) then | |
| 78 | + if find_int32(msg, "version") is | |
| 79 | + { | |
| 80 | + failure then send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE);failure, | |
| 81 | + success(service_version) then find_service(net_services, service_id, service_version) | |
| 82 | + } | |
| 83 | + } | |
| 84 | + | |
| 73 | 85 | success(service_id) then |
| 74 | - if find_int32(msg, "version") is | |
| 86 | + if find_int32(msg, "VERSION") is | |
| 75 | 87 | { |
| 76 | 88 | failure then send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE);failure, |
| 77 | 89 | success(service_version) then find_service(net_services, service_id, service_version) |
| 78 | 90 | } |
| 79 | 91 | }. |
| 92 | + | |
| 93 | +define String | |
| 94 | + get_time_stamp | |
| 95 | + = | |
| 96 | + with time = (UTime) now, | |
| 97 | + "<"+virtual_machine_id+"@"+time.seconds+">". | |
| 80 | 98 | |
| 81 | 99 | /** This message_received function just handle the negociation process the available net_services. |
| 82 | 100 | * In other words, it only recognize the _CXM_REQUEST_FOR_SERVICE message and try to launch the |
| ... | ... | @@ -97,13 +115,16 @@ define One |
| 97 | 115 | if has_service(queue, msg, net_services) is |
| 98 | 116 | { |
| 99 | 117 | failure then |
| 100 | - send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE), | |
| 118 | + send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE, _CXM_UNKNOW_SERVICE, "Unknown service") | |
| 101 | 119 | success(net_service) then |
| 102 | - send_ACK_ok(queue, _CXM_REQUEST_FOR_SERVICE); | |
| 103 | - net_service.handler(queue, peer) | |
| 120 | + with result = message(0), | |
| 121 | + timestamp = get_time_stamp, | |
| 122 | + forget(add_string(result, "TIMESTAMP", timestamp)); | |
| 123 | + send_ACK_ok(queue, _CXM_REQUEST_FOR_SERVICE, result); | |
| 124 | + net_service.handler(queue, peer, timestamp) | |
| 104 | 125 | } |
| 105 | 126 | else |
| 106 | - unique | |
| 127 | + send_ACK_error(queue, *msg.what, _CXM_UNKNOW_CMD, "Unknown command [" + (*msg.what) + "]") | |
| 107 | 128 | . |
| 108 | 129 | |
| 109 | 130 | /** |
| ... | ... | @@ -155,7 +176,6 @@ public define Maybe(Server) |
| 155 | 176 | Int32 network_port, |
| 156 | 177 | Var(Bool) shutdown_required |
| 157 | 178 | )= |
| 158 | - //TODO change the port number in the real world | |
| 159 | 179 | if start_server(0, |
| 160 | 180 | network_port, |
| 161 | 181 | net_services_handler(net_services), | ... | ... |
calexium_lib/web/CXM_making_a_web_site.anubis
| ... | ... | @@ -973,6 +973,7 @@ public define Actioner_Aspect |
| 973 | 973 | |
| 974 | 974 | |
| 975 | 975 | public type TextAreaOption: |
| 976 | + input_attrs(List(InputAttrs)), | |
| 976 | 977 | disabled, |
| 977 | 978 | read_only, |
| 978 | 979 | wrap_lines. |
| ... | ... | @@ -3547,9 +3548,10 @@ define Printable_tree |
| 3547 | 3548 | [] then [], |
| 3548 | 3549 | [h . t] then if h is |
| 3549 | 3550 | { |
| 3550 | - disabled then [" disabled " . format1(t)] | |
| 3551 | - read_only then [" readonly " . format1(t)] | |
| 3552 | - wrap_lines then [" wrap " . format1(t)] | |
| 3551 | + input_attrs(input_attr_list) then [format_attrs(input_attr_list) . format1(t)], | |
| 3552 | + disabled then [" disabled=\"disabled\" " . format1(t)] | |
| 3553 | + read_only then [" readonly=\"readonly\" " . format1(t)] | |
| 3554 | + wrap_lines then [" wrap=\"wrap\" " . format1(t)] | |
| 3553 | 3555 | } |
| 3554 | 3556 | }. |
| 3555 | 3557 | |
| ... | ... | @@ -3560,7 +3562,7 @@ define Printable_tree |
| 3560 | 3562 | ) = |
| 3561 | 3563 | if member(l,wrap_lines) |
| 3562 | 3564 | then format1(l) |
| 3563 | - else [" wrap=off " . format1(l)]. | |
| 3565 | + else [" wrap=\"off\" " . format1(l)]. | |
| 3564 | 3566 | |
| 3565 | 3567 | |
| 3566 | 3568 | *** [5.7] Formating elements which may be put anywhere. | ... | ... |