Class: ExistRuby
- Inherits:
-
Object
- Object
- ExistRuby
- Defined in:
- lib/ExistRuby.rb
Instance Method Summary collapse
-
#initialize ⇒ ExistRuby
constructor
A new instance of ExistRuby.
-
#publishService(lanServiceName, lanServicePort, lanServiceProtocolType) ⇒ Object
Publish a service to the LAN.
Constructor Details
#initialize ⇒ ExistRuby
Returns a new instance of ExistRuby.
7 8 9 10 11 12 |
# File 'lib/ExistRuby.rb', line 7 def initialize host = '239.173.40.5' #组播组主机地址。 port = 11500 #组播组端口。 @networkThread = EM::open_datagram_socket(host, port, MulticastHandler) end |
Instance Method Details
#publishService(lanServiceName, lanServicePort, lanServiceProtocolType) ⇒ Object
Publish a service to the LAN.
Example:
>> existRuby=ExistRuby.new
>> existRuby.publishService("fp_serverPython", 10086, exist::ServicePublishMessage::ServiceProtocolType::GRPC)
Arguments:
lanServiceName: (String)
lanServicePort: (int)
lanServiceProtocolType: (enum)
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ExistRuby.rb', line 24 def publishService(lanServiceName, lanServicePort, lanServiceProtocolType) existMessage=Com::Stupidbeauty::Exist::ExistMessage.new #消息体。 existMessage.= Com::Stupidbeauty::Exist::ExistMessage::MessageType::SERVICEPUBLISH #设置消息类型。 existMessage.servicePublishMessage=Com::Stupidbeauty::Exist::ServicePublishMessage.new #创建服务发布消息体。 existMessage.servicePublishMessage.name=lanServiceName #设置服务名字。 existMessage.servicePublishMessage.port=lanServicePort #设置端口号。 existMessage.servicePublishMessage.protocolType=lanServiceProtocolType #设置协议类型。 packageString=Com::Stupidbeauty::Exist::ExistMessage.encode(existMessage) #序列化为字符串。 #发送: @networkThread.castData(packageString) #发送数据。 end |