<commit_before>require! {
	fs
	cookie
	redis
	'../../config': config
	'express-session': session
}
exports = (io, session-store) ->
	io.of '/streaming/talk' .on \connection (socket) ->
		cookies = cookie.parse socket.handshake.headers.cookie
		sid = cookies[config.session-key]

		sidkey = sid.match /s:(.+?)\./ .1
		session-store.get sidkey, (err, session) ->
			if err
				console.log err.message
			else
				if !session?
					console.log 'undefined: ' + sidkey
				else
					uid = socket.user-id = session.user-id
					publisher = redis.create-client!
					socket
						..emit \connected
						..on \init (req) ->
							otherparty-id = String req.otherparty_id
							socket.otherparty-id = otherparty-id
							subscriber = redis.create-client!
								..subscribe 'misskey:talkStream:' + uid + '-' + socket.otherparty-id
							publisher.publish 'misskey:talkStream:' + socket.otherparty-id + '-' + uid, \otherpartyEnterTheTalk
							socket.emit \inited
							subscriber.on \message (channel, content) ->
								try
									content = JSON.parse content
									if content.type? && content.value?
										then socket.emit content.type, content.value
										else socket.emit content
								catch e
									socket.emit content
						..on \rea' (id) ->
							publisher.publish 'misskey:talkStream:' + socket.otherparty-id + '-' + uid, JSON.stringify do
								type: \read
								value: id
						..on \alive (req) ->
							publisher.publish 'misskey:talkStream:' + socket.otherparty-id + '-' + uid, \alive
						..on \type (text) ->
							publisher.publish 'misskey:talkStream:' + socket.otherparty-id + '-' + uid, JSON.stringify do
								type: \type
								value: text
						.on \disconnect ->
						publisher.publish 'misskey:talkStream:' + socket.otherpartyId + '-' + uid, \otherpartyLeftTheTalk<commit_msg>Fix bug<commit_after>require! {
	fs
	cookie
	redis
	'../../config': config
	'express-session': session
}
exports = (io, session-store) ->
	io.of '/streaming/talk' .on \connection (socket) ->
		cookies = cookie.parse socket.handshake.headers.cookie
		sid = cookies[config.session-key]

		sidkey = sid.match /s:(.+?)\./ .1
		session-store.get sidkey, (err, session) ->
			if err
				console.log err.message
			else
				if !session?
					console.log 'undefined: ' + sidkey
				else
					uid = socket.user-id = session.user-id
					publisher = redis.create-client!
					socket
						..emit \connected
						..on \init (req) ->
							otherparty-id = String req.otherparty_id
							socket.otherparty-id = otherparty-id
							subscriber = redis.create-client!
								..subscribe 'misskey:talkStream:' + uid + '-' + socket.otherparty-id
							publisher.publish 'misskey:talkStream:' + socket.otherparty-id + '-' + uid, \otherpartyEnterTheTalk
							socket.emit \inited
							subscriber.on \message (channel, content) ->
								try
									content = JSON.parse content
									if content.type? && content.value?
										then socket.emit content.type, content.value
										else socket.emit content
								catch e
									socket.emit content
						..on \read (id) ->
							publisher.publish 'misskey:talkStream:' + socket.otherparty-id + '-' + uid, JSON.stringify do
								type: \read
								value: id
						..on \alive (req) ->
							publisher.publish 'misskey:talkStream:' + socket.otherparty-id + '-' + uid, \alive
						..on \type (text) ->
							publisher.publish 'misskey:talkStream:' + socket.otherparty-id + '-' + uid, JSON.stringify do
								type: \type
								value: text
						.on \disconnect ->
						publisher.publish 'misskey:talkStream:' + socket.otherpartyId + '-' + uid, \otherpartyLeftTheTalk
{'fraction_non_alphanumeric': 0.13703501094091905, 'fraction_numerical': 0.0005470459518599562, 'mean_word_length': 2.2945945945945945, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '4592391', 'n_tokens_mistral': 1561, 'n_tokens_neox': 1124, 'n_words': 264}