multipeer | Pythonista class for iOS multipeer connectivity
kandi X-RAY | multipeer Summary
kandi X-RAY | multipeer Summary
Peer IDs passed around by the wrapper have a display_name member that gives you the display name of that peer. There is no guarantee that these names are unique between peers. The IDs act also as identifier objects for specific peers, and can be used to send messages to individual peers. You cannot create peer IDs for remote peers manually.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Select the player s color
- Start a random robot
- Move the cursor forward
- Calls the given function with the given arguments
- Invoked when a Peer is received
- Check if the current track is open
- Collect stats for a peer
- Sets up an output stream
- Send message to peer
- Get list of connected peers
- Called when all players have completed
- Send message to peers
- Called when a session received data from a peer
- Called when a player is committed
- Add a turn
- Update the player track
- Handle incoming message
- Called when the player is committed
- Called when a stream is received from a peer
- Gets the next turn
- Called when the peer has changed
- Called when a player is found
- Called when a browser is found
- Receive incoming data from peer
- Context manager that creates a menu
- Return the next turn in the track
- Context manager for all players
multipeer Key Features
multipeer Examples and Code Snippets
import multipeer
my_name = input('Name: ')
mc = multipeer.MultipeerConnectivity(display_name=my_name,
service_type='chat')
try:
while True:
chat_message = input('Message: ')
mc.send(chat_message)
finally:
mc.end_all()
mc = MultipeerConnectivity(display_name='Peer', service_type='dev-srv')
Community Discussions
Trending Discussions on multipeer
QUESTION
The same error is also triggered setting up Multipeer Connectivity (which uses Bonjour). The code I was using for initiating Bonjour browsing and Multipeer Connectivity was modified from the Apple sample code and worked fine under iOS 13.
...ANSWER
Answered 2020-Dec-07 at 21:59You need to add the following keys to the Info.plist: NSLocalNetworkUsageDescription and NSBonjourServices. E.g.
QUESTION
I am currently working for WebRTC multipeer connection. I want to implement feature to switch camera from front to back while on call. This is the code I am using to switch cameras
...ANSWER
Answered 2020-Jul-28 at 12:56You are probably being unable to cause a renegotiaton so change to the facingMode
of your camera cannot affect the other peers, but you do not use this explicitely as I see but replaceTracks
. But still you may not being able to trigger a renegotiation. Checkout things that cause renegotiation: https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpSender/replaceTrack#Usage_notes
Changing facingMode
setting by applying constraints with applyConstraints
may be a solution without using replaceTracks
.
A strange idea coming to my mind to dispatch negotiationneeded
event yourself, but I would try this after chasing the reason not being able to casue renegotiation itself by replacing track, or changing camera, and everything else.
About another reason: As for the reasons that casues renegotiation, your back camera resolution is most probably higher than the front camera, so it looks like a reason. If you start from the back camera first and then switch to front it might have been a no reason. I am suspicious about your max
constraints of width
nad height
. They might be very lower for the both camera hence resulting in the same size, resoltion and so a no reason according to the list in the linked page above. I suggest removing them.
Also the replaceTracks
returns a promise but the map function it is called from does not return anything, hence undefined
. You are supposed to use the promises inside the array argument to Promise.all
. I would suggest return
those promises inside the map
function.
QUESTION
I've got an app that supports Bonjour and manually connecting to an IP (all within the same local network). I'm now looking at whether I can use MPC instead and while it obviously would be able to replace Bonjour, I haven't seen anything that allows me to replace the functionality around manually connecting to the IP. For context, my app runs in networks that have multicast disabled which is when users fall back to manually entering the IP address.
I could have the receiving app host a webserver and send a request there. Could I create a Peer based on the ip:port combination? That would allow me to make use of MPC for the MCSession aspect.
Is it possible to set up a Multipeer Connection based on an ip:port rather than having it automatically discovered via multicast?
...ANSWER
Answered 2020-Jun-25 at 19:18I'll go with a solution based on NWConnection
which uses NWEndpoint
and can be created with both IP:port and a Bonjour-established service.
If I would've had access to the full Network.framework
then I could've used that for both discovery & communication but due to SDK constraints I'll be using MultipeerConnectivity for the discovery aspect instead. By providing the device its IP & port when broadcasting the Bonjour service, another device can discover it automatically and then use the extra info to create an IP:port-based NWConnection
.
QUESTION
I have created a multipeer network.
I have created 3 orgs StancOrg
, StancOrgA
,StancOrgB
.Here's the configtx.yaml file.
ANSWER
Answered 2019-Jan-15 at 20:22Paths should be set using the full path /home/user/yourPath
instead of the shortcut ~/yourPath
.
Anyway, remember always to check the app logs and not just the console since sometimes they show much more information.
QUESTION
I am trying to build a basic application to send messages between nearby iOS devices with Multipeer Connectivity Framework. I have tried many tutorials but it seems in Xcode 11 browsing nearby devices and accepting requests does not work as it did before.
Here is my view controller & delegate methods:
...ANSWER
Answered 2019-Oct-26 at 21:48It seems MCAdvertiserAssistant
and MCBrowserViewController
are not updated for latest versions of iOS & Swift, hence they're not working properly.
I solved it by using MCNearbyServiceAdvertiser
instead of MCAdvertiserAssistant
and MCNearbyServiceBrowser
instead of MCBrowserViewController
. Note that by using these classes, you'll need to perform basic operations yourself such as listing founded devices, showing and handling invitation alert.. etc.
You can use these classes as below.
Definition:
QUESTION
I'm trying to use MultiPeer Connectivity framework with swift ui and am having issues with using ForEach in my view. I have a singleton that I'm using to track connected users in an array:
...ANSWER
Answered 2019-Aug-03 at 09:58There are a couple issues here as far as I can tell.
First, I would suggest you try this with your MPCManager
:
QUESTION
TLDR:
When other devices call the invitationHandler
after they receive the invitation, I want the device who sent the invitation to know which device(s) accepted the invitation and which device(s) declined it.
To avoid being an XY problem, here's what I'm doing:
I am using Multipeer Connectivity for a 2-4 player game.
The flow of my app is going to be like this:
- Devices can set their visibility to others by pressing a button
- One of the 2-4 players of the game, let's call him Player A, will press a button and he/she will see a list of nearby players
- Player A will choose 1-3 players from the list that he wants to add to the game
- Other devices use some logic to figure out whether to accept the invitation or decline it.
- After all the invitations Player A sent has been responded to, a button will be enabled and Player A can press it to start the game.
- I am doing this since I don't want new players joining after the game starts. If for example, Player A invites Player B and Player B accepts it. Player A then invites Player C but before Player C receives the invitation, Player A starts the game. The game will start but because only 2 players are connected, a 2-player game will be created. After that the invitation reaches Player C and he accepts it and now suddenly there are 3 people in a 2-player game! This is why I need to ensure all invitations are responded before starting the game.
This is also why I need to know whether a device declined the invitation. I already know how to detect that a device accepted the invitation, just like this:
...ANSWER
Answered 2017-Oct-16 at 07:59When user declines the invitation the device that initiated the invite will get a delegate state change with state = MCSessionStateNotConnected
.
As far as I know this state will also happen if user fails to connect for some reason, but you could distinguish the two flows since when connection fails you will also get state change first to MCSessionStateConnecting
and then to MCSessionStateNotConnected
.
So in short:
- State change from
MCSessionStateConnecting
toMCSessionStateNotConnected
means device failed to connect but invite was accepted - State only goes to
MCSessionStateConnecting
, means user tapped decline
Given that you need advanced logic when a game can be started you will not be able to rely on the built in MCBrowserViewController
since this will have Done
button enabled as soon as one of the peers is coonected.
You would have to use MCNearbyServiceBrowser
then you initiate each invite with -invitePeer:toSession:withContext:timeout:
and thus you have a way of knowing who was invited, and based on delegate calls who connected, who failed to connect or who declined.
Hope this helps...
QUESTION
I have an array of a custom class that is used to populate a UICollectionView.
Additional arrays of the same custom class are created as they are received from other iOS devices (via Multipeer Connectivity). Data objects are contained within the class type, and so are quite large which I do not want to make copies of and my current logic, I was thinking of retaining them in separate arrays.
With this in mind, how do I manage the UICollectionView delegate methods?
Item count suggestion. Presuming the 2nd array is empty until MPC sends it's data, its count would be 0 :
...ANSWER
Answered 2019-Aug-21 at 20:34You can use a helper computed property:
QUESTION
I am using the Multipeer Connectivity Framework on macOS, and I am trying to implement the functionality of connecting to other peers. I used a MCNearbyServiceBrowser
and displayed the found peers in an NSTableView
. I also have a NSTextField
for people to enter their display name, which will be the display name of their MCPeerID
.
The workflow is as follows: The user enter a display name, selects a peer from the NSTableView
, and press the connect button.
This means that I don't have an MCPeerID
until the connect button is pressed, because before that time the textfield text could still change. However, initialising a MCNearbyServiceBrowser
requires an MCPeerID
, so I thought I could use a dummy peer ID for the browser, then create the real one when the connect button is pressed, like this:
ANSWER
Answered 2019-Aug-21 at 15:39I can think of two solutions: using data contexts or using a second browser
Using data contexts
Use your dummy id but don't rely on its displayName property. Instead pass your real display name via the context parameter of invitePeer(_ peerID: MCPeerID, to session: MCSession, withContext context: Data?, timeout: TimeInterval)
QUESTION
I'm trying to write the browser/discovery side for a Multipeer Connectivity app in Objective-C++. I think I can advertise, as far as I can tell anyways since I can see it using Discovery (https://itunes.apple.com/us/app/discovery-dns-sd-browser/id1381004916?mt=12). But my browser doesn't see anything. What am I doing wrong?
...ANSWER
Answered 2019-Apr-16 at 05:58I (finally) figured it out. MultipeerConnectivity needs a run loop. This is not in the documentation.
I assumed that the MultipeerConnectivity API created the threads and/or loops it needed upon the method call [browser startBrowsingForPeers]
. It does not.
Nowhere in this code is a run loop started. Also, interestingly enough, using a NSThread directly doesn't start a run loop, even though it's implied that it will:
Your application neither creates or explicitly manages NSRunLoop objects. Each NSThread object—including the application’s main thread—has an NSRunLoop object automatically created for it as needed. If you need to access the current thread’s run loop, you do so with the class method currentRunLoop.
What will create a run loop (and start it) is CFRunLoopRun()
:
The current thread’s run loop runs in the default mode (see Default Run Loop Mode) until the run loop is stopped with CFRunLoopStop or all the sources and timers are removed from the default run loop mode.
What will stop it, then, is CFRunLoopStop(CFRunLoopRef rl)
:
This function forces rl to stop running and return control to the function that called CFRunLoopRun or CFRunLoopRunInMode for the current run loop activation.
Of course, CFRunLoopStop
takes a CFRunLoopRef
as an argument. You can get that by using CFRunLoopGetCurrent
, just remember it's a reference and may expire at any time. I think you can be pretty sure that the run loop won't die while you're in the callback that's running in the run loop. But I wouldn't count on it sticking around afterwards. In fact, in this case, the whole point is to kill it at this point; so I expect it to go away.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install multipeer
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page