Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rickkas7/serverlocator
Sample code for locating Particle Photons on your local network for direct client-server communication
https://github.com/rickkas7/serverlocator
Last synced: 3 months ago
JSON representation
Sample code for locating Particle Photons on your local network for direct client-server communication
- Host: GitHub
- URL: https://github.com/rickkas7/serverlocator
- Owner: rickkas7
- License: mit
- Created: 2016-08-04T12:56:35.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-04T13:27:50.000Z (over 8 years ago)
- Last Synced: 2024-04-05T22:38:35.784Z (7 months ago)
- Language: C++
- Size: 3.91 KB
- Stars: 11
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-particle - Photon Network Locator Example
README
# serverlocator
*Sample code for locating Particle Photons on your local network for direct client-server communication*
Often, publish and subscribe is the most convenient way for two Particle Photons to communicate. But sometimes when you have two or more Photons on a local network, sometimes you may want to use direct client-server communications using TCP or UDP. Some common reasons:
- Your data is too large
- You need to send data very frequently
- You have limited or no connectivity to the InternetOne problem is that to put the server on a Photon, the IP address is often dynamic. Having to code this address into all of the clients when it might change can be a problem.
This sample code implements two ways of solving this problem:
- Using publish and subcribe (pubsubserverlocator)
- Using UDP multicast (mcastserverlocator)The first method is easier; the second can be used even if you have no Internet access. In fact, the mcastserverlocator examples run in WiFi-only mode, with no cloud connection at all.
In each directory there is a "c" directory (cpubsubserverlocator, for example) that's the client Photon code and an "s" directory that's the server Photon code.
I also have another example that uses a [local server written in node.js] (https://github.com/rickkas7/localserver) that uses publish and subscribe to not only locate the server IP address, but also for authentication.
There's another technology, [mdns] (https://en.wikipedia.org/wiki/Multicast_DNS), that could also be used. There is an [mdns server for the Photon] (https://github.com/mrhornsby/spark-core-mdns). It's really useful if you're running a HTTP server on your Photon and you want to connect to it from a web browser Mac or Linux. The problem is that there isn't an mdns client, and it adds a lot of complexity that you don't need for Photon to Photon communication, so I didn't use it here.