Method
addMessage
(op byte, payload []byte, isClient bool, t time.Time)
Source from the content-addressed store, hash-verified
| 628 | } |
| 629 | |
| 630 | func (w *websocket) addMessage(op byte, payload []byte, isClient bool, t time.Time) { |
| 631 | w.mu.Lock() |
| 632 | defer w.mu.Unlock() |
| 633 | |
| 634 | data := "" |
| 635 | if op == wsOpcodeText { |
| 636 | data = string(payload) |
| 637 | } else { |
| 638 | data = base64.StdEncoding.EncodeToString(payload) |
| 639 | } |
| 640 | |
| 641 | var dir string |
| 642 | if (isClient && w.isOutgoing) || (!isClient && !w.isOutgoing) { |
| 643 | dir = "send" |
| 644 | } else { |
| 645 | dir = "receive" |
| 646 | } |
| 647 | |
| 648 | w.msgs = append(w.msgs, &tracer.WebsocketMessage{ |
| 649 | Type: dir, |
| 650 | Time: float64(t.UnixNano()) / 1e9, |
| 651 | Opcode: int(op), |
| 652 | Data: data, |
| 653 | }) |
| 654 | } |
| 655 | |
| 656 | func (w *websocket) getMessages() []*tracer.WebsocketMessage { |
| 657 | w.mu.RLock() |
Tested by
no test coverage detected