JubeatPlus 3.9.11
Loading...
Searching...
No Matches
SharePlayManager.h
Go to the documentation of this file.
1
16
17#import <Foundation/Foundation.h>
18#import <MultipeerConnectivity/MultipeerConnectivity.h>
19
20@class SharePlayManager;
21
22NS_ASSUME_NONNULL_BEGIN
23
28@protocol SharePlayManagerDelegate <NSObject>
29
30@optional
36- (void)sharePlayManager:(SharePlayManager *)manager receiveProgress:(float)progress;
42- (void)sharePlayManager:(SharePlayManager *)manager findHostID:(MCPeerID *)hostID;
48- (void)sharePlayManager:(SharePlayManager *)manager lostHostID:(MCPeerID *)hostID;
53- (void)sharePlayManagerConnectHost:(SharePlayManager *)manager;
58- (void)sharePlayManagerDisconnect:(SharePlayManager *)manager;
64- (void)sharePlayManager:(SharePlayManager *)manager disconnectClient:(MCPeerID *)peer;
70- (void)sharePlayManager:(SharePlayManager *)manager receiveExistMusicData:(BOOL)exist;
75- (void)sharePlayManagerSuccessSendMusicData:(SharePlayManager *)manager;
80- (void)sharePlayManagerHostSelectStart:(SharePlayManager *)manager;
86- (void)sharePlayManager:(SharePlayManager *)manager startMusicTime:(float)time;
93- (BOOL)sharePlayManager:(SharePlayManager *)manager receiveMusicInfo:(NSDictionary *)musicInfo;
100- (BOOL)sharePlayManager:(SharePlayManager *)manager musicDataReceived:(NSData *)musicData;
105- (void)sharePlayManagerAllClientReady:(SharePlayManager *)manager;
110- (void)sharePlayManagerAllClientLoaded:(SharePlayManager *)manager;
115- (void)sharePlayManagerConnectClient:(SharePlayManager *)manager;
121- (void)sharePlayManager:(SharePlayManager *)manager receiveScore:(int)score;
129- (void)sharePlayManager:(SharePlayManager *)manager
130 receiveFinalScore:(int)score
131 bonus:(int)bonus
132 fullCombo:(BOOL)fullCombo;
133
134@end
135
139@interface SharePlayManager : NSObject <MCNearbyServiceBrowserDelegate,
140 MCNearbyServiceAdvertiserDelegate,
141 MCSessionDelegate,
142 NSStreamDelegate>
143
145@property(nonatomic, readonly) BOOL isHost;
147@property(nonatomic, readonly, nullable) NSString *partnerScreenName;
149@property(nonatomic, strong, nullable) MCSession *session;
151@property(nonatomic, weak, nullable) id<SharePlayManagerDelegate> delegate;
153@property(nonatomic, assign, nullable) NSString *displayName;
154
161- (instancetype)initWithScreenName:(nullable NSString *)screenName;
162
164- (void)sessionCreate;
166- (void)startClient;
173- (void)startHostModeWithMusicInfo:(NSDictionary *)musicInfo filePath:(NSString *)filePath;
174
176- (void)connectCancel;
178- (void)disconnect;
179
182- (void)sendSelectStart;
184- (void)startPlaySync;
186- (void)sendClientReady;
187
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;
212
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;
233
240- (void)changeState:(MCPeerID *)peer state:(MCSessionState)state;
241
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;
304
310- (void)sendConnectRequest:(MCPeerID *)peer;
316- (void)sendHostClock:(MCPeerID *)peer;
317
320- (void)checkFinishStatus;
326- (void)receiveScore:(NSNumber *)score;
332- (void)receiveFinalData:(NSDictionary *)finalData;
333
338
344- (void)sendScore:(int)score;
352- (void)sendFinalScore:(int)score bonus:(int)bonus fullCombo:(BOOL)fullCombo;
353
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;
376
383- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode;
384
385@end
386
387NS_ASSUME_NONNULL_END
388
389// code: language=Objective-C
390// kate: hl Objective-C;
391// vim: set ft=objc :
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