Methods

์†Œ๊ฐœ

App์—์„œ ์œ„์ ฏ์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๋‚ด๊ฑฐ๋‚˜, ์œ„์ ฏ์„ ํŒŒ๊ดดํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

๐Ÿ“š API ์„ค๋ช… ๋ฐ ์˜ˆ์ œ

Methods ํ•จ์ˆ˜ ํ•œ ๋ˆˆ์— ๋ณด๊ธฐ

// ์ƒ์„ฑํ•œ ์œ„์ ฏ์— ๋ฉ”์„ธ์ง€๋ฅผ ๋ณด๋ƒ„
widget.sendMessage(object: any)

// ์œ„์ ฏ์„ ์ œ๊ฑฐ
widget.destroy()

sendMessage

widget.sendMessage(object: any)

App์—์„œ ์œ„์ ฏ์œผ๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๋ƒ…๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์˜ˆ์ œ

์œ„์ ฏ์— ํ…์ŠคํŠธ์™€ ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ ๋ณด๋‚ด๊ธฐ


// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ž…์žฅํ•  ๋•Œ ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜
App.onJoinPlayer.Add(function (player) {
	player.tag = {
		widget: null,
	};
	
	player.tag.widget = player.showWidget("sample.html", "top", 300, 300);
	//์œ„์ ฏ์—์„œ ์•ฑ์œผ๋กœ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๋ฉด ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜
	player.tag.widget.onMessage.Add(function (player, data) {
		if (data.type == "close") {
			player.showCenterLabel("์œ„์ ฏ์ด ๋‹ซํ˜”์Šต๋‹ˆ๋‹ค.");
			player.tag.widget.destroy();
			player.tag.widget = null;
		}
	});
	player.sendUpdated();
});

// q๋ฅผ ๋ˆ„๋ฅด๋ฉด ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜
// ์œ„์ ฏ์— ํ…์ŠคํŠธ์™€ blueman ์ด๋ฏธ์ง€๋ฅผ ๋ณด๋ƒ„
// App.addOnKeyDown ์„ค๋ช…(๋งํฌ)
App.addOnKeyDown(81, function (player) {
	if (player.tag.widget) {
		player.tag.widget.sendMessage({
			text: "๋ธ”๋ฃจ๋งจ",
		});
	}
});

sample.html: ํ…์ŠคํŠธ, ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„ ํ‘œ์‹œํ•˜๋Š” ๋ถ€๋ถ„

//์•ฑ์—์„œ ์œ„์ ฏ์œผ๋กœ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๋ฉด ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜
window.addEventListener("message", function (e) {
	let text = e.data.text;
	let content = document.getElementById("content");
	if (content) {
		while (content.hasChildNodes()) {
			content.removeChild(content.firstChild);
		}
		let content_image = document.createElement("img");
		content_image.setAttribute("src", BLUEMAN);
		content_image.setAttribute("class", "cover");
		content.append(content_image);
	}
	if (text) {
		document.getElementById("text").innerText = text;
	}
});
// ์ด๋ฏธ์ง€๋กœ ์‚ฌ์šฉํ•  ๋ธ”๋ฃจ๋งจ ์ด๋ฏธ์ง€ (base64 ์ธ์ฝ”๋”ฉ)
const BLUEMAN = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAABACAYAAABcIPRGAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAF+UlEQVRoge2ZX2hTVxzHPxk+lOFDbJCtHYVYmpCO7qHEsDWtyFrppkLtxDD3v8hgm7TLgw42Xeek6wSnD7XgJhvi0G1CpDphlHWdIiN3jrb40CDlRmyhKA7XGvaw9WFw9nBzbm9u7k1zb9L5sHzhkntPfuec7/fc3/md8zsXKqigggoqqKCCCiqooIL/Kzyr3L5Y7b5Wo1GddF1wUC+cVw+udr+uIYxXXXBQv4/0Tgv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zO06FgBZEQCbt+/KM7z2wwVC/M3Z65Oynhi5MkFowxMA7HgriTcYYvNjV/jsw3dtO3zvkxNc+72djDrD96daAZiZveNahLlCwYxIJjHGxOPm7F1dgIT6Y/4ASASfu6DfSwHgXoR5JfYUuiTxjlCY22eGWEyO8uSGWk6fS7BjkyZkaU7l4tVJy84uXp3Ug4S0b/TX0Oiv4YVnN5J1R0dppZN8QFzu66NreJiOUBhv9GlAizZd/XH2Dwzp5I6MVHFkJGXRhDZPluZU2LSWmdk7NPpr9H+liJ3tkaKjk6OMrG33NhaTo3z5/utawf0HtO3elmOTOnqK8S3byagzedf4lu2kjp7SbZWkkteHVVkhOPE3YVykMmlVv69u3cr+gSF9cq50LiQn+7H+ODdn79Lor+Hi1UmUpMKB9qCjVdrprBdygUpN3cK4IzWuBTKPMAoxl8k1YP/AEAAHXtRcUu6pqlu3FsXPcVIvk3iz65hHvZjnQGeCvXUG8i7gNKn31PfE86JEXXDQctTtYDy5q++JZ8+TllHs6IO7U4m8tcN4Lip3svfm1JzzUhmhMhYNZpTf9HunO9RyfO4UVkmP8cjcfBRvhDyWd8upbB/5rCDzCNM3YisYF0xHKIsAY/IjYUqCLEVY1XOKcggoZoQt4eaLjBllO1r0/nlCv89uy/Py5/RYTN/xlgvleAOuSWXrPfwv9W0tG2lr2QjYjr6ERyZNxjr/a/wLheTsVoCMSQ0AAAAASUVORK5CYII="

destroy

widget.destroy()

์œ„์ ฏ์„ ์‚ญ์ œํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

  • ์—†์Œ

์˜ˆ์ œ

๋ถ€๋ก

์œ„์ ฏ์—์„œ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•œ ๋ฌธ๋ฒ•

Last updated