{"id":133,"date":"2020-12-09T18:30:33","date_gmt":"2020-12-09T09:30:33","guid":{"rendered":"http:\/\/localhost:8000\/?p=133"},"modified":"2021-03-13T22:49:24","modified_gmt":"2021-03-13T13:49:24","slug":"niconico-coment-on-browser","status":"publish","type":"post","link":"http:\/\/localhost:8000\/2020\/12\/niconico-coment-on-browser.html","title":{"rendered":"Web\u30d6\u30e9\u30a6\u30b6\u4e0a\u3067\u30cb\u30b3\u30cb\u30b3\u52d5\u753b\u98a8\u306b\u30b3\u30e1\u30f3\u30c8\u3092\u8868\u793a"},"content":{"rendered":"
\u30b3\u30ed\u30ca\u306e\u5f71\u97ff\u3067\u3001\u30ea\u30e2\u30fc\u30c8\u3067\u306e\u52c9\u5f37\u4f1a\u304c\u5897\u3048\u3066\u304d\u307e\u3057\u305f\u304c\u3001\u30d7\u30ec\u30bc\u30f3\u4e2d\u306b\u53cd\u5fdc\u304c\u5c11\u306a\u304f\u3066\u5bc2\u3057\u3044\u306a\u3041\u3068\u611f\u3058\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002
\n\u3067\u3082\u610f\u5916\u306b\u30c1\u30e3\u30c3\u30c8\u306f\u76db\u308a\u4e0a\u304c\u3063\u3066\u308b\u3053\u3068\u304c\u591a\u3044\u306e\u3067\u3001\u753b\u9762\u5171\u6709\u3057\u3066\u3044\u308b\u30d6\u30e9\u30a6\u30b6\u4e0a\u306b\u30cb\u30b3\u30cb\u30b3\u52d5\u753b\u98a8\u306b\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u8868\u793a\u3059\u308b\u6a5f\u80fd<\/b>\u3092\u4f5c\u3063\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n
<\/p>\n
<\/p>\n
\u691c\u8a0e\u306e\u7d50\u679c\u3001\u4ee5\u4e0b\u306e\u6280\u8853\u3092\u63a1\u7528\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n
\u3067\u306f\u3001\u3053\u3053\u304b\u3089\u5b9f\u88c5\u306e\u30dd\u30a4\u30f3\u30c8\u3068\u306a\u308b\u90e8\u5206\u3092\u7d39\u4ecb\u3057\u3066\u3044\u304d\u307e\u3059\u3002 \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\u3067\u306f\u3001\u300c\u53c2\u52a0\u8005\u304cWebSocket\u30b5\u30fc\u30d0\u306b\u30b3\u30e1\u30f3\u30c8\u3092\u9001\u4fe1\u3059\u308b\u300d\u3068\u3044\u3046\u3053\u3068\u3092\u3084\u308a\u307e\u3059\u3002\u8a73\u7d30\u306f\u3053\u3061\u3089<\/a> \u3002<\/p>\n \u30e9\u30a4\u30d6\u30e9\u30ea\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/strong><\/p>\n \u307e\u305a\u306f socket.io<\/a> \u3068 express<\/a> \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n \u5b9f\u88c5<\/strong><\/p>\n \u30b5\u30fc\u30d0\u30b5\u30a4\u30c9\u3067\u306f\u3001\u300c\u53c2\u52a0\u8005\u304b\u3089\u306e\u30b3\u30e1\u30f3\u30c8\u3092\u53d7\u4fe1\u3057\u3066\u30d7\u30ec\u30bc\u30f3\u30bf\u30fc\u306b\u9001\u4fe1\u3059\u308b\u300d\u3068\u3044\u3046\u3053\u3068\u3092\u3084\u308a\u307e\u3059\u3002\u8a73\u7d30\u306f\u3053\u3061\u3089<\/a>\u3002<\/p>\n \u4ee5\u4e0b\u306e\u90e8\u5206\u3067\u3001express + socket.io \u3092\u7acb\u3061\u4e0a\u3052\u3066\u30018080\u30dd\u30fc\u30c8\u3067\u30ea\u30c3\u30b9\u30f3\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n \u6b21\u306b\u3001\u4ee5\u4e0b\u306e\u90e8\u5206\u3067\u3001socket.io\u306e\u30a4\u30d9\u30f3\u30c8\u51e6\u7406\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n \u30d7\u30ec\u30bc\u30f3\u30bf\u30fc\u306f\u4efb\u610f\u306eWeb\u30da\u30fc\u30b8\u4e0a\u3067\u4f1a\u8b70\u4f5c\u6210\u3084\u30b3\u30e1\u30f3\u30c8\u53d7\u4ed8\u3092\u3059\u308b\u3088\u3046\u306b\u3057\u305f\u3044\u306e\u3067\u3001JavaScript\u3060\u3051\u3067\u753b\u9762\u69cb\u7bc9\u304a\u3088\u3073WebSocket\u901a\u4fe1\u3092\u884c\u3046\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002\u8a73\u7d30\u306f\u3053\u3061\u3089<\/a>\u3002<\/p>\n \u307e\u305a\u3001\u52d5\u7684\u306bJavaScript\u3067 socket.io.js \u3092\u8aad\u307f\u8fbc\u3093\u3067\u304a\u304d\u307e\u3059\u3002<\/p>\n socket.io\u306b\u95a2\u3059\u308b\u51e6\u7406\u306e\u66f8\u304d\u3063\u3077\u308a\u306f\u3001\u3053\u308c\u307e\u3067\u7d39\u4ecb\u3057\u305f\u3082\u306e\u3068\u307b\u307c\u540c\u7b49\u3067\u3059\u3002<\/p>\n \u6700\u5f8c\u306b\u3001presenter.js \u306e\u8aad\u307f\u8fbc\u307f\u306f\u4ee5\u4e0b\u306e\u30d6\u30c3\u30af\u30de\u30fc\u30af\u30ec\u30c3\u30c8\u3067\u884c\u3044\u307e\u3059\uff08\u30b3\u30f3\u30bd\u30fc\u30eb\u3084\u30a2\u30c9\u30ec\u30b9\u30d0\u30fc\u5b9f\u884c\u3067\u3082\u3082\u3061\u308d\u3093OK\uff09\u3002<\/p>\n \u6700\u521d\u306f\u4f55\u304bJavaScript\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3082\u5165\u308c\u3088\u3046\u304b\u3068\u601d\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u4eca\u56de\u306e\u7bc4\u56f2\u3067\u3042\u308c\u3070\u3001css\u306e animation<\/a> \u3067\u5341\u5206\u3060\u3063\u305f\u306e\u3067\u3001\u305d\u3061\u3089\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n \u30cb\u30b3\u30cb\u30b3\u52d5\u753b\u98a8\u306b\u30b3\u30e1\u30f3\u30c8\u3092\u53f3\u304b\u3089\u5de6\u306b\u30b9\u30e9\u30a4\u30c9\u3055\u305b\u308b\u8a2d\u5b9a\u306f\u3001\u3068\u3066\u3082\u30b7\u30f3\u30d7\u30eb\u3067\u3059\uff08\u5b9f\u969b\u306b\u306fJavaScript\u3067\u52d5\u7684\u306b\u5024\u3092\u8a2d\u5b9a\u3057\u3066\u307e\u3059\uff09\u3002<\/p>\n animation\u4e00\u62ec\u6307\u5b9a\u30d7\u30ed\u30d1\u30c6\u30a3<\/strong><\/p>\n \u5de6\u304b\u3089\u9806\u306b\u4ee5\u4e0b\u306e\u610f\u5473\u306b\u306a\u308b\u305d\u3046\u3067\u3059\u3002<\/p>\n @keyframes<\/strong><\/p>\n \u3053\u3061\u3089<\/a>\u3092\u307f\u306a\u304c\u3089\u4f5c\u696d\u3057\u3066\u307f\u307e\u3057\u305f\u304c\u3001\u521d\u3081\u3066\u3067\u308230\u5206\u3050\u3089\u3044\u3067\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n GAE\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3067\u3042\u308bapp.yaml\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u8a2d\u5b9a\u5185\u5bb9\u306e\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u306f\u3053\u3061\u3089<\/a>\u3067\u3059\u3002<\/p>\n app.yaml\u3092\u4f5c\u6210\u3057\u305f\u3089\u3001 \u4eca\u56de\u306e\u4f8b\u3060\u3068\u3001http:\/\/localhost:8080<\/a> \u304c https:\/\/niconicoment.df.r.appspot.com<\/a> \u3067\u516c\u958b\u3055\u308c\u307e\u3057\u305f\u3002 WebSocket connection to 'wss:\/\/niconicoment.df.r.appspot.com\/socket.io\/?EIO=4&transport=websocket&sid=PokDhNT0SYiyiNngAAAg' failed: Error during WebSocket handshake: Unexpected response code: 400<\/p>\n<\/blockquote>\n Google App Engine\u306eStandard\u74b0\u5883\u3067\u306fWebSocket\u306e\u5bfe\u5fdc\u3092\u3057\u3066\u306a\u3044\u305f\u3081\u3067\u3057\u305f\u3002\u30d5\u30ec\u30ad\u30b7\u30d6\u30eb\u74b0\u5883\u306b\u8a2d\u5b9a\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u3067\u3053\u306e\u30a8\u30e9\u30fc\u306f\u89e3\u6d88\u3055\u308c\u308b\u3088\u3046\u3067\u3059\u3002app.yaml\u306b\u4ee5\u4e0b\u306e\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3059\u308c\u3070\u3088\u3044\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n \u3057\u304b\u3057\u3001\u30d5\u30ec\u30ad\u30b7\u30d6\u30eb\u74b0\u5883\u306f\u7121\u6599\u67a0\u304c\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u305b\u3093<\/a> \u306e\u3067\u3001\u8cbb\u7528\u304c\u304b\u304b\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u4eca\u56de\u306f\u3001\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u3066\u3044\u308b\u3082\u306e\u306e\u554f\u984c\u306a\u304f\u52d5\u4f5c\u3057\u3066\u3044\u308b\u305f\u3081\u3001\u3053\u306e\u5bfe\u51e6\u306f\u884c\u308f\u305a\u653e\u7f6e\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002 The client will try to establish a WebSocket connection if possible, and will fall back on HTTP long polling if not.<\/p>\n<\/blockquote>\n \u3069\u3046\u3084\u3089\u3001socket.io\u306fWebSocket\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u5834\u5408\u3001HTTP polling \u306b\u5207\u308a\u66ff\u3048\u3066\u5b9f\u884c\u3057\u3066\u304f\u308c\u308b\u3088\u3046\u3067\u3059\u3002\u3053\u308c\u306fWebSocket\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u30d6\u30e9\u30a6\u30b6\u306a\u3069\u3067\u3082\u3001\u52d5\u304f\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306e\u3082\u306e\u306e\u3088\u3046\u3067\u3059\u304c\u3001\u4eca\u56de\u306f\u3053\u308c\u306b\u52a9\u3051\u3089\u308c\u307e\u3057\u305f(^ ^)<\/p>\n \u30d6\u30c3\u30af\u30de\u30fc\u30af\u30ec\u30c3\u30c8\u3067\u30db\u30b9\u30c8\u30da\u30fc\u30b8\u306e\u30c9\u30e1\u30a4\u30f3\u304b\u3089\u3001WebSocket\u30b5\u30fc\u30d0\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u969b\u306b\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002<\/p>\n Access to XMLHttpRequest at 'https:\/\/niconicoment.df.r.appspot.com\/socket.io\/?EIO=4&transport=polling&t=NOtA0a6<\/a>' from origin 'https:\/\/socket.io<\/a>' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.<\/p>\n<\/blockquote>\n \u3053\u308c\u306fsocket.io\u306e\u30b5\u30fc\u30d0\u30b5\u30a4\u30c9\u306e\u8a2d\u5b9a\u3067\u4ee5\u4e0b\u306e\u8a2d\u5b9a\u3092\u884c\u3046\u3053\u3068\u3067\u56de\u907f\u3057\u307e\u3059\u3002<\/p>\n \u30d6\u30c3\u30af\u30de\u30fc\u30af\u30ec\u30c3\u30c8\u3067\u52d5\u7684\u306bJavaScript\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u3093\u3060\u969b\u306b\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3059\u308b\u30da\u30fc\u30b8\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n VM19:1 Refused to load the script 'https:\/\/niconicoment.df.r.appspot.com\/presenter.js<\/a>' because it violates the following Content Security Policy directive: "script-src github.githubassets.com". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.<\/p>\n<\/blockquote>\n \u3053\u308c\u306f\u3001\u73fe\u72b6\u307e\u3060\u89e3\u6c7a\u3057\u3066\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u52d5\u7684\u306b\u8aad\u307f\u8fbc\u3093\u3067\u3044\u308b\u4e8c\u3064\u306eJavaScript\u30d5\u30a1\u30a4\u30eb\u3092\u30d0\u30f3\u30c9\u30eb\u3057\u3066\u3001\u305d\u306e\u5185\u5bb9\u3092\u76f4\u63a5\u30d6\u30c3\u30af\u30de\u30fc\u30af\u30ec\u30c3\u30c8\u3067\u5b9f\u884c\u3059\u308b\u304b\u3001Chrome\u62e1\u5f35\u3068\u3057\u3066\u5b9f\u884c\u3059\u308c\u3070\u89e3\u6c7a\u3067\u304d\u305d\u3046\u3067\u3059\u3002<\/p>\n \uff08\u5f8c\u65e5\u8ffd\u8a18\uff09\u3053\u3061\u3089\u306fChrome\u62e1\u5f35\u3068\u3057\u3066\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067\u89e3\u6c7a\u3057\u307e\u3057\u305f\u3002\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3092\u516c\u958b\u3057\u3066\u307e\u3059\u306e\u3067\u8208\u5473\u304c\u3042\u308c\u3070\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\n \u3053\u3061\u3089\u3067\u516c\u958b\u3057\u3066\u3044\u307e\u3059\u3002 \u4f1a\u793e\u306e\u52c9\u5f37\u4f1a\u5411\u3051\u306b\u30cb\u30b3\u30cb\u30b3\u52d5\u753b\u98a8\u30b3\u30e1\u30f3\u30c8\u8868\u793a\u30b5\u30fc\u30d3\u30b9\u3092\u958b\u767a\u3057\u3066\u307f\u307e\u3057\u305f\u304c\u3001\u4eca\u56de\u521d\u3081\u3066\u89e6\u3063\u305f socket.io \u3082 GAE \u3082\u304b\u306a\u308a\u826f\u304b\u3063\u305f\u3067\u3059\u3002<\/p>\n \u30d7\u30ec\u30bc\u30f3\u30bf\u30fc\u306f\u53c2\u52a0\u8005\u304c\u5165\u529b\u3057\u305f\u30b3\u30e1\u30f3\u30c8\u3092\u53d7\u3051\u4ed8\u3051\u305f\u3044\u306e\u3067\u3059\u304c\u3001\u5019\u88dc\u306f\u4e8c\u3064\u3042\u308b\u304b\u306a\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n \u4eca\u56de\u306f\u30d7\u30ec\u30bc\u30f3\u30c6\u30fc\u30b7\u30e7\u30f3\u4e2d\u306b\u826f\u3044\u611f\u3058\u306e\u30b3\u30e1\u30f3\u30c8\u3092\u9001\u308b\u306e\u304c\u76ee\u7684\u306a\u306e\u3067\u3001\u30ea\u30a2\u30eb\u30bf\u30a4\u30e0\u6027\u306b\u512a\u308c\u305fWebSocket\u3092\u63a1\u7528\u3057\u307e\u3057\u305f\u3002<\/p>\n \u30d7\u30ec\u30bc\u30f3\u30bf\u30fc\u306f\u3001Web\u4f1a\u8b70\u30b7\u30b9\u30c6\u30e0\u3067\u753b\u9762\u5171\u6709\u3059\u308b\u4efb\u610f\u306e\u30da\u30fc\u30b8\u4e0a\u306b\u30b3\u30e1\u30f3\u30c8\u3092\u8868\u793a\u3057\u305f\u3044\u306e\u3067\u3059\u304c\u3001\u4efb\u610f\u306e\u30da\u30fc\u30b8\u4e0a\u3067JavaScript\u3092\u5b9f\u884c\u3067\u304d\u308b\u5fc5\u8981\u304c\u3042\u308a\u3001\u5019\u88dc\u306f\u4e09\u3064\u3042\u308a\u305d\u3046\u3067\u3059\u3002<\/p>\n \u7d50\u8ad6\u3068\u3057\u3066\u306f\u3001\u307e\u305a\u306f\u30d6\u30c3\u30af\u30de\u30fc\u30af\u30ec\u30c3\u30c8\u3067\u4f5c\u308a\u8fbc\u3093\u3067\u3001\u826f\u3044\u3082\u306e\u304c\u3067\u304d\u305f\u3089Chrome\u62e1\u5f35\u5316\u3059\u308b<\/b>\u3068\u3044\u3046\u65b9\u91dd\u306b\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n WebSocket\u306e\u30b5\u30fc\u30d0\u6a5f\u80fd\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u304c\u3001\u4eca\u56de\u306f\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304c\u30d6\u30e9\u30a6\u30b6\u3067\u8a00\u8a9e\u306fJavaScript\u306b\u306a\u308a\u307e\u3059\u306e\u3067\u3001\u30b5\u30fc\u30d0\u30b5\u30a4\u30c9\u3082\u540c\u3058\u304fJavaScript\u3092\u63a1\u7528\u3057\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002 \u6b21\u306b\u30b5\u30fc\u30d0\u306e\u5b9f\u884c\u5834\u6240\u3067\u3059\u304c\u3001GCP\u306e\u30b5\u30fc\u30d3\u30b9\u5185\u3067\u691c\u8a0e\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u4e09\u3064\u5019\u88dc\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n \u6bd4\u8f03\u3059\u308b\u3068\u3001GAE\u304c\u660e\u3089\u304b\u306b\u4eca\u56de\u306e\u7528\u9014\u3067\u306f\u512a\u4f4d\u6027\u304c\u3042\u308b\u306e\u3067\u3001GAE\u3092\u63a1\u7528\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n \uff08Deno<\/a>\u3092\u4f7f\u3044\u305f\u3044\u6b32\u6c42\u3082\u3042\u308b\u306e\u3067\u3059\u304c\u3001GAE\u304c\u5bfe\u5fdc\u3057\u3066\u306a\u3044\u306e\u3067\u4eca\u56de\u306f\u3084\u3081\u3066\u304a\u304f\u3053\u3068\u306b\u3057\u307e\u3057\u305f\uff09<\/p>\n \u53c2\u52a0\u8005\u304c\u30b3\u30e1\u30f3\u30c8\u3092\u5165\u529b\u3059\u308bWeb\u753b\u9762\u304c\u5fc5\u8981\u306a\u306e\u3067\u3059\u304c\u3001\u3053\u3053\u306f\u9759\u7684\u306aWeb\u30b5\u30a4\u30c8\u3092\u30db\u30b9\u30c6\u30a3\u30f3\u30b0\u3067\u304d\u308c\u3070\u305d\u308c\u3067\u826f\u3055\u305d\u3046\u3067\u3059\u3002 \u30b3\u30ed\u30ca\u306e\u5f71\u97ff\u3067\u3001\u30ea\u30e2\u30fc\u30c8\u3067\u306e\u52c9\u5f37\u4f1a\u304c\u5897\u3048\u3066\u304d\u307e\u3057\u305f\u304c\u3001\u30d7\u30ec\u30bc\u30f3\u4e2d\u306b\u53cd\u5fdc\u304c\u5c11\u306a\u304f\u3066\u5bc2\u3057\u3044\u306a\u3041\u3068\u611f\u3058\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002 \u3067\u3082\u610f\u5916\u306b\u30c1\u30e3\u30c3\u30c8\u306f\u76db\u308a\u4e0a\u304c\u3063\u3066\u308b\u3053\u3068\u304c\u591a\u3044\u306e\u3067\u3001\u753b\u9762\u5171\u6709\u3057\u3066\u3044\u308b\u30d6\u30e9\u30a6\u30b6\u4e0a\u306b\u30cb\u30b3\u30cb\u30b3\u52d5\u753b\u98a8\u306b\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u8868\u793a\u3059\u308b\u6a5f\u80fd\u3092\u4f5c\u3063\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002 \u3084\u308a\u305f\u3044\u3053\u3068 \u30d7\u30ec\u30bc\u30f3\u30bf\u30fc\u304c\u4f1a\u8b70URL\u3092\u767a\u884c\u3059\u308b \u53c2\u52a0\u8005\u306f\u4f1a\u8b70URL\u304b\u3089\u30b3\u30e1\u30f3\u30c8\u3092\u5165\u529b\u3059\u308b \u30d7\u30ec\u30bc\u30f3\u30bf\u30fc\u306eWeb\u30d6\u30e9\u30a6\u30b6\u4e0a\u306b\u3001\u53c2\u52a0\u8005\u306e\u30b3\u30e1\u30f3\u30c8\u304c\u30cb\u30b3\u30cb\u30b3\u52d5\u753b\u98a8\u306b\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u8868\u793a\u3055\u308c\u308b \u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3 \u691c\u8a0e\u306e\u7d50\u679c\u3001\u4ee5\u4e0b\u306e\u6280\u8853\u3092\u63a1\u7528\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002 \u30d6\u30e9\u30a6\u30b6\u4e0a\u3067\u30b3\u30e1\u30f3\u30c8\u5e38\u6642\u53d7\u4ed8\uff08\u30d5\u30ed\u30f3\u30c8\u3001\u30d7\u30ec\u30bc\u30f3\u30bf\u30fc\u5074\uff09 => WebSocket(socket.io) \u4efb\u610f\u306e\u30da\u30fc\u30b8\u4e0a\u306b\u30b3\u30e1\u30f3\u30c8\u8868\u793a\uff08\u30d5\u30ed\u30f3\u30c8\u3001\u30d7\u30ec\u30bc\u30f3\u30bf\u30fc\u5074\uff09 => \u30d6\u30c3\u30af\u30de\u30fc\u30af\u30ec\u30c3\u30c8\uff08\u826f\u3044\u3082\u306e\u304c\u3067\u304d\u305f\u3089Chrome\u62e1\u5f35\u5316\u3057\u3066\u516c\u958b\uff09 \u30b3\u30e1\u30f3\u30c8\u5e38\u6642\u53d7\u4ed8\uff08\u30b5 <\/span>Continue Reading<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12,10,11],"tags":[],"_links":{"self":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/133"}],"collection":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/comments?post=133"}],"version-history":[{"count":1,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/133\/revisions"}],"predecessor-version":[{"id":135,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/133\/revisions\/135"}],"wp:attachment":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/media?parent=133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/categories?post=133"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/tags?post=133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
\ngithub\u30ea\u30dd\u30b8\u30c8\u30ea<\/a> \u3092\u516c\u958b\u3057\u3066\u3044\u308b\u306e\u3067\u6700\u65b0\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u305d\u3061\u3089\u3092\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\nWebSocket\u3067\u30b3\u30e1\u30f3\u30c8\u3092\u9001\u53d7\u4fe1<\/h2>\n
WebSocket\u3068\u306f<\/h3>\n
\n
\n
\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\u5b9f\u88c5\uff08\u53c2\u52a0\u8005\u5074\uff09<\/h3>\n
\/\/ \u4e00\u90e8\u629c\u7c8b\n<script src="https:\/\/niconicoment.df.r.appspot.com\/socket.io\/socket.io.js"><\/script>\n<script>\n(() => {\n class NiconicomentParticipant {\n constructor() {\n \/\/ \u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u4f5c\u6210\n this.socket = io();\n this.message = undefined;\n this.registerEvents();\n this.render();\n }\n\n registerEvents() {\n this.sendButtonEl.addEventListener('click',(e) => {\n const comment = new Comment(this.commentEl.value, this.colorEl.value, this.sizeEl.value);\n \/\/ \u30a4\u30d9\u30f3\u30c8\u767a\u884c\n this.socket.emit('send-comment-to-server', {meetingId: this.meetingIdEl.value, comment: comment}, (res) => {\n this.message = res.message;\n this.render();\n });\n });\n }\n }\n new NiconicomentParticipant();\n})();<\/code><\/pre>\n
\n
\n
io()<\/code>\u3067\u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b<\/li>\n
socket.emit()<\/code>\u3067\u30a4\u30d9\u30f3\u30c8\u3092\u767a\u884c\u3057\u3066\u3044\u308b\u3002\u5f15\u6570\u3067callback\u95a2\u6570\u3092\u6e21\u3057\u3001\u51e6\u7406\u7d50\u679c\u3092\u53d7\u3051\u53d6\u308c\u308b\u3002<\/li>\n<\/ul>\n
\u30b5\u30fc\u30d0\u30b5\u30a4\u30c9\u5b9f\u88c5<\/h3>\n
npm install express socket.io --save<\/code><\/pre>\n
const express = require('express');\nconst app = express()\nconst http = require('http').Server(app);\nconst io = require('socket.io')(http, { cors: { origin: '*' } });\n\napp.use(express.static('public'));\n\nconst port = process.env.PORT || 8080;\nhttp.listen(port, () => {\n console.log('listening on http:\/\/localhost:' + port);\n});<\/code><\/pre>\n
\n
Access-Control-Allow-Origin: *<\/code>\u3092\u8fd4\u3059\u8a2d\u5b9a\uff09<\/li>\n
express.static('public')<\/code> \u3067public\u30d5\u30a9\u30eb\u30c0\u914d\u4e0b\u306e\u9759\u7684\u30d5\u30a1\u30a4\u30eb\u3092serve\u3059\u308b<\/li>\n
\/\/ \u4e00\u90e8\u629c\u7c8b\nio.on('connection', (socket) => {\n socket.on('send-comment-to-server', (msg, callback) => {\n io.to(msg.meetingId).emit('send-comment-to-presenter', msg.comment);\n callback(new Response(true, 'Send comment succeeded.'));\n });\n});<\/code><\/pre>\n
\n
io.on('connection')<\/code>\u3067\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304b\u3089\u306e\u30cf\u30f3\u30c9\u30b7\u30a7\u30a4\u30af\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u4ed8\u3051\u308b\u3002
socket.id<\/code>\u306f\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u6bce\u306b\u5225ID\u306b\u306a\u308b<\/li>\n
socket.on('send-comment-to-server')<\/code>\u3067\u305d\u306esocket\u306b\u304a\u3051\u308b\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304b\u3089\u306e\u30b3\u30e1\u30f3\u30c8\u9001\u4fe1\u30a4\u30d9\u30f3\u30c8\u3092\u53d7\u3051\u53d6\u308b\u3002\u6700\u5f8c\u306e\u5f15\u6570\u306fcallback\u3067\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067\u547c\u3073\u51fa\u3057\u5143\u306b\u7d50\u679c\u3092\u8fd4\u5374\u3067\u304d\u308b<\/li>\n
io.emit('send-comment-to-presenter')<\/code>\u3067\u30e1\u30c3\u30bb\u30fc\u30b8\u9001\u4fe1\u30a4\u30d9\u30f3\u30c8\u3092\u767a\u884c\u3057\u3066\u3044\u304c\u3001
to(msg.meetingId)<\/code>\u3067\u5b9b\u5148\u3092\u7d5e\u3063\u3066\u3044\u308b\u305f\u3081\u3001\u30d7\u30ec\u30bc\u30f3\u30bf\u30fc\u306b\u3060\u3051\u30a4\u30d9\u30f3\u30c8\u304c\u9001\u3089\u308c\u308b<\/li>\n<\/ul>\n
\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\u5b9f\u88c5\uff08\u30d7\u30ec\u30bc\u30f3\u30bf\u30fc\u5074\uff09<\/h3>\n
\/\/ \u4e00\u90e8\u629c\u7c8b\nconst script = document.createElement('script');\nscript.src = 'https:\/\/niconicoment.df.r.appspot.com\/socket.io\/socket.io.js';\nscript.addEventListener('load', () => {\n \/\/ \u672c\u4f53\u51e6\u7406\n new NiconicomentPresenter();\n});\ndocument.body.appendChild(script);<\/code><\/pre>\n
\n
load<\/code>\u30a4\u30d9\u30f3\u30c8\u3067\u5f85\u3063\u3066\u304b\u3089\u3001\u672c\u4f53\u306e\u51e6\u7406\u3092\u884c\u3046<\/li>\n<\/ul>\n
\/\/ \u4e00\u90e8\u629c\u7c8b\nclass NiconicomentPresenter {\n constructor() {\n this.registerEvents();\n }\n registerEvents() {\n this.openButtonEl.addEventListener('click', (e) => {\n \/\/ \u30b3\u30cd\u30af\u30b7\u30e7\u30f3\u4f5c\u6210\n this.socket = io('https:\/\/niconicoment.df.r.appspot.com'); \/\/ \u660e\u793a\u7684\u306bURL\u6307\u5b9a\n \/\/ \u30a4\u30d9\u30f3\u30c8\u76e3\u8996\n this.socket.on('send-comment-to-presenter', (msg) => {\n this.slideComment(new Comment(msg.comment, msg.color, msg.size));\n this.renderToolbox();\n });\n });\n }\n}<\/code><\/pre>\n
\n
socket.on()<\/code>\u3067\u30a4\u30d9\u30f3\u30c8\u3092\u76e3\u8996\u3057\u3066\u3044\u308b<\/li>\n<\/ul>\n
javascript: const script = document.createElement('script'); script.src = 'https:\/\/niconicoment.df.r.appspot.com\/presenter.js'; document.body.appendChild(script);<\/code><\/pre>\n
\u30cb\u30b3\u30cb\u30b3\u52d5\u753b\u98a8\u306b\u30b3\u30e1\u30f3\u30c8\u3092\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3<\/h2>\n
<style>\n.niconicoment-slide-comment {\n position: absolute;\n animation: slide 10s linear 0s 1 normal forwards;\n}\n@keyframes slide {\n 0% { right: 0; }\n 100% { right: 100%; display: none; }\n}\n<\/style><\/code><\/pre>\n
\n
\n
right: 0<\/code> =>
right: 100%<\/code>\u3067\u53f3\u304b\u3089\u5de6\u306b\u79fb\u52d5\u3055\u305b\u3066\u3044\u308b<\/li>\n
display: none<\/code>\u3092\u6307\u5b9a\u3057\u305f\u4e0a\u3067\u3001
animation-fill-mode: forwards<\/code>\u3068\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u5f8c\u306b\u8981\u7d20\u306f\u975e\u8868\u793a\u306b\u306a\u308b<\/li>\n<\/ul>\n
GAE\u306bNode.js\u30a2\u30d7\u30ea\u3092\u30c7\u30d7\u30ed\u30a4<\/h2>\n
\u4e8b\u524d\u8a2d\u5b9a<\/h3>\n
\n
\n
\n
gcloud projects create [YOUR_PROJECT_ID] --set-as-default<\/code><\/li>\n<\/ul>\n<\/li>\n
\n
gcloud projects describe [YOUR_PROJECT_ID]<\/code><\/li>\n<\/ul>\n<\/li>\n
\n
gcloud app create --project=[YOUR_PROJECT_ID]<\/code><\/li>\n<\/ul>\n<\/li>\n
\n
app.yaml\u3092\u4f5c\u6210\u3057\u3066\u30c7\u30d7\u30ed\u30a4<\/h3>\n
runtime: nodejs12\nnetwork:\n session_affinity: true\nentrypoint: node serve.js<\/code><\/pre>\n
\n
session_affinity: true<\/code>\u3067 \u540c\u3058\u30e6\u30fc\u30b6\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u540c\u3058\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u5272\u308a\u632f\u308b<\/li>\n
entrypoint<\/code>\u30678080\u30dd\u30fc\u30c8\u3067\u30ea\u30c3\u30b9\u30f3\u3059\u308bWeb\u30b5\u30fc\u30d0\u3092\u7acb\u3061\u4e0a\u3052\u308b\u3068\u3001\u72ec\u81ea\u30c9\u30e1\u30a4\u30f3\u3067\u5916\u90e8\u516c\u958b\u3057\u3066\u304f\u308c\u308b<\/li>\n<\/ul>\n
gcloud app deploy<\/code>\u3067GAE\u30a2\u30d7\u30ea\u3092\u30c7\u30d7\u30ed\u30a4\u3057\u307e\u3059\u3002<\/p>\n
gcloud app deploy\n> Services to deploy:\n> \n> descriptor: [\/xxxx\/niconicoment\/server\/app.yaml]\n> source: [\/xxxx\/niconicoment\/server]\n> target project: [niconicoment]\n> target service: [default]\n> target version: [20201208t011212]\n> target url: [https:\/\/niconicoment.df.r.appspot.com]<\/code><\/pre>\n
\n\u30c7\u30d7\u30ed\u30a4\u3057\u305f\u30a2\u30d7\u30ea\u306e\u7a3c\u50cd\u72b6\u6cc1\uff08\u30a2\u30af\u30bb\u30b9\u6570\u3001\u8ab2\u91d1\u30b9\u30c6\u30fc\u30bf\u30b9\u306a\u3069\uff09\u306f\u30b3\u30f3\u30bd\u30fc\u30eb<\/a>\u304b\u3089\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\u30c8\u30e9\u30d6\u30eb\u5bfe\u5fdc<\/h2>\n
WebSocket\u306e\u30cf\u30f3\u30c9\u30b7\u30a7\u30a4\u30af\u3067\u30a8\u30e9\u30fc<\/h3>\n
\n
# \u30d5\u30ec\u30ad\u30b7\u30d6\u30eb\u74b0\u5883\u306b\u3059\u308b\nenv: flex\n# \u30ed\u30fc\u30ab\u30eb\u30e1\u30e2\u30ea\u306b\u30c1\u30e3\u30c3\u30c8\u5185\u5bb9\u306a\u3069\u3092\u4fdd\u6301\u3057\u3066\u3044\u308b\u30b1\u30fc\u30b9\u3067\u306f\u30a4\u30f3\u30bf\u30f3\u30b9\u304c\u8907\u6570\u3042\u308b\u3068\u3046\u307e\u304f\u52d5\u304b\u306a\u3044\u306e\u3067\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u6570\u30921\u306b\u8a2d\u5b9a\nmanual_scaling:\n instances: 1<\/code><\/pre>\n
\n\u3067\u306f\u3001\u306a\u305cWebSocket\u304c\u5229\u7528\u3067\u304d\u306a\u3044\u306e\u306b\u3046\u307e\u304f\u52d5\u304f\u306e\u3067\u3057\u3087\u3046\u304b\u3002\u7b54\u3048\u306f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u66f8\u3044\u3066\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n\n
CORS\u30a8\u30e9\u30fc<\/h3>\n
\n
const io = require('socket.io')(http, { cors: { origin: '*' } });<\/code><\/pre>\n
Content Security Policy<\/a> \u30a8\u30e9\u30fc<\/h3>\n
\n
\u3084\u308a\u306e\u3053\u3057\u305f\u3053\u3068<\/h2>\n
\n
\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n
\nhttps:\/\/github.com\/rinoguchi\/niconicoment<\/a><\/p>\n\u3055\u3044\u3054\u306b<\/h2>\n
\n
\n
\n
[\u53c2\u8003] \u30a2\u30fc\u30ad\u30c6\u30af\u30c1\u30e3\u9078\u5b9a\u7406\u7531<\/h2>\n
\u30d6\u30e9\u30a6\u30b6\u4e0a\u3067\u30b3\u30e1\u30f3\u30c8\u5e38\u6642\u53d7\u4ed8\uff08\u30d5\u30ed\u30f3\u30c8\u3001\u30d7\u30ec\u30bc\u30f3\u30bf\u30fc\u5074\uff09<\/h3>\n
\n
\u4efb\u610f\u306e\u30da\u30fc\u30b8\u4e0a\u306b\u30b3\u30e1\u30f3\u30c8\u8868\u793a\uff08\u30d5\u30ed\u30f3\u30c8\u3001\u30d7\u30ec\u30bc\u30f3\u30bf\u30fc\u5074\uff09<\/h3>\n
\n
\n
\n
\n
Access-Control-Allow-Origin<\/code>\u30d8\u30c3\u30c0\u30fc\u3092\u8ffd\u52a0\u3057\u3066\u3082\u3089\u3046\u306e\u306f\u4e0d\u53ef\u80fd<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n
\u30b3\u30e1\u30f3\u30c8\u5e38\u6642\u53d7\u4ed8\uff08\u30b5\u30fc\u30d0\u5074\uff09<\/h3>\n
\nNode.js\u306esocket.io<\/a>\u3067\u3042\u308c\u3070\u3001Web\u30d6\u30e9\u30a6\u30b6\u3067\u5b9f\u884c\u3059\u308bJavaScript\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u3082\u63d0\u4f9b\u3055\u308c\u308b\u306e\u3067\u3001\u3053\u308c\u3092\u4f7f\u3046\u306e\u304c\u826f\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n\n
\n
\n
\n
\u30b3\u30e1\u30f3\u30c8\u5165\u529b\uff08\u30d5\u30ed\u30f3\u30c8\u3001\u53c2\u52a0\u8005\u5074\uff09<\/h3>\n
\n\u8272\u3005\u5019\u88dc\u304c\u3042\u308b\u3088\u3046\u306a\u306e\u3067\u3059\u304c\u3001\u4eca\u56de\u306fGAE+Node.js\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3092\u3059\u3067\u306b\u6c7a\u3081\u305f\u306e\u3067\u3001\u3064\u3044\u3067\u306bexpress<\/a>\u3067\u9759\u7684HTML\u3092serve\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"