diff --git a/calexium_lib/net_services/CXM_generic_client.anubis b/calexium_lib/net_services/CXM_generic_client.anubis index cb80be1..662e568 100644 --- a/calexium_lib/net_services/CXM_generic_client.anubis +++ b/calexium_lib/net_services/CXM_generic_client.anubis @@ -93,7 +93,7 @@ define Maybe($T) } }. -public define (MessageQueue) -> Maybe($T) +public define (MessageQueue, String) -> Maybe($T) make_generic_handler ( Int32 timeout, @@ -101,7 +101,7 @@ public define (MessageQueue) -> Maybe($T) (Message) -> Maybe($T) handler, (String) -> One logger ) = - (MessageQueue queue) |-> + (MessageQueue queue, String timestamp) |-> generic_handler(queue, timeout, msg_to_send, handler, logger). define Maybe($T) @@ -110,12 +110,12 @@ define Maybe($T) MessageQueue queue, Int32 service_id, Int32 service_version, - (MessageQueue) -> Maybe($T) handler, + (MessageQueue, String) -> Maybe($T) handler, (String) -> One logger )= with test_msg = message(_CXM_REQUEST_FOR_SERVICE), - forget(add_int32(test_msg, "service", service_id)); - forget(add_int32(test_msg, "version", service_version)); + forget(add_int32(test_msg, "SERVICE", service_id)); + forget(add_int32(test_msg, "VERSION", service_version)); queue.add_Message_to_send(test_msg); if queue.get_next_received_Message(10) is { @@ -124,10 +124,20 @@ define Maybe($T) msg(msg) then if find_int32(msg, "STATUS") is { - failure then logger("["+queue.get_name(unique)+"]: requesting service status not found");failure, + failure then logger("["+queue.get_name(unique)+"]: requesting service STATUS not found");failure, success(v) then if v = _CXM_OK then - handler(queue) + if find_message(msg, "RESULT") is + { + failure then logger("["+queue.get_name(unique)+"]: requesting service RESULT not found");failure, + success(result) then + if find_string(msg, "TIMESTAMP") is + { + failure then logger("["+queue.get_name(unique)+"]: requesting service TIMESTAMP not found");failure, + success(timestamp) then + handler(queue, timestamp) + } + } else logger("["+queue.get_name(unique)+"]: requested service started won't start");failure } @@ -141,7 +151,7 @@ public define Maybe($T) Int32 port, Int32 service_id, Int32 service_version, - (MessageQueue) -> Maybe($T) handler, + (MessageQueue, String) -> Maybe($T) handler, (String) -> One logger ) = diff --git a/calexium_lib/net_services/CXM_generic_protocol.anubis b/calexium_lib/net_services/CXM_generic_protocol.anubis index 037d65c..3b6b301 100644 --- a/calexium_lib/net_services/CXM_generic_protocol.anubis +++ b/calexium_lib/net_services/CXM_generic_protocol.anubis @@ -14,9 +14,10 @@ read tools/basis.anubis read system/message_queue.anubis read calexium_lib/CXM_message_constants.anubis -public define Int32 _CXM_OK = 0. -public define Int32 _CXM_ERROR = 1. -public define Int32 _CXM_UNKNOW_CMD = 2. +public define Int32 _CXM_OK = 0. +public define Int32 _CXM_ERROR = 1. +public define Int32 _CXM_UNKNOW_CMD = 2. +public define Int32 _CXM_UNKNOW_SERVICE = 2. public type ProtocolResult: failure, @@ -30,14 +31,26 @@ public define One send_ACK_error ( MessageQueue queue, - Int32 cmd_id + Int32 cmd_id, + Int32 error_code, + String error_string, )= with err_msg = message(_CXM_ACK), forget(add_int32(err_msg, "CMD", cmd_id)); - forget(add_int32(err_msg, "STATUS", _CXM_ERROR)); + forget(add_int32(err_msg, "STATUS", error_code)); + (if error_string /= "" then forget(add_string(err_msg, "STATUS_STR", error_string)) + else unique); forget(queue.add_Message_to_send(err_msg)). public define One + send_ACK_error + ( + MessageQueue queue, + Int32 cmd_id + )= + send_ACK_error(queue, cmd_id, _CXM_ERROR, ""). + +public define One send_ACK_ok ( MessageQueue queue, diff --git a/calexium_lib/net_services/CXM_net_services.anubis b/calexium_lib/net_services/CXM_net_services.anubis index e2d7985..67accae 100644 --- a/calexium_lib/net_services/CXM_net_services.anubis +++ b/calexium_lib/net_services/CXM_net_services.anubis @@ -21,7 +21,7 @@ public type NetService: Int32 version, Int32 id, String name, - (MessageQueue, String) -> One handler + (MessageQueue, String, String) -> One handler // Parameters are MessageQueue, peer IP and timestamp string ). define One @@ -67,16 +67,34 @@ define Maybe(NetService) Message msg, List(NetService) net_services )= - if find_int32(msg, "service") is + if find_int32(msg, "SERVICE") is { - failure then send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE); failure, + failure then //send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE); failure, + // old names... should be removed soon + if find_int32(msg, "service") is + { + failure then send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE); failure, + success(service_id) then + if find_int32(msg, "version") is + { + failure then send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE);failure, + success(service_version) then find_service(net_services, service_id, service_version) + } + } + success(service_id) then - if find_int32(msg, "version") is + if find_int32(msg, "VERSION") is { failure then send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE);failure, success(service_version) then find_service(net_services, service_id, service_version) } }. + +define String + get_time_stamp + = + with time = (UTime) now, + "<"+virtual_machine_id+"@"+time.seconds+">". /** This message_received function just handle the negociation process the available net_services. * In other words, it only recognize the _CXM_REQUEST_FOR_SERVICE message and try to launch the @@ -97,13 +115,16 @@ define One if has_service(queue, msg, net_services) is { failure then - send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE), + send_ACK_error(queue, _CXM_REQUEST_FOR_SERVICE, _CXM_UNKNOW_SERVICE, "Unknown service") success(net_service) then - send_ACK_ok(queue, _CXM_REQUEST_FOR_SERVICE); - net_service.handler(queue, peer) + with result = message(0), + timestamp = get_time_stamp, + forget(add_string(result, "TIMESTAMP", timestamp)); + send_ACK_ok(queue, _CXM_REQUEST_FOR_SERVICE, result); + net_service.handler(queue, peer, timestamp) } else - unique + send_ACK_error(queue, *msg.what, _CXM_UNKNOW_CMD, "Unknown command [" + (*msg.what) + "]") . /** @@ -155,7 +176,6 @@ public define Maybe(Server) Int32 network_port, Var(Bool) shutdown_required )= - //TODO change the port number in the real world if start_server(0, network_port, net_services_handler(net_services), diff --git a/calexium_lib/web/CXM_making_a_web_site.anubis b/calexium_lib/web/CXM_making_a_web_site.anubis index b80cda1..9b35d16 100644 --- a/calexium_lib/web/CXM_making_a_web_site.anubis +++ b/calexium_lib/web/CXM_making_a_web_site.anubis @@ -973,6 +973,7 @@ public define Actioner_Aspect public type TextAreaOption: + input_attrs(List(InputAttrs)), disabled, read_only, wrap_lines. @@ -3547,9 +3548,10 @@ define Printable_tree [] then [], [h . t] then if h is { - disabled then [" disabled " . format1(t)] - read_only then [" readonly " . format1(t)] - wrap_lines then [" wrap " . format1(t)] + input_attrs(input_attr_list) then [format_attrs(input_attr_list) . format1(t)], + disabled then [" disabled=\"disabled\" " . format1(t)] + read_only then [" readonly=\"readonly\" " . format1(t)] + wrap_lines then [" wrap=\"wrap\" " . format1(t)] } }. @@ -3560,7 +3562,7 @@ define Printable_tree ) = if member(l,wrap_lines) then format1(l) - else [" wrap=off " . format1(l)]. + else [" wrap=\"off\" " . format1(l)]. *** [5.7] Formating elements which may be put anywhere. -- libgit2 0.21.4