<commit_before>var intervalId,
	handleReceptacle = {},

	// This is the same value as server.get.js
	sampleUri = "/a/iotivity-node-observe-sample",
	iotivity = require( "iotivity" ),
	currentData = {};

// Start iotivity and set up the processing loop
iotivity.OCInit( null, 0, iotivity.OCMode.OC_SERVER );

iotivity.OCSetDeviceInfo( { deviceName: "server.observable" } );
iotivity.OCSetPlatformInfo( {
	platformID: "server.observe.sample",
	manufacturerName: "iotivity-node"
} );

intervalId = setInterval( function() {
	iotivity.OCProcess();
}, 1000 );

require( "./mock-sensor" )().on( "change", function( data ) {
	console.log( "Sensor data has changed. Notifying all observers." );
	currentData = data;
	iotivity.OCNotifyAllObservers(
		handleReceptacle.handle,
		iotivity.OCQualityOfService.OC_HIGH_QOS );
} );

// Create a new resource
iotivity.OCCreateResource(

	// The bindings fill in this object
	handleReceptacle,

	"core.fan",
	iotivity.OC_RSRVD_INTERFACE_DEFAULT,
	sampleUri,
	function( flag, request ) {
		console.log( "Entity handler called with flag = " + flag + " and the following request:" );
		console.log( JSON.stringify( request, null, 4 ) );

		iotivity.OCDoResponse( {
			requestHandle: request.requestHandle,
			resourceHandle: request.resource,
			ehResult: iotivity.OCEntityHandlerResult.OC_EH_OK,
			payload: {
				type: iotivity.OCPayloadType.PAYLOAD_TYPE_REPRESENTATION,
				values: currentData
			},
			resourceUri: sampleUri,
			sendVendorSpecificHeaderOptions: []
		} );<commit_msg>Examples: Switch observation example to list notification<commit_after>var intervalId,
	handleReceptacle = {},
	observerIds = [],

	// This is the same value as server.get.js
	sampleUri = "/a/iotivity-node-observe-sample",
	iotivity = require( "iotivity" );

// Start iotivity and set up the processing loop
iotivity.OCInit( null, 0, iotivity.OCMode.OC_SERVER );

iotivity.OCSetDeviceInfo( { deviceName: "server.observable" } );
iotivity.OCSetPlatformInfo( {
	platformID: "server.observe.sample",
	manufacturerName: "iotivity-node"
} );

intervalId = setInterval( function() {
	iotivity.OCProcess();
}, 1000 );

require( "./mock-sensor" )().on( "change", function( data ) {
	console.log( "Sensor data has changed. " +
		( observerIds.length > 0
			? "Notifying " + observerIds.length + " observers."
			: "No observers in list." ) );
	if ( observerIds.length > 0 ) {
		iotivity.OCNotifyListOfObservers(
			handleReceptacle.handle,
			observerIds,
			{
				type: iotivity.OCPayloadType.PAYLOAD_TYPE_REPRESENTATION,
				values: data
			},
			iotivity.OCQualityOfService.OC_HIGH_QOS );
	}
} );

// Create a new resource
iotivity.OCCreateResource(

	// The bindings fill in this object
	handleReceptacle,

	"core.fan",
	iotivity.OC_RSRVD_INTERFACE_DEFAULT,
	sampleUri,
	function( flag, request ) {
		var observerIdIndex;

		console.log( "Entity handler called with flag = " + flag + " and the following request:" );
		console.log( JSON.stringify( request, null, 4 ) );

		if ( flag & iotivity.OCEntityHandlerFlag.OC_OBSERVE_FLAG ) {
			if ( request.obsInfo.obsId !== 0 ) {
				if ( request.obsInfo.action === iotivity.OCObserveAction.OC_OBSERVE_REGISTER ) {

					// Add new observer to list.
					observerIds.push( request.obsInfo.obsId );
				} else if ( request.obsInfo.action ===
						iotivity.OCObserveAction.OC_OBSERVE_DEREGISTER ) {

					// Remove requested observer from list.
					observerIdIndex = observerIds.indexOf( request.obsInfo.obsId );
					if ( observerIdIndex >= 0 ) {
						observerIds.splice( observerIdIndex, 1 );
					}
				}
			}

			iotivity.OCDoResponse( {
				requestHandle: request.requestHandle,
				resourceHandle: request.resource,
				ehResult: iotivity.OCEntityHandlerResult.OC_EH_OK,
				payload: null,
				resourceUri: sampleUri,
				sendVendorSpecificHeaderOptions: []
			} );
		}
{'fraction_non_alphanumeric': 0.12186847599164927, 'fraction_numerical': 0.004436325678496869, 'mean_word_length': 4.036793692509855, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '4404413', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1249, 'n_words': 269}