mikaelho / multipeer Goto Github PK
View Code? Open in Web Editor NEWPythonista class for iOS multipeer connectivity
License: The Unlicense
Pythonista class for iOS multipeer connectivity
License: The Unlicense
hi @mikaelho
the code is not reentrant if I do extract the demo chat code from multipeer.py into a separate file lets say demochat.py.
demochat.py runs fine the first time, but when you exit it and run it again it will not find any peers.
the curios thing is that when you run the demochat inside the multipeer.py then you can exit and rerun it as often you like it will always find the peers.
In other words, running the multipeer.py itself is completely reentrant. But calling the multipeer API from another file is not.
Do you have any ideas ?
Maybe it has something to do with the delegates, which you only create once??
Hi @mikaelho
i made a small program to speed test the different communication modes of multiplier connectivity via your API. For the test it send small text string 'ping' over to another peer that peer answers the incoming message with a 'reping'. The program does this 1000 times to get a reasonable average.
So here are the results for the different modes:
11.85ms send method unreliable
11.94ms send method reliable
6.19ms stream method
there is effective no difference in latency whether using send method mode reliable or unreliable. When you run the test again it is unpredictable which one has lower latency.
But stream makes really the difference.
When I measured it last month or so, I saw unstable latency values with the send method. But it turned out that the latency came from the GUI, (maybe garbage collector?) sometimes I saw values of 240 or so.
Now I changed the benchmark program that it takes 1000 probes automatically without GUI intervention. And the 1000 probes are very close to each other I see no statistical outliers anymore.
So yeah. You brought latency effectively down a lot with streams. So great!!!
Before I saw these good values for streams, I had to remove some debug code in multipeer.py. You still have some debug-log code in method 'stream_handleEvent_' where you write to a file named 'l'. I also disabled global logging by inserting a 'pass' into the method 'log_this'. Maybe you still would like to do some housekeeping ? Or should I do it and send you the pull request ?
Thanks a lot for this addition !!! This is soo great !
Line 300 in de0d913
It has certainly no effect on running the demo. But for understanding the code this is maybe a bit misleading...
Or am I wrong???
flake8 testing of https://github.com/mikaelho/multipeer on Python 3.6.3
$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
./multipeer_chat.py:9:18: F821 undefined name 'MultipeerConnectivity'
class ChatPeer(MultipeerConnectivity):
^
./multipeer_chat.py:11:6: F821 undefined name 'on_main_thread'
@on_main_thread
^
./multipeer_chat.py:15:6: F821 undefined name 'on_main_thread'
@on_main_thread
^
./multipeer_chat.py:24:6: F821 undefined name 'on_main_thread'
@on_main_thread
^
4 F821 undefined name 'MultipeerConnectivity'
4
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.