<commit_before>package events

import (
	"log"
	"time"

	"github.com/byuoitav/central-event-system/hub/base"
	"github.com/byuoitav/central-event-system/messenger"
	"github.com/byuoitav/common/v2/events"
	"github.com/byuoitav/touchpanel-ui-microservice/socket"
	"github.com/fatih/color"
)

// Message is a message down a websocket
type Message struct {
	Message string `json:"message"`
}

func WriteEventsToSocket(m *messenger.Messenger) {
	for {
		event, err := base.UnwrapEvent(m.ReceiveEvent())
		if err != nil {
			log.Printf("unable to write an event to the socket: %s", err.Error())
		}

		// TODO decide what to filter out
		// filter out heartbeat events (and whatever else)
		if events.HasTag(event, events.Heartbeat) {
			continue
		}

		socket.H.WriteToSockets(event)
	}
}

func SendScreenTimeout() {
	socket.H.WriteToSockets(Message{Message: "screenoff"})
}

func SendRefresh(delay *time.Timer) {
	defer color.Unset()<commit_msg>use messenger changes<commit_after>package events

import (
	"log"
	"time"

	"github.com/byuoitav/central-event-system/messenger"
	"github.com/byuoitav/common/v2/events"
	"github.com/byuoitav/touchpanel-ui-microservice/socket"
	"github.com/fatih/color"
)

// Message is a message down a websocket
type Message struct {
	Message string `json:"message"`
}

func WriteEventsToSocket(m *messenger.Messenger) {
	for {
		event := m.ReceiveEvent()

		// TODO decide what to filter out
		// filter out heartbeat events (and whatever else)
		if events.HasTag(event, events.Heartbeat) {
			continue
		}

		socket.H.WriteToSockets(event)
	}
}

func SendScreenTimeout() {
	socket.H.WriteToSockets(Message{Message: "screenoff"})
}

func SendRefresh(delay *time.Timer) {
	defer color.Unset()
{'fraction_non_alphanumeric': 0.1292952824694234, 'fraction_numerical': 0.0011648223645894002, 'mean_word_length': 4.35202492211838, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2174636', 'n_tokens_mistral': 650, 'n_tokens_neox': 602, 'n_words': 126}