this repo has no description
at main 1.2 kB view raw
1open Swim.Types 2 3let hex_of_string s = 4 String.to_seq s 5 |> Seq.map (fun c -> Printf.sprintf "%02x" (Char.code c)) 6 |> List.of_seq |> String.concat "" 7 8let () = 9 let node = 10 make_node_info 11 ~id:(node_id_of_string "test-node") 12 ~addr:(`Udp (Eio.Net.Ipaddr.of_raw "\127\000\000\001", 7947)) 13 ~meta:"" 14 in 15 let ping = 16 Ping { seq = 1; target = node_id_of_string "go-node"; sender = node } 17 in 18 19 let wire_msg = msg_to_wire ~self_name:"ocaml-node" ~self_port:7947 ping in 20 Printf.printf "Wire message type: %s\n" 21 (match wire_msg with 22 | Wire.Ping _ -> "Ping" 23 | Wire.Indirect_ping _ -> "Indirect_ping" 24 | Wire.Ack _ -> "Ack" 25 | Wire.Nack _ -> "Nack" 26 | Wire.Suspect _ -> "Suspect" 27 | Wire.Alive _ -> "Alive" 28 | Wire.Dead _ -> "Dead" 29 | Wire.User_data _ -> "User_data" 30 | Wire.Compound _ -> "Compound" 31 | Wire.Compressed _ -> "Compressed" 32 | Wire.Err _ -> "Err"); 33 34 let encoded = 35 Swim.Codec.encode_internal_msg ~self_name:"ocaml-node" ~self_port:7947 ping 36 in 37 Printf.printf "Encoded length: %d bytes\n" (String.length encoded); 38 Printf.printf "Encoded hex: %s\n" (hex_of_string encoded); 39 Printf.printf "First byte (msg type): %d\n" (Char.code encoded.[0])