You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: client_events.go
    path of file: ./repos/cds/sdk/cdsclient
    
    the code of the file until where you have to start completion: package cdsclient

import (
	"context"
	"encoding/json"
	"fmt"
	"time"

	"github.com/rockbears/log"

	"github.com/ovh/cds/sdk"
)

func (c *client) WebsocketEventsListen(ctx context.Context, goRoutines *sdk.GoRoutines, chanFilterToSend <-chan []sdk.WebsocketFilter, chanEventReceived chan<- sdk.WebsocketEvent, chanErrorReceived chan<- error) {
	chanMsgReceived := make(chan json.Raw
    
func (c *client) WebsocketEventsListen(ctx context.Context, goRoutines *sdk.GoRoutines, chanFilterToSend <-chan []sdk.WebsocketFilter, chanEventReceived chan<- sdk.WebsocketEvent, chanErrorReceived chan<- error) {
	chanMsgReceived := make(chan json.RawMessage)
	chanMsgToSend := make(chan json.RawMessage)

	goRoutines.Exec(ctx, "WebsocketEventsListen", func(ctx context.Context) {
		for {
			select {
			case <-ctx.Done():
				if ctx.Err() != nil {
					log.ErrorWithStackTrace(ctx, ctx.Err())
				}
				return
			case f := <-chanFilterToSend:
				m, err := json.Marshal(f)
				if err != nil {
					chanErrorReceived <- newError(fmt.Errorf("unable to marshal message: %s: %v", string(m), err))
					continue
				}
				chanMsgToSend <- m
			case m := <-chanMsgReceived:
				var wsEvent sdk.WebsocketEvent
				if err := sdk.JSONUnmarshal(m, &wsEvent); err != nil {
					chanErrorReceived <- newError(fmt.Errorf("unable to unmarshal message: %s: %v", string(m), err))
					continue
				}
				chanEventReceived <- wsEvent
			}
		}
	})

	for ctx.Err() == nil {
		if err := c.RequestWebsocket(ctx, goRoutines, "/ws", chanMsgToSend, chanMsgReceived, chanErrorReceived); err != nil {
			chanErrorReceived <- newError(fmt.Errorf("websocket error: %v", err))
		}
		time.Sleep(1 * time.Second)

	}
}