Class: MulticastHandler

Inherits:
EventMachine::Connection
  • Object
show all
Defined in:
lib/QWebChannel/MulticastHandler.rb

Instance Method Summary collapse

Instance Method Details

#castData(packageString) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/QWebChannel/MulticastHandler.rb', line 7

def castData(packageString)
    multicastHost = '239.173.40.5' #组播组主机地址。
    multicastPort = 11500 #组播组端口。

#         print("castData\n") #Debug.
#         send_data(packageString)
    send_datagram(packageString, multicastHost, multicastPort) #发送组播数据包。
end

#post_initObject



20
21
22
23
24
25
# File 'lib/QWebChannel/MulticastHandler.rb', line 20

def post_init
#         print("post_init\n") #Debug.
    port, host = Socket::unpack_sockaddr_in( get_sockname() )
    ip = IPAddr.new( host ).hton + IPAddr.new("0.0.0.0").hton
    set_sock_opt( Socket::IPPROTO_IP, Socket::IP_ADD_MEMBERSHIP, ip )
end

#receive_data(data) ⇒ Object



16
17
18
# File 'lib/QWebChannel/MulticastHandler.rb', line 16

def receive_data(data)
#         puts data
end