Commit 9e42b33744e813f1e9dafdb2ba21ee0aebe1e0c7
1 parent
507b82f6
add send_message_by_Stream in muscle.anubis. This function send the message thro…
…ugh the tcp/ip channel
Showing
1 changed file
with
27 additions
and
1 deletions
Show diff stats
anubis_dev/library/system/muscle.anubis
| ... | ... | @@ -1531,7 +1531,7 @@ public define Maybe(ByteArray) |
| 1531 | 1531 | /********************** I/O socket *****************************/ |
| 1532 | 1532 | |
| 1533 | 1533 | /** |
| 1534 | - * create the right udp socket. deterline if we must create broadcast | |
| 1534 | + * create the right udp socket. determine if we must create broadcast | |
| 1535 | 1535 | * or not udp socket |
| 1536 | 1536 | */ |
| 1537 | 1537 | |
| ... | ... | @@ -1580,6 +1580,32 @@ public define Message_Send_Result |
| 1580 | 1580 | } |
| 1581 | 1581 | }. |
| 1582 | 1582 | |
| 1583 | +public define Message_Send_Result | |
| 1584 | + send_message_by_Stream | |
| 1585 | + ( | |
| 1586 | + RWStream conn, | |
| 1587 | + Message msg | |
| 1588 | + )= | |
| 1589 | + if flatten_message(msg) is | |
| 1590 | + { | |
| 1591 | + failure then println("Error flattening identity Message"); flatten_error, | |
| 1592 | + success(buffer) then | |
| 1593 | + with header = host_to_lendian_Int32_ByteArray(length(buffer)) + | |
| 1594 | + host_to_lendian_Int32_ByteArray(_MUSCLE_MESSAGE_ENCODING_DEFAULT), | |
| 1595 | + //send the header. that header is construct as follow (size of the following message + header mark) | |
| 1596 | + if write(weaken(conn),header) is | |
| 1597 | + { | |
| 1598 | + failure then network_error, | |
| 1599 | + success(_) then | |
| 1600 | + //now we send the real message | |
| 1601 | + if write(weaken(conn), buffer) is | |
| 1602 | + { | |
| 1603 | + failure then network_error, | |
| 1604 | + success(_) then ok | |
| 1605 | + } | |
| 1606 | + } | |
| 1607 | + }. | |
| 1608 | + | |
| 1583 | 1609 | |
| 1584 | 1610 | /********************** TESTING SERVER *************************/ |
| 1585 | 1611 | ... | ... |