<commit_before>package websocket

import (
	"time"

	"github.com/gorilla/websocket"
	uuid "github.com/satori/go.uuid"
)

func NewClient(ws *websocket.Conn) *Client {
	return &Client{
		ID:            uuid.NewV4().String(),
		ws:            ws,
		subscriptions: []string{},
	}
}

type Client struct {
	ID            string
	ws            *websocket.Conn
	subscriptions []string
}

func (c *Client) Subscribe(s string, ref uint64) {
	c.subscriptions = append(c.subscriptions, s)
	c.ws.WriteJSON(PhoenixMessage{
		Event: PhxReplyEvent,
		Topic: s,
		Ref:   ref,
		Payload: PhoenixReplyPayload{
			Status:   "ok",
			Response: map[string]string{},
		},
	})
}

func (c *Client) Unsubscribe(s string, ref uint64) {
	var element int
	for i, v := range c.subscriptions {
		if v == s {
			element = i
			break
		}
	}
	if element < len(c.subscriptions) {
		c.subscriptions = append(c.subscriptions[:element], c.subscriptions[element+1:]...)
	}
}
<commit_msg>[backend] added response for socket unsubscribe<commit_after>package websocket

import (
	"time"

	"github.com/gorilla/websocket"
	uuid "github.com/satori/go.uuid"
)

func NewClient(ws *websocket.Conn) *Client {
	return &Client{
		ID:            uuid.NewV4().String(),
		ws:            ws,
		subscriptions: []string{},
	}
}

type Client struct {
	ID            string
	ws            *websocket.Conn
	subscriptions []string
}

func (c *Client) Subscribe(s string, ref uint64) {
	c.subscriptions = append(c.subscriptions, s)
	c.ws.WriteJSON(PhoenixMessage{
		Event: PhxReplyEvent,
		Topic: s,
		Ref:   ref,
		Payload: PhoenixReplyPayload{
			Status:   "ok",
			Response: map[string]string{},
		},
	})
}

func (c *Client) Unsubscribe(s string, ref uint64) {
	var element int
	for i, v := range c.subscriptions {
		if v == s {
			element = i
			break
		}
	}
	if element < len(c.subscriptions) {
		c.subscriptions = append(c.subscriptions[:element], c.subscriptions[element+1:]...)
	}
	c.ws.WriteJSON(PhoenixMessage{
		Event: PhxReplyEvent,
		Topic: s,
		Ref:   ref,
		Payload: PhoenixReplyPayload{
			Status:   "ok",
			Response: map[string]string{},
		},
	})
}

{'fraction_non_alphanumeric': 0.13865147198480532, 'fraction_numerical': 0.005698005698005698, 'mean_word_length': 3.1722772277227724, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '947726', 'n_tokens_mistral': 825, 'n_tokens_neox': 759, 'n_words': 174}