<commit_before>var intervalId,
	handleReceptacle = {},

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

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

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

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

iotivity.OCStartPresence( 0 );

// 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 ) );
		return iotivity.OCEntityHandlerResult.OC_EH_OK;
	},
	iotivity.OCResourceProperty.OC_DISCOVERABLE );

// Exit gracefully when interrupted
process.on( "SIGINT", function() {
	console.log( "SIGINT: Quitting..." );

	// Tear down the processing loop and stop iotivity
	clearInterval( intervalId );
	iotivity.OCDeleteResource( handleReceptacle.handle );
	iotivity.OCStopPresence();
	iotivity.OCStop();

	// Exit
	process.exit( 0 );
} );
<commit_msg>Examples: Use SIGINT to turn presence on/off in presence example server<commit_after>var intervalId,
	handleReceptacle = {},

	// This is the same value as client.presence.js
	sampleUri = "/a/iotivity-node-presence-sample",
	interruptSequence = 0,
	iotivity = require( "iotivity" );

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

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

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

console.log( "The first SIGINT will start presence.\nThe second SIGINT will stop presence.\n" +
	"The third SIGINT will quit the server." );

// 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 ) );
		return iotivity.OCEntityHandlerResult.OC_EH_OK;
	},
	iotivity.OCResourceProperty.OC_DISCOVERABLE );

// Exit gracefully when interrupted
process.on( "SIGINT", function() {
	if ( interruptSequence === 0 ) {
		console.log( "\nSIGINT: Starting presence..." );

		iotivity.OCStartPresence( 0 );
	} else if ( interruptSequence === 1 ) {
		console.log( "\nSIGINT: Stopping presence..." );

		iotivity.OCStopPresence();
	} else {
		console.log( "\nSIGINT: Quitting..." );

		// Tear down the processing loop and stop iotivity
		clearInterval( intervalId );
		iotivity.OCDeleteResource( handleReceptacle.handle );
		iotivity.OCStopPresence();
		iotivity.OCStop();

		// Exit
		process.exit( 0 );
	}
	interruptSequence++;
} );

{'fraction_non_alphanumeric': 0.1280940594059406, 'fraction_numerical': 0.005878712871287129, 'mean_word_length': 4.451939291736931, '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': '5142089', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1042, 'n_words': 261}