Skip to content

feat: add callbackConnected to createToken #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/core/websocket/interfaces/ws_handler.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import 'package:socket_io_client/socket_io_client.dart';

abstract class WsHandler {
void establishConnection({bool forceConnection = false});
void establishConnection({
bool forceConnection = false,
Function()? callbackConnected,
});
void disconnection();
void reconnect({required Function callbackConnected});

Expand Down
10 changes: 8 additions & 2 deletions lib/flutter_waterbus_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,14 @@ class WaterbusSdk {
}

// Auth
Future<Result<User>> createToken(AuthPayload payload) async {
return await _sdk.createToken(payload: payload);
Future<Result<User>> createToken(
AuthPayload payload, {
Function()? callbackConnected,
}) async {
return await _sdk.createToken(
payload: payload,
callbackConnected: callbackConnected,
);
}

Future<Result<bool>> deleteToken() async {
Expand Down
10 changes: 8 additions & 2 deletions lib/waterbus_sdk_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,17 @@ class SdkCore extends WaterbusSdkInterface {

// Auth
@override
Future<Result<User>> createToken({required AuthPayload payload}) async {
Future<Result<User>> createToken({
required AuthPayload payload,
Function()? callbackConnected,
}) async {
final Result<User> user = await _authRepository.createToken(payload);

if (user.isSuccess) {
_wsHandler.establishConnection(forceConnection: true);
_wsHandler.establishConnection(
forceConnection: true,
callbackConnected: callbackConnected,
);
}

return user;
Expand Down
5 changes: 4 additions & 1 deletion lib/waterbus_sdk_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ abstract class WaterbusSdkInterface {
Future<void> initializeApp();

// Auth
Future<Result<User>> createToken({required AuthPayload payload});
Future<Result<User>> createToken({
required AuthPayload payload,
Function()? callbackConnected,
});
Future<Result<bool>> deleteToken();
Future<Result<bool>> renewToken();

Expand Down
Loading