-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbce022
commit 92ed058
Showing
93 changed files
with
1,390 additions
and
852 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ include: package:pedantic/analysis_options.yaml | |
|
||
analyzer: | ||
errors: | ||
todo: ignore | ||
# todo: ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:pubnub/pubnub.dart'; | ||
import 'package:pubnub/networking.dart'; | ||
|
||
void main() async { | ||
var logger = StreamLogger.root('root', logLevel: Level.warning); | ||
|
||
// Subscribe to messages with a default printer | ||
logger.stream.listen( | ||
LogRecord.createPrinter(r'[$time] (${level.name}) $scope $message')); | ||
|
||
await provideLogger(logger, () async { | ||
// Create PubNub instance with default keyset. | ||
var pubnub = PubNub( | ||
networking: NetworkingModule( | ||
retryPolicy: RetryPolicy.exponential(maxRetries: 10)), | ||
defaultKeyset: | ||
Keyset(subscribeKey: 'demo', publishKey: 'demo', uuid: UUID('demo')), | ||
); | ||
|
||
print( | ||
'Network reconnection test. Please wait few seconds for further instructions...'); | ||
|
||
var sub = await pubnub.subscribe(channels: {'test2'}); | ||
|
||
await Future.delayed(Duration(seconds: 5)); | ||
|
||
print('Subscribed. Disconnect your network for few seconds.'); | ||
|
||
await Future.delayed(Duration(seconds: 5)); | ||
|
||
var f = pubnub.publish('test2', {'myMessage': 'it works!'}); | ||
|
||
print( | ||
'Now reconnect your network again! If everything goes well, you should see the message. You will see few diagnostic log lines in the meantime.'); | ||
|
||
await f; | ||
|
||
var message = await sub.messages.first; | ||
|
||
print(message.payload); | ||
|
||
await sub.dispose(); | ||
|
||
print('Done!'); | ||
|
||
exit(0); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'src/net/net.dart'; | ||
export 'src/net/meta/meta.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 11 additions & 4 deletions
15
lib/src/net/exceptions.dart → lib/src/core/net/exceptions.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
import 'package:pubnub/src/core/exceptions.dart'; | ||
import 'package:pubnub/pubnub.dart'; | ||
|
||
class PubNubRequestTimeoutException extends PubNubException { | ||
PubNubRequestTimeoutException() : super('request timed out'); | ||
dynamic additionalData; | ||
|
||
PubNubRequestTimeoutException([this.additionalData]) | ||
: super('request timed out'); | ||
} | ||
|
||
class PubNubRequestCancelException extends PubNubException { | ||
dynamic additionalData; | ||
|
||
PubNubRequestCancelException([this.additionalData]) | ||
: super('request cancelled'); | ||
} | ||
|
||
class PubNubRequestOtherException extends PubNubException { | ||
dynamic additionalData; | ||
|
||
PubNubRequestOtherException([this.additionalData]) : super('request failed'); | ||
} | ||
|
||
class PubNubRequestFailureException extends PubNubException { | ||
dynamic responseData; | ||
PubNubRequestFailureException(this.responseData) : super('request failed'); | ||
IResponse response; | ||
|
||
PubNubRequestFailureException(this.response) | ||
: super('request returned non-success status code'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
import 'request.dart'; | ||
import '../core.dart'; | ||
import 'request_handler.dart'; | ||
|
||
export 'request.dart' show Request, RequestHandler; | ||
export 'request.dart' show Request; | ||
export 'request_type.dart' show RequestType, RequestTypeExtension; | ||
export 'request_handler.dart' show IRequestHandler; | ||
export 'response.dart' show IResponse; | ||
export 'exceptions.dart' | ||
show | ||
PubNubRequestCancelException, | ||
PubNubRequestFailureException, | ||
PubNubRequestOtherException, | ||
PubNubRequestTimeoutException; | ||
|
||
abstract class NetworkModule { | ||
Future<RequestHandler> handle(Request request); | ||
abstract class INetworkingModule { | ||
void register(Core core); | ||
|
||
Future<RequestHandler> handleCustomRequest(Request request); | ||
Future<IRequestHandler> handler(); | ||
} |
Oops, something went wrong.