| 517 | } |
| 518 | |
| 519 | func (w *websocketWriter) writeCtrlFrames() (int, error) { |
| 520 | var ( |
| 521 | n int |
| 522 | total int |
| 523 | i int |
| 524 | err error |
| 525 | ) |
| 526 | for ; i < len(w.ctrlFrames); i++ { |
| 527 | buf := w.ctrlFrames[i] |
| 528 | n, err = w.w.Write(buf) |
| 529 | total += n |
| 530 | if err != nil { |
| 531 | break |
| 532 | } |
| 533 | } |
| 534 | if i != len(w.ctrlFrames) { |
| 535 | w.ctrlFrames = w.ctrlFrames[i+1:] |
| 536 | } else { |
| 537 | w.ctrlFrames = w.ctrlFrames[:0] |
| 538 | } |
| 539 | return total, err |
| 540 | } |
| 541 | |
| 542 | func (w *websocketWriter) writeCloseMsg() (int, error) { |
| 543 | n, err := w.w.Write(w.cm) |