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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5ab1ca1291bc4d644d5e85919de6ac67fe7bc63
4
- data.tar.gz: 08cff4471c4a41a9d07437596db34869cb1a996f
3
+ metadata.gz: da6fa84e3622b29e242b5f8e88cdf79c4c1ae25d
4
+ data.tar.gz: 65bb18eddc24a5661306929ea4093312ef960079
5
5
  SHA512:
6
- metadata.gz: cc8ca673949e3a327bde6f53b8d7d840895abbb94e6e431cbbf0b87ecb61cf2f9f38319f184a9b177d9356ce5f1ba7c02646a57096c294284bb8c7c7c1621315
7
- data.tar.gz: 0de8d7b5b43d4acae3ef4c60be2287f5459950c5c6c22b01538ed01e7b9ff813fc24581ad85f30f171e41d8510f1b7918eae711d82ad14394dd191d66052ae87
6
+ metadata.gz: ba41af30bae3cd2854f16d2edfdc5ebf627de0c7161830b1dd97f0fb465961888326072ece36d8837fbef49acfb9b355a16503d71fe3cc32b4d923a9e11204e2
7
+ data.tar.gz: a8dc030e5478b057b313047ed5da1ae5694c2e5cc0321acbb9125e7d72c8fe0b8e4e8cb3ea63059fdd59f012bac7f4457f8bb5a2344de026e22a04ddf9c5f9b2
data/README.md CHANGED
@@ -1 +1,2 @@
1
- TODO
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
@@ -1,3 +1,3 @@
1
1
  module Plumo
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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: '127.0.0.1',
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,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plumo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - sonota88