multicast 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -4,6 +4,10 @@ Ruby library and command line utils for multicasting
4
4
 
5
5
  This project is very young so some things might not work.
6
6
 
7
+ == Install
8
+
9
+ gem install multicast
10
+
7
11
  == Listening
8
12
 
9
13
  mclisten -g 224.0.1.33 -p 4567
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/bin/mclisten CHANGED
@@ -48,31 +48,6 @@ puts "==== Multicast Listener ====\n"
48
48
  listener = Multicast::Listener.new(:group => Choice.choices[:group], :port => Choice.choices[:port])
49
49
  puts "---> Joining #{Choice.choices[:group]}:#{Choice.choices[:port]}"
50
50
 
51
- listener.listen do |msg, info|
52
- puts "---> [#{info[2]} / #{info[3]}:#{info[1]} (#{msg.size} bytes)] #{msg}"
51
+ listener.listen do |message|
52
+ puts "---> [#{message.hostname} / #{message.ip}:#{message.port} (#{message.message.size} bytes)] #{message.message}"
53
53
  end
54
-
55
-
56
- # puts "==== Multicast Listener ====\n"
57
- #
58
- # multicast_group = Choice.choices[:group]
59
- # port = Choice.choices[:port]
60
- # ip = IPAddr.new(multicast_group).hton + IPAddr.new("0.0.0.0").hton
61
- # puts "---> Joining #{multicast_group}:#{port}"
62
- # sock = UDPSocket.new
63
- # sock.setsockopt(Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, ip)
64
- # sock.bind(Socket::INADDR_ANY, port)
65
- #
66
- # loop do
67
- # begin
68
- # msg, info = sock.recvfrom(1024)
69
- # #puts "MSG: #{msg} from #{info[2]} (#{info[3]})/#{info[1]} len #{msg.size}"
70
- # puts "---> [#{info[2]} / #{info[3]}:#{info[1]} (#{msg.size} bytes)] #{msg}"
71
- #
72
- # rescue Interrupt
73
- # sock.close
74
- # puts "\n---> Exiting"
75
- # exit
76
- # end
77
- #
78
- # end
@@ -16,10 +16,9 @@ module Multicast
16
16
 
17
17
  loop do
18
18
  begin
19
- msg, info = sock.recvfrom(1024)
20
- #puts "MSG: #{msg} from #{info[2]} (#{info[3]})/#{info[1]} len #{msg.size}"
21
- #puts "---> [#{info[2]} / #{info[3]}:#{info[1]} (#{msg.size} bytes)] #{msg}"
22
- yield(msg, info)
19
+ msg, info = sock.recvfrom(1024)
20
+ message = Message.new(:message => msg, :hostname => info[2], :ip => info[3], :port => info[1])
21
+ yield(message)
23
22
 
24
23
  rescue Interrupt
25
24
  sock.close
@@ -0,0 +1,13 @@
1
+ module Multicast
2
+ class Message
3
+ attr_accessor :message, :hostname, :ip, :port
4
+
5
+ def initialize(opts={})
6
+ @message = opts[:message]
7
+ @hostname = opts[:hostname]
8
+ @ip = opts[:ip]
9
+ @port = opts[:port]
10
+ end
11
+
12
+ end
13
+ end
data/lib/multicast.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'socket'
2
2
  require 'ipaddr'
3
3
 
4
+ require File.dirname(__FILE__) + '/multicast/message'
4
5
  require File.dirname(__FILE__) + '/multicast/listener'
5
6
  require File.dirname(__FILE__) + '/multicast/sender'
data/multicast.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{multicast}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marshall Huss"]
12
- s.date = %q{2010-05-20}
12
+ s.date = %q{2010-05-21}
13
13
  s.description = %q{Multicasting in Ruby}
14
14
  s.email = %q{mwhuss@gmail.com}
15
15
  s.executables = ["mclisten", "mcsend"]
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  "bin/mcsend",
29
29
  "lib/multicast.rb",
30
30
  "lib/multicast/listener.rb",
31
+ "lib/multicast/message.rb",
31
32
  "lib/multicast/sender.rb",
32
33
  "multicast.gemspec",
33
34
  "test/helper.rb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multicast
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marshall Huss
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-05-20 00:00:00 -04:00
18
+ date: 2010-05-21 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -69,6 +69,7 @@ files:
69
69
  - bin/mcsend
70
70
  - lib/multicast.rb
71
71
  - lib/multicast/listener.rb
72
+ - lib/multicast/message.rb
72
73
  - lib/multicast/sender.rb
73
74
  - multicast.gemspec
74
75
  - test/helper.rb