<commit_before>package sockjs

/*
Cotains package internal types (not public)
*/

import (
	"errors"
	"io"
)

type context struct {
	Config
	HandlerFunc
	connections
}

type conn struct {
	context
	input_channel    chan []byte
	output_channel   chan []byte
	httpTransactions chan *httpTransaction
}

func newConn(ctx *context) *conn {
	return &conn{
		input_channel:    make(chan []byte),
		output_channel:   make(chan []byte),
		httpTransactions: make(chan *httpTransaction),
		context:          *ctx,
	}
}

func (this *conn) ReadMessage() ([]byte, error) {
	if val, ok := <-this.input_channel; ok {
		return val[1 : len(val)-1], nil
	}
	return []byte{}, io.EOF
}

func (this *conn) WriteMessage(val []byte) (count int, err error) {
	defer func() {
		if recover() != nil {
			err = errors.New("already closed")
		}
	}()
	val2 := make([]byte, len(val))
	copy(val2, val)
	go func() {
		this.output_channel <- val2
	}()
	return len(val), nil
}

func (this *conn) Close() (err error) {
	defer func() {
		if recover() != nil {
			err = errors.New("already closed")
		}
	}()
	close(this.input_channel)<commit_msg>ErrConnectionClosed variable created to reference connection closed state.<commit_after>package sockjs

/*
Cotains package internal types (not public)
*/

import (
	"errors"
	"io"
)

var ErrConnectionClosed = errors.New("Connection closed.")

type context struct {
	Config
	HandlerFunc
	connections
}

type conn struct {
	context
	input_channel    chan []byte
	output_channel   chan []byte
	httpTransactions chan *httpTransaction
}

func newConn(ctx *context) *conn {
	return &conn{
		input_channel:    make(chan []byte),
		output_channel:   make(chan []byte),
		httpTransactions: make(chan *httpTransaction),
		context:          *ctx,
	}
}

func (this *conn) ReadMessage() ([]byte, error) {
	if val, ok := <-this.input_channel; ok {
		return val[1 : len(val)-1], nil
	}
	return []byte{}, io.EOF
}

func (this *conn) WriteMessage(val []byte) (count int, err error) {
	defer func() {
		if recover() != nil {
			err = ErrConnectionClosed
		}
	}()
	val2 := make([]byte, len(val))
	copy(val2, val)
	go func() {
		this.output_channel <- val2
	}()
	return len(val), nil
}

func (this *conn) Close() (err error) {
	defer func() {
		if recover() != nil {
			err = ErrConnectionClosed
		}
	}()
	close(this.input_channel)
{'fraction_non_alphanumeric': 0.1457524795170332, 'fraction_numerical': 0.004312203536006899, 'mean_word_length': 3.8637316561844863, 'pattern_counts': {'":': 0, '<': 7, '<?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': '570248', 'n_tokens_mistral': 854, 'n_tokens_neox': 806, 'n_words': 226}