<commit_before>package MQTTg

type Edge interface {
	recvConnectMessage(*ConnectMessage, *Client) error
	recvConnackMessage(*ConnackMessage, *Client) error
	recvPublishMessage(*PublishMessage, *Client) error
	recvPubackMessage(*PubackMessage, *Client) error
	recvPubrecMessage(*PubrecMessage, *Client) error
	recvPubrelMessage(*PubrelMessage, *Client) error
	recvPubcompMessage(*PubcompMessage, *Client) error
	recvSubscribeMessage(*SubscribeMessage, *Client) error
	recvSubackMessage(*SubackMessage, *Client) error
	recvUnsubscribeMessage(*UnsubscribeMessage, *Client) error
	recvUnsubackMessage(*UnsubackMessage, *Client) error
	recvPingreqMessage(*PingreqMessage, *Client) error
	recvPingrespMessage(*PingrespMessage, *Client) error
	recvDisconnectMessage(*DisconnectMessage, *Client) error
	ReadMessage() (Message, error)
}

func ReadLoop(edge Edge, c *Client) error {
	for {
		m, err := edge.ReadMessage()
		if err != nil {
			EmitError(err)
			continue
		}
		switch m := m.(type) {
		case *ConnectMessage:
			err = edge.recvConnectMessage(m, c)
		case *ConnackMessage:
			err = edge.recvConnackMessage(m, c)
		case *PublishMessage:
			err = edge.recvPublishMessage(m, c)
		case *PubackMessage:
			err = edge.recvPubackMessage(m, c)
		case *PubrecMessage:
			err = edge.recvPubrecMessage(m, c)
		case *PubrelMessage:
			err = edge.recvPubrelMessage(m, c)
		case *PubcompMessage:
			err = edge.recvPubcompMessage(m, c)
		case *SubscribeMessage:
			err = edge.recvSubscribeMessage(m, c)
		case *SubackMessage:
			err = edge.recvSubackMessage(m, c)
		case *UnsubscribeMessage:
			err = edge.recvUnsubscribeMessage(m, c)
		case *UnsubackMessage:
			err = edge.recvUnsubackMessage(m, c)
		case *PingreqMessage:
			err = edge.recvPingreqMessage(m, c)
		case *PingrespMessage:
			err = edge.recvPingrespMessage(m, c)
		case *DisconnectMessage:
			err = edge.recvDisconnectMessage(m, c)

		}
		EmitError(err)
	}
}<commit_msg>fix bug<commit_after>package MQTTg

type Edge interface {
	recvConnectMessage(*ConnectMessage, *Client) error
	recvConnackMessage(*ConnackMessage, *Client) error
	recvPublishMessage(*PublishMessage, *Client) error
	recvPubackMessage(*PubackMessage, *Client) error
	recvPubrecMessage(*PubrecMessage, *Client) error
	recvPubrelMessage(*PubrelMessage, *Client) error
	recvPubcompMessage(*PubcompMessage, *Client) error
	recvSubscribeMessage(*SubscribeMessage, *Client) error
	recvSubackMessage(*SubackMessage, *Client) error
	recvUnsubscribeMessage(*UnsubscribeMessage, *Client) error
	recvUnsubackMessage(*UnsubackMessage, *Client) error
	recvPingreqMessage(*PingreqMessage, *Client) error
	recvPingrespMessage(*PingrespMessage, *Client) error
	recvDisconnectMessage(*DisconnectMessage, *Client) error
	ReadMessage() (Message, error)
}

func ReadLoop(edge Edge, c *Client) (err error) {
	var m Message
	for {
		EmitError(err)
		// TODO: not cool
		if c == nil {
			m, err = edge.ReadMessage()
		} else {
			m, err = c.ReadMessage()
		}
		if err != nil {
			EmitError(err)
			continue
		}
		switch m := m.(type) {
		case *ConnectMessage:
			err = edge.recvConnectMessage(m, c)
		case *ConnackMessage:
			err = edge.recvConnackMessage(m, c)
		case *PublishMessage:
			err = edge.recvPublishMessage(m, c)
		case *PubackMessage:
			err = edge.recvPubackMessage(m, c)
		case *PubrecMessage:
			err = edge.recvPubrecMessage(m, c)
		case *PubrelMessage:
			err = edge.recvPubrelMessage(m, c)
		case *PubcompMessage:
			err = edge.recvPubcompMessage(m, c)
		case *SubscribeMessage:
			err = edge.recvSubscribeMessage(m, c)
		case *SubackMessage:
			err = edge.recvSubackMessage(m, c)
		case *UnsubscribeMessage:
			err = edge.recvUnsubscribeMessage(m, c)
		case *UnsubackMessage:
			err = edge.recvUnsubackMessage(m, c)
		case *PingreqMessage:
			err = edge.recvPingreqMessage(m, c)
		case *PingrespMessage:
			err = edge.recvPingrespMessage(m, c)
		case *DisconnectMessage:
			err = edge.recvDisconnectMessage(m, c)

		}
	}
}
{'fraction_non_alphanumeric': 0.10893854748603352, 'fraction_numerical': 0.0, 'mean_word_length': 5.3841166936790925, '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': '427177', 'n_tokens_mistral': 1448, 'n_tokens_neox': 1337, 'n_words': 293}