()
| 23 | ) |
| 24 | |
| 25 | func Example_msg() { |
| 26 | receive := func(msg transport.Msg, err error) error { |
| 27 | if !transport.ReservedOpcode(msg.Opcode) { |
| 28 | fmt.Printf("%s...\n", string(msg.Body[:16])) |
| 29 | } |
| 30 | return nil |
| 31 | } |
| 32 | |
| 33 | ts := httptest.NewServer(msgmux) |
| 34 | defer ts.Close() |
| 35 | |
| 36 | trname := "dummy-msg" |
| 37 | err := transport.HandleMsgStream(trname, receive) |
| 38 | if err != nil { |
| 39 | fmt.Println(err) |
| 40 | return |
| 41 | } |
| 42 | httpclient := transport.NewIntraDataClient() |
| 43 | url := ts.URL + transport.MsgURLPath(trname) |
| 44 | stream := transport.NewMsgStream(httpclient, url, cos.GenTie()) |
| 45 | |
| 46 | stream.Send(&transport.Msg{Body: []byte(lorem)}) |
| 47 | stream.Send(&transport.Msg{Body: []byte(duis)}) |
| 48 | stream.Send(&transport.Msg{Body: []byte(et)}) |
| 49 | stream.Send(&transport.Msg{Body: []byte(temporibus)}) |
| 50 | |
| 51 | stream.Fin() |
| 52 | |
| 53 | // Output: |
| 54 | // Lorem ipsum dolo... |
| 55 | // Duis aute irure ... |
| 56 | // Et harum quidem ... |
| 57 | // Temporibus autem... |
| 58 | } |
| 59 | |
| 60 | func Test_MsgDryRun(t *testing.T) { |
| 61 | tutils.CheckSkip(t, tutils.SkipTestArgs{Long: true}) |
nothing calls this directly
no test coverage detected