<commit_before>part of couclient;

bool _metadataEqual(Map metaA, Map metaB) {
	if ((metaA == null && metaB == null) ||
	    (metaA.isEmpty && metaB.isEmpty)) {
		return true;
	}
//	//metadata is only used to store slots right now, so check that
//	if (metaA['slots'] != null && metaB['slots'] != null) {
//		List<Map> slotsA = metaA['slots'];
//		List<Map> slotsB = metaB['slots'];
//		if (slotsA.length == slotsB.length) {
//			for (int i = 0; i < slotsA.length; i++) {
//				Map slotA = slotsA[i];
//				Map slotB = slotsB[i];
//				if (slotA['itemType'] != slotB['itemType'] ||
//				    slotA['count'] != slotB['count']) {
//					return false;
//				}
//			}
//		}
//	}
	return JSON.encode(metaA) == JSON.encode(metaB);
//	return true;
}

_setupStreetSocket(String streetName) {
	//start a timer for a few seconds and then show the server down message if not canceled
	Timer serverDownTimer = new Timer(new Duration(seconds: 10), () {
		querySelector('#server-down').hidden = false;
		serverDown = true;
	});
	streetSocket = new WebSocket(streetEventServer);

	streetSocket.onOpen.listen((_) {
		querySelector('#server-down').hidden = true;
		serverDownTimer.cancel();
		if (serverDown) {
			window.location.reload();
		}
		sendJoinedMessage(streetName);
	});
	streetSocket.onMessage.listen((MessageEvent event) {
		Map map = JSON.decode(event.data);
		if (map['error'] != null) {
			reconnect = false;
			logmessage('[Multiplayer (Street)] Error ${map['error']}');
			streetSocket.close();
			return;
		}

		if (map['label'] != null && currentStreet.label != map['label']) {
			return;
		}

		//check if we are receiving our inventory
		if (map['inventory'] != null) {
			updateInventory(map);
			return;
		}

		if (map['vendorName'] == 'Auctioneer') {
			new AuctionWindow().open();
			return;
		}
		if (map['openWindow'] != null) {
			if (map['openWindow'] == 'vendorSell') new VendorWindow().call(map, sellMode: true);
			if (map['openWindow'] == 'mailbox') new MailboxWindow().open();
			if (map['openWindow'] == 'itemChooser') {
				Function feedPig = ({String itemType, int count}) {
					Map arguments = {'itemType':itemType, 'count': count};
					sendAction('feedItem', map['id'], arguments);
				};
				//feedPig will be called when the itemChooser window (and how many picker) is finished
				new ItemChooser(map['windowTitle'], feedPig, filter: map['filter']);
			}
			return;
		}
		if (map['itemsForSale'] != null) {
			new VendorWindow().call(map);
			return;
		}
		if (map['giantName'] != null) {<commit_msg>item choosers are not specific to piggies<commit_after>part of couclient;

bool _metadataEqual(Map metaA, Map metaB) {
	if ((metaA == null && metaB == null) ||
	    (metaA.isEmpty && metaB.isEmpty)) {
		return true;
	}
//	//metadata is only used to store slots right now, so check that
//	if (metaA['slots'] != null && metaB['slots'] != null) {
//		List<Map> slotsA = metaA['slots'];
//		List<Map> slotsB = metaB['slots'];
//		if (slotsA.length == slotsB.length) {
//			for (int i = 0; i < slotsA.length; i++) {
//				Map slotA = slotsA[i];
//				Map slotB = slotsB[i];
//				if (slotA['itemType'] != slotB['itemType'] ||
//				    slotA['count'] != slotB['count']) {
//					return false;
//				}
//			}
//		}
//	}
	return JSON.encode(metaA) == JSON.encode(metaB);
//	return true;
}

_setupStreetSocket(String streetName) {
	//start a timer for a few seconds and then show the server down message if not canceled
	Timer serverDownTimer = new Timer(new Duration(seconds: 10), () {
		querySelector('#server-down').hidden = false;
		serverDown = true;
	});
	streetSocket = new WebSocket(streetEventServer);

	streetSocket.onOpen.listen((_) {
		querySelector('#server-down').hidden = true;
		serverDownTimer.cancel();
		if (serverDown) {
			window.location.reload();
		}
		sendJoinedMessage(streetName);
	});
	streetSocket.onMessage.listen((MessageEvent event) {
		Map map = JSON.decode(event.data);
		if (map['error'] != null) {
			reconnect = false;
			logmessage('[Multiplayer (Street)] Error ${map['error']}');
			streetSocket.close();
			return;
		}

		if (map['label'] != null && currentStreet.label != map['label']) {
			return;
		}

		//check if we are receiving our inventory
		if (map['inventory'] != null) {
			updateInventory(map);
			return;
		}

		if (map['vendorName'] == 'Auctioneer') {
			new AuctionWindow().open();
			return;
		}
		if (map['openWindow'] != null) {
			if (map['openWindow'] == 'vendorSell') new VendorWindow().call(map, sellMode: true);
			if (map['openWindow'] == 'mailbox') new MailboxWindow().open();
			if (map['openWindow'] == 'itemChooser') {
				Function callback = ({String itemType, int count}) {
					Map arguments = {'itemType':itemType, 'count': count};
					sendAction(map["action"], map['id'], arguments);
				};
				new ItemChooser(map['windowTitle'], callback, filter: map['filter']);
			}
			return;
		}
		if (map['itemsForSale'] != null) {
			new VendorWindow().call(map);
			return;
		}
		if (map['giantName'] != null) {
{'fraction_non_alphanumeric': 0.1840736294517807, 'fraction_numerical': 0.0012004801920768306, 'mean_word_length': 3.658900279589935, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '124758', 'n_tokens_mistral': 1928, 'n_tokens_neox': 1695, 'n_words': 410}