forked from cory/tildefriends
		
	Make print more of a standard RPC thing.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3959 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
		| @@ -16,8 +16,7 @@ let gOriginalInput; | ||||
| let kErrorColor = "#dc322f"; | ||||
| let kStatusColor = "#fff"; | ||||
|  | ||||
| /* Functions that server-side app code can call through app.setDocument()-style | ||||
|  * calls. */ | ||||
| /* Functions that server-side app code can call through the app object. */ | ||||
| const k_api = { | ||||
| 	setDocument: {args: ['content'], func: api_setDocument}, | ||||
| 	postMessage: {args: ['message'], func: api_postMessage}, | ||||
| @@ -25,6 +24,7 @@ const k_api = { | ||||
| 	localStorageSet: {args: ['key', 'value'], func: api_localStorageSet}, | ||||
| 	localStorageGet: {args: ['key'], func: api_localStorageGet}, | ||||
| 	requestPermission: {args: ['permission', 'id'], func: api_requestPermission}, | ||||
| 	print: {args: ['...'], func: api_print}, | ||||
| }; | ||||
|  | ||||
| window.addEventListener("keydown", function(event) { | ||||
| @@ -500,7 +500,11 @@ function api_requestPermission(permission, id) { | ||||
| 	}); | ||||
| } | ||||
|  | ||||
| function receive(message) { | ||||
| function api_print() { | ||||
| 	console.log('app>', ...arguments); | ||||
| } | ||||
|  | ||||
| function _receive_websocket_message(message) { | ||||
| 	if (message && message.action == "session") { | ||||
| 		setStatusMessage("🟢 Executing...", kStatusColor); | ||||
| 		gCredentials = message.credentials; | ||||
| @@ -520,8 +524,6 @@ function receive(message) { | ||||
| 		} | ||||
| 	} else if (message && message.action == "ping") { | ||||
| 		send({action: "pong"}); | ||||
| 	} else if (message && message.action == "print") { | ||||
| 		console.log('app>', ...message.args); | ||||
| 	} else if (message && message.action == "stats") { | ||||
| 		let now = new Date().getTime(); | ||||
| 		for (let key of Object.keys(message.stats)) { | ||||
| @@ -839,7 +841,7 @@ function connectSocket(path) { | ||||
| 			})); | ||||
| 		} | ||||
| 		gSocket.onmessage = function(event) { | ||||
| 			receive(JSON.parse(event.data)); | ||||
| 			_receive_websocket_message(JSON.parse(event.data)); | ||||
| 		} | ||||
| 		gSocket.onclose = function(event) { | ||||
| 			const k_codes = { | ||||
|   | ||||
| @@ -268,7 +268,7 @@ async function getProcessBlob(blobId, key, options) { | ||||
| 				} | ||||
| 			} | ||||
| 			process.task.onPrint = function(args) { | ||||
| 				process.app.send({action: 'print', args: args}); | ||||
| 				imports.app.print(...args); | ||||
| 			}; | ||||
| 			process.task.onError = function(error) { | ||||
| 				try { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user