GithubHelp home page GithubHelp logo

bk138 / wxservdisc Goto Github PK

View Code? Open in Web Editor NEW
10.0 4.0 4.0 212 KB

wxServDisc is a simple to use C++ dropin-class/ library to facilitate Zeroconf service discovery in any wxWidgets application, without any other dependencies than wxWidgets. It works under UNIX, Mac OS X and Windows. A sample app is included.

License: GNU General Public License v2.0

C++ 26.64% C 61.85% Makefile 4.50% M4 3.72% NSIS 1.87% CMake 1.43%
wxwidgets zeroconf mdns bonjour

wxservdisc's Introduction

CI

wxServDisc - a wxwidgets zeroconf service discovery module

API:

// type can be one of QTYPE_A, QTYPE_NS, QTYPE_CNAME, QTYPE_PTR or QTYPE_SRV  
wxServDisc(void* parent, const wxString& what, int type);
~wxServDisc();

// yeah well...
std::vector<wxSDEntry> getResults() const;
size_t getResultCount() const;

// get query name
const wxString& getQuery() const { const wxString& ref = query; return ref; };
// get error string
const wxString& getErr() const { const wxString& ref = err; return ref; };

Typically you would do a three-stage query when looking up the address of a service instance (look into sdwrap sample to see how it's done...):

wxServDisc *servscan = new wxServDisc(this, wxT("_rfb._tcp.local."), QTYPE_PTR);
wxServDisc namescan(0, servscan->getResults().at(0).name, QTYPE_SRV);
wxServDisc addrscan(0, namescan.getResults().at(0).name;, QTYPE_A);
wxString addr = addrscan.getResults().at(0).ip;

Ah yes and a wxServDisc instance sends a custom event when sth. is discovered. so you have to add it to your event table, if you want to use it:

// map recv of wxServDiscNOTIFY to some method
BEGIN_EVENT_TABLE(MyFrameMain, FrameMain)
   EVT_COMMAND  (wxID_ANY, wxServDiscNOTIFY, MyFrameMain::onSDNotify)
END_EVENT_TABLE()

In that event listener function, you can then call getResults().

wxServDisc uses mdnsd (C) Jer [email protected] internally.

BUILDING:

Prerequisites: wxWidgets >= 2.8

wxServDisc uses CMake as its build system. Thus, it's the usual:

mkdir build
cd build
cmake ..
make

from the root of the source tree.

That's it, have fun!

christian beier [email protected]

wxservdisc's People

Contributors

bk138 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.