Compare commits
No commits in common. "master" and "0.0.1" have entirely different histories.
2 changed files with 3 additions and 8 deletions
|
@ -26,7 +26,6 @@ let handle pk =
|
||||||
| None -> printf "unhandled cmd: %d\n%!" pk.cmd; None
|
| None -> printf "unhandled cmd: %d\n%!" pk.cmd; None
|
||||||
|
|
||||||
let rec run ic oc =
|
let rec run ic oc =
|
||||||
let open Packet in
|
|
||||||
let* pk = read ic in
|
let* pk = read ic in
|
||||||
|
|
||||||
let head = Hex.show (Hex.of_string pk.head) in
|
let head = Hex.show (Hex.of_string pk.head) in
|
||||||
|
@ -35,7 +34,7 @@ let rec run ic oc =
|
||||||
printf "packet cmd: %d, head: %s, body: %s\n%!" pk.cmd head body;
|
printf "packet cmd: %d, head: %s, body: %s\n%!" pk.cmd head body;
|
||||||
|
|
||||||
let* () = match handle pk with
|
let* () = match handle pk with
|
||||||
|Some res -> (Lwt_list.iter_s (fun pk -> write oc pk) res.packets)
|
| Some pk -> write oc pk
|
||||||
| None -> return_unit
|
| None -> return_unit
|
||||||
in
|
in
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ open Lwt
|
||||||
open Lwt.Syntax
|
open Lwt.Syntax
|
||||||
|
|
||||||
type packet = { cmd: int; head: string; body: string }
|
type packet = { cmd: int; head: string; body: string }
|
||||||
type net_result = { packets: packet list }
|
|
||||||
|
|
||||||
let read ic =
|
let read ic =
|
||||||
let open Lwt_io in
|
let open Lwt_io in
|
||||||
|
@ -38,9 +37,6 @@ let pack cmd en data =
|
||||||
en data encoder;
|
en data encoder;
|
||||||
|
|
||||||
let buf = Pbrt.Encoder.to_string encoder in
|
let buf = Pbrt.Encoder.to_string encoder in
|
||||||
{ packets = [{ cmd = cmd; head = ""; body = buf; }] }
|
{ cmd = cmd; head = ""; body = buf; }
|
||||||
|
|
||||||
let merge lhs rhs =
|
let empty cmd = { cmd = cmd; head = ""; body = "" }
|
||||||
{ packets = lhs.packets @ rhs.packets }
|
|
||||||
|
|
||||||
let empty cmd = {packets = [{ cmd = cmd; head = ""; body = "" }]}
|
|
||||||
|
|
Loading…
Reference in a new issue