plumo 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/plumo/version.rb +1 -1
- data/lib/plumo.rb +11 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da6fa84e3622b29e242b5f8e88cdf79c4c1ae25d
|
4
|
+
data.tar.gz: 65bb18eddc24a5661306929ea4093312ef960079
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba41af30bae3cd2854f16d2edfdc5ebf627de0c7161830b1dd97f0fb465961888326072ece36d8837fbef49acfb9b355a16503d71fe3cc32b4d923a9e11204e2
|
7
|
+
data.tar.gz: a8dc030e5478b057b313047ed5da1ae5694c2e5cc0321acbb9125e7d72c8fe0b8e4e8cb3ea63059fdd59f012bac7f4457f8bb5a2344de026e22a04ddf9c5f9b2
|
data/README.md
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
(Japanese) Plumo: pure Ruby + WEBrick + Comet + Canvasで手軽にお絵描き - memo88
|
2
|
+
https://memo88.hatenablog.com/entry/2019/04/30/114356
|
data/lib/plumo/version.rb
CHANGED
data/lib/plumo.rb
CHANGED
@@ -28,6 +28,8 @@ class Plumo
|
|
28
28
|
|
29
29
|
@q = Thread::SizedQueue.new(100)
|
30
30
|
|
31
|
+
@first_reset_done = false
|
32
|
+
@first_reset_q = Thread::Queue.new
|
31
33
|
@close_q = Thread::Queue.new
|
32
34
|
|
33
35
|
@status = :starting
|
@@ -44,6 +46,11 @@ class Plumo
|
|
44
46
|
h: "#{@h}px"
|
45
47
|
}
|
46
48
|
})
|
49
|
+
|
50
|
+
unless @first_reset_done
|
51
|
+
@first_reset_q.enq 1
|
52
|
+
@first_reset_done = true
|
53
|
+
end
|
47
54
|
end
|
48
55
|
|
49
56
|
def handle_comet(req)
|
@@ -82,7 +89,7 @@ class Plumo
|
|
82
89
|
|
83
90
|
@server = WEBrick::HTTPServer.new(
|
84
91
|
DocumentRoot: File.join(__dir__, "plumo/public"),
|
85
|
-
BindAddress:
|
92
|
+
BindAddress: "127.0.0.1",
|
86
93
|
Port: @opts[:port],
|
87
94
|
AccessLog: [
|
88
95
|
[logger_access, WEBrick::AccessLog::COMMON_LOG_FORMAT],
|
@@ -129,11 +136,12 @@ class Plumo
|
|
129
136
|
@server_thread = Thread.new do
|
130
137
|
@server.start
|
131
138
|
end
|
132
|
-
|
133
|
-
sleep 0.1
|
134
139
|
end
|
135
140
|
|
136
141
|
def draw(*cmds)
|
142
|
+
# Prevent enqueue before first reset
|
143
|
+
@first_reset_q.deq unless @first_reset_done
|
144
|
+
|
137
145
|
if @status == :running
|
138
146
|
@q.enq({
|
139
147
|
type: :cmds,
|