JubeatPlus 3.9.11
Loading...
Searching...
No Matches
SharePlayManager Class Reference

Manages a two-peer MultipeerConnectivity session for shared ("versus") play. More...

#include <SharePlayManager.h>

Inheritance diagram for SharePlayManager:
Collaboration diagram for SharePlayManager:

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.

Detailed Description

Manages a two-peer MultipeerConnectivity session for shared ("versus") play.

Method Documentation

◆ advertiser:didNotStartAdvertisingPeer:

- (void) advertiser: (MCNearbyServiceAdvertiser *) advertiser
didNotStartAdvertisingPeer: (NSError *) error 

Advertising failed to start.

Parameters
advertiserThe advertiser that failed.
errorThe failure.
Ghidra address:
0xc5d94

◆ advertiser:didReceiveInvitationFromPeer:withContext:invitationHandler:

- (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.

Parameters
advertiserThe advertiser that received the invitation.
peerIDThe inviting peer.
contextThe invitation's context data, or nil when none was sent.
handlerCalled with the accept decision and the session to join.
Ghidra address:
0xc5d98

◆ browser:didNotStartBrowsingForPeers:

- (void) browser: (MCNearbyServiceBrowser *) browser
didNotStartBrowsingForPeers: (NSError *) error 

Browsing failed to start.

Parameters
browserThe browser that failed.
errorThe failure.
Ghidra address:
0xc5d90

◆ browser:foundPeer:withDiscoveryInfo:

- (void) browser: (MCNearbyServiceBrowser *) browser
foundPeer: (MCPeerID *) peerID
withDiscoveryInfo: (nullable NSDictionary< NSString *, NSString * > *) info 

A candidate host was found while browsing.

Parameters
browserThe browser reporting the peer.
peerIDThe peer that was found.
infoThe peer's discovery information, or nil when it advertised none.
Ghidra address:
0xc5c08

◆ browser:lostPeer:

- (void) browser: (MCNearbyServiceBrowser *) browser
lostPeer: (MCPeerID *) peerID 

A previously found host was lost.

Parameters
browserThe browser reporting the loss.
peerIDThe peer that was lost.
Ghidra address:
0xc5ccc

◆ changeState:state:

- (void) changeState: (MCPeerID *) peer
state: (MCSessionState) state 

Drives the connection state machine for a peer.

Parameters
peerThe peer whose state changed.
stateThe new session state.
Ghidra address:
0xc5e98
Ghidra address:
0xc6128
Ghidra address:
0xc6068

◆ checkFinishStatus

- (void) checkFinishStatus

Host: if both sides finished, exchanges and reports the final result.

Ghidra address:

0xc7548

◆ checkMusicDataLoadingStatus

- (void) checkMusicDataLoadingStatus

Notifies the delegate once both sides have loaded the chart.

Ghidra address:
0xc7d64

◆ completeLoadingMusicData

- (void) completeLoadingMusicData

Marks this side's chart as loaded and reconciles or reports it.

Ghidra address:
0xc7e4c

◆ connectCancel

- (void) connectCancel

Tears down advertising, browsing, streams, and the session.

Ghidra address:
0xc5708

◆ disconnect

- (void) disconnect

Disconnects from the session.

Ghidra address:
0xc5898

◆ initWithScreenName:

- (instancetype) initWithScreenName: (nullable NSString *) screenName

Designated initialiser.

Parameters
screenNameThe name to advertise, or nil to use the device name.
Returns
The initialised manager.
Ghidra address:
0xc51e4

◆ receiveData:data:fromPeer:

- (void) receiveData: (MCSession *) session
data: (NSData *) data
fromPeer: (MCPeerID *) peer 

Decodes and dispatches a received message by its dataType tag.

Parameters
sessionThe session the data arrived on.
dataThe archived message payload.
peerThe originating peer.
Ghidra address:
0xc62cc

◆ receiveFinalData:

- (void) receiveFinalData: (NSDictionary *) finalData

Records the peer's end-of-play result and reports or reconciles it.

Parameters
finalDataThe peer's final-result dictionary.
Ghidra address:
0xc79fc

◆ receiveScore:

- (void) receiveScore: (NSNumber *) score

Records a mid-play score for the peer and notifies the delegate.

Parameters
scoreThe peer's score, boxed.
Ghidra address:
0xc78fc

◆ sendClientReady

- (void) sendClientReady

Client: tells the host it is ready to load the chart.

Ghidra address:
0xc5b6c

◆ sendConnectRequest:

- (void) sendConnectRequest: (MCPeerID *) peer

Client: invites the given host peer to this device's session.

Parameters
peerThe host peer to invite.
Ghidra address:
0xc7324

◆ sendData:toPeer:

- (void) sendData: (NSData *) data
toPeer: (MCPeerID *) peer 

Sends an archived payload to a single peer reliably.

Parameters
dataThe archived payload.
peerThe destination peer.
Ghidra address:
0xc84b0

◆ sendDataStream:toPeer:dataName:

- (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.

Parameters
dataThe payload to stream.
peerThe destination peer.
dataNameThe stream name.
Ghidra address:
0xc8568
Ghidra address:
0xc8690

◆ sendFinalScore:bonus:fullCombo:

- (void) sendFinalScore: (int) score
bonus: (int) bonus
fullCombo: (BOOL) fullCombo 

Sends the end-of-play result, or records it on the host.

Parameters
scoreThe final score.
bonusThe end-of-play bonus.
fullComboWhether a full combo was achieved.
Ghidra address:
0xc80b8

◆ sendHostClock:

- (void) sendHostClock: (MCPeerID *) peer

Host: sends its current clock and counts a ping attempt.

Parameters
peerThe client peer.
Ghidra address:
0xc73ec

◆ sendScore:

- (void) sendScore: (int) score

Sends a mid-play score to the peer.

Parameters
scoreThe score to send.
Ghidra address:
0xc7f34

◆ sendSelectStart

- (void) sendSelectStart

Host: tells the client the song was chosen and play should begin.

Ghidra address:
0xc58a4

◆ sendTypeData:toPeer:

- (void) sendTypeData: (int) type
toPeer: (MCPeerID *) peer 

Archives a bare message-type tag and sends it to the peer.

Parameters
typeThe message-type tag.
peerThe destination peer.
Ghidra address:
0xc83b8

◆ session:didFinishReceivingResourceWithName:fromPeer:atURL:withError:

- (void) session: (MCSession *) session
didFinishReceivingResourceWithName: (NSString *) resourceName
fromPeer: (MCPeerID *) peerID
atURL: (nullable NSURL *) localURL
withError: (nullable NSError *) error 

Resource-transfer finish callback (unused).

Parameters
sessionThe session the transfer arrived on.
resourceNameThe resource's name.
peerIDThe peer that sent it.
localURLWhere the resource was written, or nil on failure.
errorThe failure, or nil on success.
Ghidra address:
0xc7320

◆ session:didReceiveData:fromPeer:

- (void) session: (MCSession *) session
didReceiveData: (NSData *) data
fromPeer: (MCPeerID *) peerID 

Data-received callback; defers handling to -receiveData:data:fromPeer: on the main queue.

Parameters
sessionThe session the data arrived on.
dataThe received payload.
peerIDThe peer that sent it.
Ghidra address:
0xc70e4
Ghidra address:
0xc71e8

◆ session:didReceiveStream:withName:fromPeer:

- (void) session: (MCSession *) session
didReceiveStream: (NSInputStream *) stream
withName: (NSString *) streamName
fromPeer: (MCPeerID *) peerID 

Stream-received callback; schedules the input stream and opens it.

Parameters
sessionThe session the stream arrived on.
streamThe incoming stream.
streamNameThe stream's name.
peerIDThe peer that opened it.
Ghidra address:
0xc7270

◆ session:didStartReceivingResourceWithName:fromPeer:withProgress:

- (void) session: (MCSession *) session
didStartReceivingResourceWithName: (NSString *) resourceName
fromPeer: (MCPeerID *) peerID
withProgress: (NSProgress *) progress 

Resource-transfer start callback (unused).

Parameters
sessionThe session the transfer arrived on.
resourceNameThe resource's name.
peerIDThe peer sending it.
progressThe transfer's progress.
Ghidra address:
0xc731c

◆ session:peer:didChangeState:

- (void) session: (MCSession *) session
peer: (MCPeerID *) peerID
didChangeState: (MCSessionState) state 

Session-state change callback; forwards to -changeState:state:.

Parameters
sessionThe session reporting the change.
peerIDThe peer whose state changed.
stateThe peer's new state.
Ghidra address:
0xc62b8

◆ sessionCreate

- (void) sessionCreate

Creates the MCSession bound to this device's peer.

Ghidra address:
0xc5324

◆ startClient

- (void) startClient

Starts browsing for a host as a client.

Ghidra address:
0xc53b8

◆ startHostModeWithMusicInfo:filePath:

- (void) startHostModeWithMusicInfo: (NSDictionary *) musicInfo
filePath: (NSString *) filePath 

Starts advertising as a host with the chosen song.

Parameters
musicInfoThe song's metadata; the file size is added under fileSize.
filePathThe path to the music data file.
Ghidra address:
0xc54a8

◆ startPlaySync

- (void) startPlaySync

Host: begins the clock-corrected start-of-play countdown.

Ghidra address:
0xc5954

◆ stream:handleEvent:

- (void) stream: (NSStream *) stream
handleEvent: (NSStreamEvent) eventCode 

Input-stream event handler; accumulates the incoming music data and acks completion.

Parameters
streamThe stream reporting the event.
eventCodeThe event that occurred.
Ghidra address:
0xc8840
Ghidra address:
0xc8d1c

Property Documentation

◆ isHost

- (BOOL) isHost
readnonatomicassign

Whether this device is the host of the session.

Ghidra address:
0xc51d4

The documentation for this class was generated from the following files: