|
JubeatPlus 3.9.11
|
Manages a two-peer MultipeerConnectivity session for shared ("versus") play. More...
#include <SharePlayManager.h>


Instance Methods | |
| (instancetype) | - initWithScreenName: |
| Designated initialiser. | |
| (void) | - sessionCreate |
| Creates the MCSession bound to this device's peer. | |
| (void) | - startClient |
| Starts browsing for a host as a client. | |
| (void) | - startHostModeWithMusicInfo:filePath: |
| Starts advertising as a host with the chosen song. | |
| (void) | - connectCancel |
| Tears down advertising, browsing, streams, and the session. | |
| (void) | - disconnect |
| Disconnects from the session. | |
| (void) | - sendSelectStart |
| Host: tells the client the song was chosen and play should begin. | |
| (void) | - startPlaySync |
| Host: begins the clock-corrected start-of-play countdown. | |
| (void) | - sendClientReady |
| Client: tells the host it is ready to load the chart. | |
| (void) | - browser:foundPeer:withDiscoveryInfo: |
| A candidate host was found while browsing. | |
| (void) | - browser:lostPeer: |
| A previously found host was lost. | |
| (void) | - browser:didNotStartBrowsingForPeers: |
| Browsing failed to start. | |
| (void) | - advertiser:didNotStartAdvertisingPeer: |
| Advertising failed to start. | |
| (void) | - advertiser:didReceiveInvitationFromPeer:withContext:invitationHandler: |
An invitation arrived while advertising; accepted only while bAccept is set. | |
| (void) | - changeState:state: |
| Drives the connection state machine for a peer. | |
| (void) | - session:peer:didChangeState: |
| Session-state change callback; forwards to -changeState:state:. | |
| (void) | - receiveData:data:fromPeer: |
Decodes and dispatches a received message by its dataType tag. | |
| (void) | - session:didReceiveData:fromPeer: |
| Data-received callback; defers handling to -receiveData:data:fromPeer: on the main queue. | |
| (void) | - session:didReceiveStream:withName:fromPeer: |
| Stream-received callback; schedules the input stream and opens it. | |
| (void) | - session:didStartReceivingResourceWithName:fromPeer:withProgress: |
| Resource-transfer start callback (unused). | |
| (void) | - session:didFinishReceivingResourceWithName:fromPeer:atURL:withError: |
| Resource-transfer finish callback (unused). | |
| (void) | - sendConnectRequest: |
| Client: invites the given host peer to this device's session. | |
| (void) | - sendHostClock: |
| Host: sends its current clock and counts a ping attempt. | |
| (void) | - checkFinishStatus |
| Host: if both sides finished, exchanges and reports the final result. | |
| (void) | - receiveScore: |
| Records a mid-play score for the peer and notifies the delegate. | |
| (void) | - receiveFinalData: |
| Records the peer's end-of-play result and reports or reconciles it. | |
| (void) | - checkMusicDataLoadingStatus |
| Notifies the delegate once both sides have loaded the chart. | |
| (void) | - completeLoadingMusicData |
| Marks this side's chart as loaded and reconciles or reports it. | |
| (void) | - sendScore: |
| Sends a mid-play score to the peer. | |
| (void) | - sendFinalScore:bonus:fullCombo: |
| Sends the end-of-play result, or records it on the host. | |
| (void) | - sendTypeData:toPeer: |
| Archives a bare message-type tag and sends it to the peer. | |
| (void) | - sendData:toPeer: |
| Sends an archived payload to a single peer reliably. | |
| (void) | - sendDataStream:toPeer:dataName: |
| Streams a payload to a peer over a one-shot NSOutputStream on a background queue. | |
| (void) | - stream:handleEvent: |
| Input-stream event handler; accumulates the incoming music data and acks completion. | |
Properties | |
| BOOL | isHost |
| Whether this device is the host of the session. | |
| NSString * | partnerScreenName |
| The connected partner's display name, or nil before one connects. | |
| MCSession * | session |
| The underlying multipeer session. | |
| id< SharePlayManagerDelegate > | delegate |
| The event delegate. | |
| NSString * | displayName |
| The display name advertised for this device's peer. | |
Manages a two-peer MultipeerConnectivity session for shared ("versus") play.
| - (void) advertiser: | (MCNearbyServiceAdvertiser *) | advertiser | |
| didNotStartAdvertisingPeer: | (NSError *) | error |
Advertising failed to start.
| advertiser | The advertiser that failed. |
| error | The failure. |
| - (void) advertiser: | (MCNearbyServiceAdvertiser *) | advertiser | |
| didReceiveInvitationFromPeer: | (MCPeerID *) | peerID | |
| withContext: | (nullable NSData *) | context | |
| invitationHandler: | (void(^)(BOOL accept, MCSession *_Nullable session)) | handler |
An invitation arrived while advertising; accepted only while bAccept is set.
| advertiser | The advertiser that received the invitation. |
| peerID | The inviting peer. |
| context | The invitation's context data, or nil when none was sent. |
| handler | Called with the accept decision and the session to join. |
| - (void) browser: | (MCNearbyServiceBrowser *) | browser | |
| didNotStartBrowsingForPeers: | (NSError *) | error |
Browsing failed to start.
| browser | The browser that failed. |
| error | The failure. |
| - (void) browser: | (MCNearbyServiceBrowser *) | browser | |
| foundPeer: | (MCPeerID *) | peerID | |
| withDiscoveryInfo: | (nullable NSDictionary< NSString *, NSString * > *) | info |
A candidate host was found while browsing.
| browser | The browser reporting the peer. |
| peerID | The peer that was found. |
| info | The peer's discovery information, or nil when it advertised none. |
| - (void) browser: | (MCNearbyServiceBrowser *) | browser | |
| lostPeer: | (MCPeerID *) | peerID |
A previously found host was lost.
| browser | The browser reporting the loss. |
| peerID | The peer that was lost. |
| - (void) changeState: | (MCPeerID *) | peer | |
| state: | (MCSessionState) | state |
Drives the connection state machine for a peer.
| peer | The peer whose state changed. |
| state | The new session state. |
| - (void) checkFinishStatus |
Host: if both sides finished, exchanges and reports the final result.
0xc7548
| - (void) checkMusicDataLoadingStatus |
Notifies the delegate once both sides have loaded the chart.
| - (void) completeLoadingMusicData |
Marks this side's chart as loaded and reconciles or reports it.
| - (void) connectCancel |
Tears down advertising, browsing, streams, and the session.
| - (void) disconnect |
Disconnects from the session.
| - (instancetype) initWithScreenName: | (nullable NSString *) | screenName |
Designated initialiser.
| screenName | The name to advertise, or nil to use the device name. |
| - (void) receiveData: | (MCSession *) | session | |
| data: | (NSData *) | data | |
| fromPeer: | (MCPeerID *) | peer |
Decodes and dispatches a received message by its dataType tag.
| session | The session the data arrived on. |
| data | The archived message payload. |
| peer | The originating peer. |
| - (void) receiveFinalData: | (NSDictionary *) | finalData |
Records the peer's end-of-play result and reports or reconciles it.
| finalData | The peer's final-result dictionary. |
| - (void) receiveScore: | (NSNumber *) | score |
Records a mid-play score for the peer and notifies the delegate.
| score | The peer's score, boxed. |
| - (void) sendClientReady |
Client: tells the host it is ready to load the chart.
| - (void) sendConnectRequest: | (MCPeerID *) | peer |
Client: invites the given host peer to this device's session.
| peer | The host peer to invite. |
| - (void) sendData: | (NSData *) | data | |
| toPeer: | (MCPeerID *) | peer |
Sends an archived payload to a single peer reliably.
| data | The archived payload. |
| peer | The destination peer. |
| - (void) sendDataStream: | (NSData *) | data | |
| toPeer: | (MCPeerID *) | peer | |
| dataName: | (NSString *) | dataName |
Streams a payload to a peer over a one-shot NSOutputStream on a background queue.
| data | The payload to stream. |
| peer | The destination peer. |
| dataName | The stream name. |
| - (void) sendFinalScore: | (int) | score | |
| bonus: | (int) | bonus | |
| fullCombo: | (BOOL) | fullCombo |
Sends the end-of-play result, or records it on the host.
| score | The final score. |
| bonus | The end-of-play bonus. |
| fullCombo | Whether a full combo was achieved. |
| - (void) sendHostClock: | (MCPeerID *) | peer |
Host: sends its current clock and counts a ping attempt.
| peer | The client peer. |
| - (void) sendScore: | (int) | score |
Sends a mid-play score to the peer.
| score | The score to send. |
| - (void) sendSelectStart |
Host: tells the client the song was chosen and play should begin.
| - (void) sendTypeData: | (int) | type | |
| toPeer: | (MCPeerID *) | peer |
Archives a bare message-type tag and sends it to the peer.
| type | The message-type tag. |
| peer | The destination peer. |
| - (void) session: | (MCSession *) | session | |
| didFinishReceivingResourceWithName: | (NSString *) | resourceName | |
| fromPeer: | (MCPeerID *) | peerID | |
| atURL: | (nullable NSURL *) | localURL | |
| withError: | (nullable NSError *) | error |
Resource-transfer finish callback (unused).
| session | The session the transfer arrived on. |
| resourceName | The resource's name. |
| peerID | The peer that sent it. |
| localURL | Where the resource was written, or nil on failure. |
| error | The failure, or nil on success. |
| - (void) session: | (MCSession *) | session | |
| didReceiveData: | (NSData *) | data | |
| fromPeer: | (MCPeerID *) | peerID |
Data-received callback; defers handling to -receiveData:data:fromPeer: on the main queue.
| session | The session the data arrived on. |
| data | The received payload. |
| peerID | The peer that sent it. |
| - (void) session: | (MCSession *) | session | |
| didReceiveStream: | (NSInputStream *) | stream | |
| withName: | (NSString *) | streamName | |
| fromPeer: | (MCPeerID *) | peerID |
Stream-received callback; schedules the input stream and opens it.
| session | The session the stream arrived on. |
| stream | The incoming stream. |
| streamName | The stream's name. |
| peerID | The peer that opened it. |
| - (void) session: | (MCSession *) | session | |
| didStartReceivingResourceWithName: | (NSString *) | resourceName | |
| fromPeer: | (MCPeerID *) | peerID | |
| withProgress: | (NSProgress *) | progress |
Resource-transfer start callback (unused).
| session | The session the transfer arrived on. |
| resourceName | The resource's name. |
| peerID | The peer sending it. |
| progress | The transfer's progress. |
| - (void) session: | (MCSession *) | session | |
| peer: | (MCPeerID *) | peerID | |
| didChangeState: | (MCSessionState) | state |
Session-state change callback; forwards to -changeState:state:.
| session | The session reporting the change. |
| peerID | The peer whose state changed. |
| state | The peer's new state. |
| - (void) sessionCreate |
Creates the MCSession bound to this device's peer.
| - (void) startClient |
Starts browsing for a host as a client.
| - (void) startHostModeWithMusicInfo: | (NSDictionary *) | musicInfo | |
| filePath: | (NSString *) | filePath |
Starts advertising as a host with the chosen song.
| musicInfo | The song's metadata; the file size is added under fileSize. |
| filePath | The path to the music data file. |
| - (void) startPlaySync |
Host: begins the clock-corrected start-of-play countdown.
| - (void) stream: | (NSStream *) | stream | |
| handleEvent: | (NSStreamEvent) | eventCode |
Input-stream event handler; accumulates the incoming music data and acks completion.
| stream | The stream reporting the event. |
| eventCode | The event that occurred. |
|
readnonatomicassign |
Whether this device is the host of the session.