mirror of
https://github.com/gen2brain/cam2ip.git
synced 2025-12-16 04:18:39 +00:00
Move context
This commit is contained in:
@@ -32,6 +32,8 @@ func (s *Socket) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
for {
|
||||
img, err := s.reader.Read()
|
||||
if err != nil {
|
||||
@@ -49,7 +51,7 @@ func (s *Socket) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
b64 := image.EncodeToString(w.Bytes())
|
||||
|
||||
err = conn.Write(context.Background(), websocket.MessageText, []byte(b64))
|
||||
err = conn.Write(ctx, websocket.MessageText, []byte(b64))
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user