{"id":1279,"date":"2021-02-07T21:53:44","date_gmt":"2021-02-07T12:53:44","guid":{"rendered":"https:\/\/dalomo.net\/blog\/?p=1279"},"modified":"2021-02-07T22:03:58","modified_gmt":"2021-02-07T13:03:58","slug":"socket-io%e3%81%ae%e3%83%87%e3%83%a2%e3%81%ae%e3%83%9b%e3%83%af%e3%82%a4%e3%83%88%e3%83%9c%e3%83%bc%e3%83%89%e3%82%92%e8%a8%ad%e7%bd%ae%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/dalomo.net\/blog\/2021\/02\/07\/1279\/","title":{"rendered":"Socket.IO\u306e\u30c7\u30e2\u306e\u30db\u30ef\u30a4\u30c8\u30dc\u30fc\u30c9\u3092\u8a2d\u7f6e\u3057\u3066\u307f\u305f"},"content":{"rendered":"<h1>\u30db\u30ef\u30a4\u30c8\u30dc\u30fc\u30c9<\/h1>\n<p>Socket.io\u306e\u30b5\u30a4\u30c8\u3092\u898b\u3066\u3044\u305f\u3089\u3001\u30c7\u30e2\u306b\u30db\u30ef\u30a4\u30c8\u30dc\u30fc\u30c9\u3082\u3042\u3063\u305f\u3002\u9762\u767d\u305d\u3046\u306a\u306e\u3067\u3053\u3061\u3089\u3082\u8a2d\u7f6e\u3057\u3066\u307f\u308b\u3002<\/p>\n<p><a href=\"https:\/\/socket.io\/demos\/whiteboard\/\">https:\/\/socket.io\/demos\/whiteboard\/<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/socketio\/socket.io\/tree\/master\/examples\/whiteboard\">https:\/\/github.com\/socketio\/socket.io\/tree\/master\/examples\/whiteboard<\/a><\/p>\n<h2>\u8a2d\u7f6e\u3057\u305f\u3084\u3064<\/h2>\n<p><a href=\"https:\/\/dalomo.net\/whiteboard\/\">https:\/\/dalomo.net\/whiteboard\/<\/a><\/p>\n<p>\u5c11\u3057\u3060\u3051\u5909\u3048\u3066\u308b\u306e\u3067\u3001\u6d41\u308c\u3068\u3068\u3082\u306b\u30e1\u30e2\u3063\u3068\u304f\u3002\u4f8b\u306b\u3088\u3063\u3066\u3001nginx\u3092\u30d5\u30ed\u30f3\u30c8\u306b\u3001\u30ea\u30d0\u30fc\u30ba\u30d7\u30ed\u30ad\u30b7\u3067\u30a2\u30af\u30bb\u30b9\u3092\u632f\u3063\u3066\u308b\u306e\u3067\u306a\u3093\u304b\u3088\u304f\u5206\u304b\u3089\u3093\u304f\u306a\u3063\u3068\u308b\u3002<\/p>\n<h2>nginx\u306e\u8a2d\u5b9a<\/h2>\n<p>\/etc\/nginx\/conf.d\/reverse_proxy.conf\u306b<\/p>\n<pre>upstream whiteboard {\r\n  ip_hash;\r\n  server 127.0.0.1:5000;\r\n}\r\n\u2026\r\nserver {\r\n\u2026\r\n location \/whiteboard\/ {\r\n    proxy_pass http:\/\/whiteboard;\r\n    proxy_redirect off;\r\n    proxy_http_version 1.1;\r\n    proxy_set_header Upgrade $http_upgrade;\r\n    proxy_set_header Connection \"upgrade\";\r\n    proxy_set_header Host $host;\r\n    proxy_set_header X-Real-IP $remote_addr;\r\n    proxy_set_header X-Forwarded-Host $host;\r\n    proxy_set_header X-Forwarded-Server $host;\r\n    proxy_set_header X-Forwarded-Proto $scheme;\r\n    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n  }\r\n\u2026\r\n}<\/pre>\n<p>\u3068\u8ffd\u8a18\u3002dalomo.net\/whiteboard\/\u3078\u306e\u30a2\u30af\u30bb\u30b9\u3092port5000\u306b\u632f\u308b\u3002<\/p>\n<h2>\u30c7\u30e2\u3092\u8a2d\u7f6e<\/h2>\n<p>\/home\/dalomo\/whiteboard\u3068\u3044\u3046\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u308a\u305d\u3053\u306b\u30d5\u30a1\u30a4\u30eb\u3092\u7f6e\u304f\u3002\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u3067<\/p>\n<pre>$ npm ci<\/pre>\n<p>\u3063\u3066\u3084\u308b\u3068\u3001package.json\u3092\u57fa\u306b\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u304d\u3066\u304f\u308c\u308b\u3002\u3059\u3054\u3044\u4fbf\u5229\u3067\u3059\u306d\u3002URL\u304c\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u306a\u3063\u3066\u3044\u308b\u90fd\u5408\u4e0a\u3001\u307e\u305f\u3046\u307e\u304f\u52d5\u3044\u3066\u306a\u3044\u306e\u3067\u8272\u3005\u66f8\u304d\u63db\u3048\u308b\u3002\u304c\u3001\u3069\u3053\u3092\u5909\u3048\u305f\u306e\u304b\u307e\u3068\u3081\u308b\u306e\u304c\u3081\u3093\u3069\u3044\u306e\u3067<\/p>\n<p><a href=\"https:\/\/difff.jp\/\">https:\/\/difff.jp\/<\/a><\/p>\n<p>\u3053\u3061\u3089\u3067\u5dee\u5206\u3092\u8868\u793a\u3057\u3066\u30b9\u30af\u30b7\u30e7\u64ae\u3063\u305f\u3002<\/p>\n<h3>\/home\/dalomo\/whiteboard\/index.js<\/h3>\n<p><a href=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1282\" src=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb1-300x91.png\" alt=\"\" width=\"300\" height=\"91\" srcset=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb1-300x91.png 300w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb1-1024x311.png 1024w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb1-768x233.png 768w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb1.png 1163w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u305d\u3082\u305d\u3082\u306eindex.html\u304c\u30b5\u30fc\u30d6\u3055\u308c\u306a\u3044\u305f\u3081app.use\u306e\u6307\u5b9a\u3092\u5909\u3048\u3066\u307f\u305f\u3002\u7d76\u5bfe\u30d1\u30b9\u306e\u6307\u5b9a\u3067\u4f55\u6545\u304b\u3055\u308c\u306a\u304b\u3063\u305f\u306e\u3060\u3051\u308c\u3069\u3001\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u540d\u306e\u6307\u5b9a\u3060\u3051\u3067\u3067\u304d\u305f\u3002\u306a\u3093\u3067\u304b\u306f\u77e5\u3089\u3093\u3002<\/p>\n<p>io\u3092require\u3059\u308b\u969b\u306bpath\u3092\u6307\u5b9a\u3057\u305f\u3002\u6307\u5b9a\u3057\u306a\u3044\u3068\u3001dalomo.net\/socket.io\u3092\u63a2\u3057\u306b\u884c\u304f\u3002\u305d\u3053\u306b\u306f\u306a\u3044\u3002<\/p>\n<h3>\/home\/dalomo\/whiteboard\/public\/index.html<\/h3>\n<p><a href=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1283\" src=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb2-300x199.png\" alt=\"\" width=\"300\" height=\"199\" srcset=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb2-300x199.png 300w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb2-1024x678.png 1024w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb2-768x509.png 768w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb2.png 1244w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\u8272\u3092\u3044\u3063\u3071\u3044\u8ffd\u52a0\u3057\u305f\u3001\u610f\u5473\u306f\u306a\u3044\u2026\u3002split\u3057\u3066\u540d\u524d\u3092\u4f7f\u3063\u3066\u308b\u307f\u305f\u3044\u3060\u3063\u305f\u306e\u3067webcolor16\u8272\u306b\u3057\u3066\u307f\u305f\u3002<\/p>\n<p>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\u306esocket.io\u3092\u30af\u30e9\u30a6\u30c9\u304b\u3089\u53d6\u5f97\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u308b\u3002\u3053\u3053\u304c\u81ea\u5206\u306e\u74b0\u5883\u3060\u3068\u3069\u3046\u3084\u308c\u3070\u3061\u3083\u3093\u3068\u914d\u4fe1\u3055\u308c\u308b\u304b\u5206\u304b\u3093\u306a\u3044\u3093\u3060\u3088\u306d\uff5e\u3002<\/p>\n<p>\u30ea\u30ed\u30fc\u30c9\u7528\u306e\u30dc\u30bf\u30f3\u3092\u3064\u3051\u3066\u308b\u3002\u753b\u9762\u304c\u63cf\u753b\u3067\u4e00\u676f\u306b\u306a\u3063\u3061\u3083\u3063\u305f\u6642\u7528\u3002canvas\u3092\u30ea\u30bb\u30c3\u30c8\u3059\u308b\u3084\u308a\u65b9\u3092\u691c\u8a0e\u3057\u3066\u306a\u3044\u306e\u3067\u3001\u4f7f\u3046\u4eba\u3044\u306a\u3044\u3060\u308d\u3046\u3057\u8ca0\u8377\u3068\u304b\u306f\u6c17\u306b\u305b\u305a\uff01<\/p>\n<h3>\/home\/dalomo\/whiteboard\/public\/style.css<\/h3>\n<p><a href=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1284\" src=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb3-252x300.png\" alt=\"\" width=\"252\" height=\"300\" srcset=\"https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb3-252x300.png 252w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb3-859x1024.png 859w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb3-768x915.png 768w, https:\/\/dalomo.net\/blog\/wp-content\/uploads\/2021\/02\/wb3.png 1259w\" sizes=\"auto, (max-width: 252px) 100vw, 252px\" \/><\/a><\/p>\n<p>android\u4f7f\u3063\u3066\u308b\u3093\u3067\u3059\u304c\u4e00\u756a\u4e0a\u3067\u4e0b\u306b\u30b9\u30ef\u30a4\u30d7\u3059\u308b\u3068\u518d\u8aad\u307f\u8fbc\u307f\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u3002Pull-to-Refresh\u3068\u3044\u3046\u3082\u306e\u3067\u3001\u4eca\u56de\u306e\u30db\u30ef\u30a4\u30c8\u30dc\u30fc\u30c9\u3067\u306f\u7121\u7528\u306a\u306e\u3067\u306a\u304f\u3057\u305f\u3044\u3002\u306a\u306e\u3067body{overscroll-behavior-y: none;}\u3092\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<p>\u518d\u8aad\u307f\u8fbc\u307f\u7528\u306e\u30dc\u30bf\u30f3\u304c\u305d\u306e\u307e\u307e\u3060\u3068\u8272\u9078\u629e\u306e\u5f8c\u308d\u306b\u96a0\u308c\u3061\u3083\u3063\u305f\u306e\u3067\u3001\u53f3\u4e0b\u306b\u304f\u308b\u3088\u3046\u306b\u3057\u3066\u307f\u305f\u3002\u3067\u3082\u306a\u3093\u304b\u3046\u307e\u304f\u8868\u793a\u3055\u308c\u306a\u304f\u3066\u9811\u5f35\u3063\u3066\u3044\u3044\u611f\u3058\u306b\u306a\u308b\u3088\u3046\u306b\u3057\u305f\u3051\u3069\u96e3\u3057\u3044\u3002CSS\u96e3\u3057\u3044\uff01<\/p>\n<h3>\/home\/dalomo\/whiteboard\/public\/main.js<\/h3>\n<pre> var socket = io();\r\n\u2193\r\n var socket = io.connect(\"\/\", {path: \"\/whiteboard\/socket.io\"});<\/pre>\n<p>\u3068\u3057\u305f\u3060\u3051\u3002<\/p>\n<h2>\u3067\u304d\u3042\u304c\u308a<\/h2>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/xswC0TVOp4A\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><br \/>\n<iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/fMuIrOad_3M\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>\u52d5\u3044\u305f\u30fc\u3002PC\u3067\u3082\u30b9\u30de\u30db\u3067\u3082\u52d5\u304f\u3002\u4ee5\u4e0b\u4f59\u8ac7\u3002<\/p>\n<h2>javascript\u3084css\u3092\u7de8\u96c6\u3057\u305f\u306e\u306b\u30d6\u30e9\u30a6\u30b6\u3067\u958b\u3044\u3066\u3082\u66f4\u65b0\u3055\u308c\u3066\u306a\u3044<\/h2>\n<p>\u3066\u3044\u3046\u3053\u3068\u304c\u3042\u3063\u305f\u3002\u30b9\u30de\u30db\u306e\u6319\u52d5\u306e\u691c\u8a3c\u3057\u3066\u305f\u3068\u3053\u308d\u3067\u3001\u306a\u3093\u3067\u304b\u5909\u66f4\u3057\u3066\u3082\u8868\u793a\u3060\u3063\u305f\u308a\u3001\u30b3\u30fc\u30c9\u3060\u3063\u305f\u308a\u304c\u5909\u308f\u3089\u306a\u3044\u3002\u30d6\u30e9\u30a6\u30b6\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u304c\u539f\u56e0\u3089\u3057\u3044\u3002\u305f\u3060\u30b9\u30fc\u30d1\u30fc\u30ea\u30ed\u30fc\u30c9\u3057\u3066\u3082\u4f55\u6545\u304b\u66f4\u65b0\u3055\u308c\u306a\u304b\u3063\u305f\u308a\u3057\u305f\u306e\u3067CacheBusting\u3068\u3044\u3046\u65b9\u6cd5\u3092\u4f7f\u3063\u3066\u5225\u7269\u3068\u8a8d\u8b58\u3055\u305b\u308b\u611f\u3058\uff1f\u3067\u7de8\u96c6\u5f8c\u306ejs\u3060\u3063\u305f\u308acss\u3060\u3063\u305f\u308a\u3092\u8aad\u307f\u8fbc\u3081\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3002\u307e\u305f\u3001\u305d\u306e\u904e\u7a0b\u3067\u3001\u30b9\u30de\u30db\u306e\u8868\u793a\u3092PC\u304b\u3089\u63a5\u7d9a\u3057\u3066\u3001PC\u306echrome\u3067\u30c7\u30d9\u30ed\u30c3\u30d1\u30fc\u30c4\u30fc\u30eb\u3092\u4f7f\u3044\u306a\u304c\u3089\u691c\u8a3c\u3059\u308b\u3088\u3046\u306a\u4f7f\u3044\u65b9\u3082\u77e5\u3063\u305f\u3002<\/p>\n<h2>\u30b9\u30de\u30db\u5b9f\u6a5f\u3067\u30c7\u30d9\u30ed\u30c3\u30d1\u30fc\u30c4\u30fc\u30eb\u3092\u4f7f\u3046<\/h2>\n<p>\u30b9\u30de\u30db\u3067\u4f7f\u3046\u3068\u3044\u3046\u3088\u308a\u306f\u3001\u30b9\u30de\u30db\u306e\u8868\u793a\u3092PC\u3067\u78ba\u8a8d\u3059\u308b\u3088\u3046\u306a\u611f\u3058\u3002<\/p>\n<p><a href=\"chrome:\/\/inspect\/#devices\">chrome:\/\/inspect\/#devices<\/a><\/p>\n<p><a href=\"https:\/\/developers.google.com\/web\/tools\/chrome-devtools\/remote-debugging\/?hl=ja\">https:\/\/developers.google.com\/web\/tools\/chrome-devtools\/remote-debugging\/?hl=ja<\/a><\/p>\n<p>\u3061\u3087\u3046\u3079\u3093\u308a\u3060\u3063\u305f\u3002<\/p>\n<h2>\u53c2\u8003<\/h2>\n<p><a href=\"https:\/\/www.nishishi.com\/javascript-tips\/location-reload.html\">https:\/\/www.nishishi.com\/javascript-tips\/location-reload.html<\/a><\/p>\n<p><a href=\"https:\/\/qiita.com\/TanakaMidnight\/items\/979cd7f044fb03a12a9d\">https:\/\/qiita.com\/TanakaMidnight\/items\/979cd7f044fb03a12a9d<\/a><\/p>\n<p><a href=\"https:\/\/developer.mozilla.org\/ja\/docs\/Web\/CSS\/overscroll-behavior-y\">https:\/\/developer.mozilla.org\/ja\/docs\/Web\/CSS\/overscroll-behavior-y<\/a><\/p>\n<p><a href=\"https:\/\/qiita.com\/aqril_1132\/items\/4789bc12a511136d8bfa\">https:\/\/qiita.com\/aqril_1132\/items\/4789bc12a511136d8bfa<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30db\u30ef\u30a4\u30c8\u30dc\u30fc\u30c9 Socket.io\u306e\u30b5\u30a4\u30c8\u3092\u898b\u3066\u3044\u305f\u3089\u3001\u30c7\u30e2\u306b\u30db\u30ef\u30a4\u30c8\u30dc\u30fc\u30c9\u3082\u3042\u3063\u305f\u3002\u9762\u767d\u305d\u3046\u306a\u306e\u3067\u3053\u3061\u3089\u3082\u8a2d\u7f6e\u3057\u3066\u307f\u308b\u3002 https:\/\/socket.io\/demos\/whiteboard\/ https:\/\/gith &hellip; <a href=\"https:\/\/dalomo.net\/blog\/2021\/02\/07\/1279\/\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1282,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[2],"tags":[129,130,131,139],"class_list":["post-1279","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-2","tag-nginx","tag-node-js","tag-socket-io","tag-139"],"_links":{"self":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/1279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/comments?post=1279"}],"version-history":[{"count":5,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/1279\/revisions"}],"predecessor-version":[{"id":1288,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/posts\/1279\/revisions\/1288"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/media\/1282"}],"wp:attachment":[{"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/media?parent=1279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/categories?post=1279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalomo.net\/blog\/wp-json\/wp\/v2\/tags?post=1279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}