diff --git a/host/adomin.html b/host/adomin.html new file mode 100644 index 0000000..59c357f --- /dev/null +++ b/host/adomin.html @@ -0,0 +1,18 @@ + + + + + + + adomin + + + +

Admin

+ + + + + + + \ No newline at end of file diff --git a/host/adomin.js b/host/adomin.js new file mode 100644 index 0000000..25a977b --- /dev/null +++ b/host/adomin.js @@ -0,0 +1,16 @@ +// ボタンがクリックされたときに音楽を再生する関数 +function playMusic() { + // 音楽再生のためのオーディオ要素を取得 + var audio = document.getElementById("music"); + + // 音楽を再生 + audio.play(); + } + + // ボタンがクリックされたときに音楽を停止する関数 + function stopMusic() { + // 音楽再生のためのオーディオ要素を取得 + var audio = document.getElementById("music"); + + // 音楽を停止 + audio.pause(); \ No newline at end of file diff --git a/host/login.html b/host/login.html new file mode 100644 index 0000000..969265a --- /dev/null +++ b/host/login.html @@ -0,0 +1,18 @@ + + + + + + + login + + +

login

+

username

+
+ + + +
+ + \ No newline at end of file diff --git a/host/login.js b/host/login.js new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/host/login.js diff --git a/host/main.html b/host/main.html new file mode 100644 index 0000000..ea9e0fc --- /dev/null +++ b/host/main.html @@ -0,0 +1,12 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git a/host/main.js b/host/main.js new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/host/main.js diff --git a/sever/ws.rb b/sever/ws.rb new file mode 100644 index 0000000..c591ec8 --- /dev/null +++ b/sever/ws.rb @@ -0,0 +1,49 @@ +#!/usr/bin/env ruby +# -*- coding: utf-8 -*- +# EM Intro. - http://keijinsonyaban.blogspot.jp/2010/12/eventmachine.html +# irb to EM - https://keyesberry.hatenadiary.org/entry/20110929/p1 +# +# Browser Settings: +# Chrome: https://blog.hello-world.jp.net/node-js/1821/ + +require 'em-websocket' +require 'set' +PORT = 8888 + +clients = Set.new # 「集合」クラス + +print("No clients yet...") +EM::WebSocket.start({:host => "0.0.0.0", :port => PORT}) do |ws_conn| + # クライアント接続がある度にその情報が ws_conn に入って来る + ws_conn.onopen do # そのクライアントが接続開始してきたとき + clients << ws_conn # クライアントを集合に追加 + ws_conn.send("うっす!") + printf("%d guest(s)\n", clients.length) + end + ws_conn.onmessage do |message| # クライアントから文字列が来たとき + p message + resp = "誰かが「"+message+"」だってさ" + clients.each{|conn| + if (conn == ws_conn) + conn.send("他の人に送っといた") + else + conn.send(resp) + end + } + end + ws_conn.onclose do # クライアントが切断したとき + clients.delete(ws_conn) # そのクライアントを集合から削除 + # p "bye"+ws_conn.inspect + printf("%d GUEST(s)\n", clients.length) + end + EM::defer do # 共通で実行するスレッド + # Thread.new do のほうがいいかも + puts "..captured!" + loop do + print("Enter message for all clients: ") + line = gets + puts("Sending") + clients.each{|conn| conn.send(line.chomp) } + end + end +end