25 Q_UNUSED(LanServiceName);
26 Q_UNUSED(LanServicePort);
27 Q_UNUSED(LanServiceProtocolType);
35 servicePublishMessage->
set_name (LanServiceName);
36 servicePublishMessage->
set_port (LanServicePort);
41 string packageString=existMessage.SerializeAsString ();
44 networkThread.castData(packageString);
50 void ServicePublisher::listen()
61 void ServicePublisher::processDatagram(
char * datagram,
int datagramLength, Poco::Net::SocketAddress senderAddress)
64 Q_UNUSED(senderAddress);
72 string datagramtoStdString(datagram,datagramLength);
76 existMessage.ParseFromString (datagramtoStdString);
82 case ExistMessage::SERVICEPUBLISH:
83 reportServiceDiscovered(existMessage,senderAddress.host().toString());
101 void ServicePublisher::reportServiceDiscovered(
ExistMessage existMessage,
string address)
105 string serviceName=servicePublishMessage.
name ();
106 quint16 servicePort=servicePublishMessage.
port ();
110 (void)(serviceProtocolType);
119 void ServicePublisher::startNetworkThread()
121 networkPocoThread.start(networkThread);
ExistCpp的主要接口,用于向局域网发布服务。
void publishService(string LanServiceName, quint16 LanServicePort, exist::ServicePublishMessage::ServiceProtocolType LanServiceProtocolType)
发布服务。
::com::stupidbeauty::exist::ServicePublishMessage_ServiceProtocolType protocoltype() const
const ::std::string & name() const
void set_protocoltype(::com::stupidbeauty::exist::ServicePublishMessage_ServiceProtocolType value)
ServicePublishMessage_ServiceProtocolType
::com::stupidbeauty::exist::ExistMessage_MessageType messagetype() const
void set_port(::google::protobuf::int32 value)
::google::protobuf::int32 port() const
::com::stupidbeauty::exist::ServicePublishMessage * mutable_servicepublishmessage()
const ::com::stupidbeauty::exist::ServicePublishMessage & servicepublishmessage() const
ServicePublisher()
默认构造函数。
void set_name(const ::std::string &value)
void set_messagetype(::com::stupidbeauty::exist::ExistMessage_MessageType value)