registerWrappedClientWithGameHandle:clientDelegate
Register Game Wrapped Client Delegate
This method binds the host application's delegate implementation to a specific game handle. Through this interface, the SDK can request the necessary interaction implementations from the host application (such as UI display, specific business logic callbacks, etc.).
Method Declaration
objectivec
/**
* Sets the delegate client to handle required callbacks and interface
* implementations from the SDK to the host application.
*/
+ (void)registerWrappedClientWithGameHandle:(nonnull id<SUDRTGameHandle>)gameHandle
clientDelegate:(nonnull id<SUDOPWrappedClientDelegate>)clientDelegate;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| gameHandle | id<SUDRTGameHandle> | Yes | The game instance handle returned by the success callback of startGame. |
| clientDelegate | id<SUDOPWrappedClientDelegate> | Yes | The delegate object implemented by the host application, which must conform to the SUDOPWrappedClientDelegate protocol. |
Runtime Behavior
- Binding Logic: The SDK internally maintains the mapping between
gameHandleandclientDelegate. - Lifecycle Synchronization: When the game needs to trigger a host feature during running (such as popping up a login box, sharing, requesting payment, etc.), it is invoked through this delegate.
- Automatic Override: If this method is called multiple times for the same
gameHandle, the later-registeredclientDelegateoverrides the previous one.
Example Code
objectivec
// Assume gameHandle has been obtained in the startGame callback
[SUDOP registerWrappedClientWithGameHandle:gameHandle
clientDelegate:self];Notes
- Timing: It is recommended to register immediately in the
onCreatedcallback ofstartGameto ensure that interactions in the early stage of game startup are not lost. - Memory Management: The SDK internally usually holds a strong reference or weak reference to
clientDelegate(depending on the specific architecture design; it is recommended that the host application ensure the Delegate is not released prematurely during the game lifecycle). - Cleanup Mechanism: When
stopGameis called or the game is destroyed, it is recommended that the SDK internally unbind this delegate automatically to prevent retain cycles or dangling pointers.
