17#import <Foundation/Foundation.h>
18#import <MultipeerConnectivity/MultipeerConnectivity.h>
22NS_ASSUME_NONNULL_BEGIN
28@protocol SharePlayManagerDelegate <NSObject>
93- (BOOL)sharePlayManager:(
SharePlayManager *)manager receiveMusicInfo:(NSDictionary *)musicInfo;
130 receiveFinalScore:(
int)score
132 fullCombo:(BOOL)fullCombo;
140 MCNearbyServiceAdvertiserDelegate,
145@property(nonatomic, readonly) BOOL
isHost;
149@property(nonatomic, strong, nullable) MCSession *
session;
151@property(nonatomic, weak, nullable) id<SharePlayManagerDelegate>
delegate;
161- (instancetype)initWithScreenName:(nullable NSString *)screenName;
173- (void)startHostModeWithMusicInfo:(NSDictionary *)musicInfo filePath:(NSString *)filePath;
195- (void)browser:(MCNearbyServiceBrowser *)browser
196 foundPeer:(MCPeerID *)peerID
197 withDiscoveryInfo:(nullable NSDictionary<NSString *, NSString *> *)info;
204- (void)browser:(MCNearbyServiceBrowser *)browser lostPeer:(MCPeerID *)peerID;
211- (void)browser:(MCNearbyServiceBrowser *)browser didNotStartBrowsingForPeers:(NSError *)error;
219- (void)advertiser:(MCNearbyServiceAdvertiser *)advertiser
220 didNotStartAdvertisingPeer:(NSError *)error;
229- (void)advertiser:(MCNearbyServiceAdvertiser *)advertiser
230 didReceiveInvitationFromPeer:(MCPeerID *)peerID
231 withContext:(nullable NSData *)context
232 invitationHandler:(
void (^)(BOOL accept, MCSession *_Nullable
session))handler;
240- (void)changeState:(MCPeerID *)peer state:(MCSessionState)state;
249- (void)
session:(MCSession *)session peer:(MCPeerID *)peerID didChangeState:(MCSessionState)state;
257- (void)receiveData:(MCSession *)session data:(NSData *)data fromPeer:(MCPeerID *)peer;
265- (void)
session:(MCSession *)session didReceiveData:(NSData *)data fromPeer:(MCPeerID *)peerID;
274- (void)
session:(MCSession *)session
275 didReceiveStream:(NSInputStream *)stream
276 withName:(NSString *)streamName
277 fromPeer:(MCPeerID *)peerID;
286- (void)
session:(MCSession *)session
287 didStartReceivingResourceWithName:(NSString *)resourceName
288 fromPeer:(MCPeerID *)peerID
289 withProgress:(NSProgress *)progress;
299- (void)
session:(MCSession *)session
300 didFinishReceivingResourceWithName:(NSString *)resourceName
301 fromPeer:(MCPeerID *)peerID
302 atURL:(nullable NSURL *)localURL
303 withError:(nullable NSError *)error;
310- (void)sendConnectRequest:(MCPeerID *)peer;
316- (void)sendHostClock:(MCPeerID *)peer;
326- (void)receiveScore:(NSNumber *)score;
332- (void)receiveFinalData:(NSDictionary *)finalData;
344- (void)sendScore:(
int)score;
352- (void)sendFinalScore:(
int)score bonus:(
int)bonus fullCombo:(BOOL)fullCombo;
360- (void)sendTypeData:(
int)type toPeer:(MCPeerID *)peer;
367- (void)sendData:(NSData *)data toPeer:(MCPeerID *)peer;
375- (void)sendDataStream:(NSData *)data toPeer:(MCPeerID *)peer dataName:(NSString *)dataName;
383- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode;
Manages a two-peer MultipeerConnectivity session for shared ("versus") play.
Definition SharePlayManager.h:142
void startClient()
Starts browsing for a host as a client.
Definition SharePlayManager.m:109
void checkFinishStatus()
Host: if both sides finished, exchanges and reports the final result.
Definition SharePlayManager.m:483
void sendSelectStart()
Host: tells the client the song was chosen and play should begin.
Definition SharePlayManager.m:175
void completeLoadingMusicData()
Marks this side's chart as loaded and reconciles or reports it.
Definition SharePlayManager.m:551
NSString * partnerScreenName
The connected partner's display name, or nil before one connects.
Definition SharePlayManager.m:672
void disconnect()
Disconnects from the session.
Definition SharePlayManager.m:169
void sendClientReady()
Client: tells the host it is ready to load the chart.
Definition SharePlayManager.m:195
void startPlaySync()
Host: begins the clock-corrected start-of-play countdown.
Definition SharePlayManager.m:181
MCSession * session
The underlying multipeer session.
Definition SharePlayManager.h:149
BOOL isHost
Whether this device is the host of the session.
Definition SharePlayManager.m:79
void sessionCreate()
Creates the MCSession bound to this device's peer.
Definition SharePlayManager.m:101
id< SharePlayManagerDelegate > delegate
The event delegate.
Definition SharePlayManager.h:151
void checkMusicDataLoadingStatus()
Notifies the delegate once both sides have loaded the chart.
Definition SharePlayManager.m:543
NSString * displayName
The display name advertised for this device's peer.
Definition SharePlayManager.h:153
void connectCancel()
Tears down advertising, browsing, streams, and the session.
Definition SharePlayManager.m:142