This PR closes #179, it's a rather large change to the codebase, but it should help us identify issues easier in the future, and reduce complexity of the codebase. Changes include:
Dart side:
Refactored AblyMessage, to avoid unnecessary nesting of objects. Previously, AblyMessage would often wrap another AblyMessage instance which required additional checks on iOS and Android side, since it was never really known if the message was wrapped or not.
Refactored AblyMessage, to always use AblyMessage.handle field for passing handle values. Previously, handle values were often passed as AblyMessage.message leaving AblyMessage.handle set to null, which made no sense and introduces additional checks in platform code (we had to check in witch field the handle value is present)
Introduced constructors with named parameters to AblyMessage together with an empty() constructor to create instances with empty parameter collections
Changed platform method callers like invoke() or invokeRaw() to always provide AblyMessage instances to platform method calls. This should prevent errors with parsing and casting method calls on Android and iOS. By default, each method will now provide and empty map of parameters if they are not defined anywhere
Android side
Refactored AblyMethodCallHandler, removing unnecessary nested message checks. I've also unified type of values for handle, which now always uses long, so checks and casts for long/int/Number types were also removed.
Removed ablyDo lambda from AblyMethodCallHandler. The lambda was only used to unwrap nested AblyFlutterMessage instances and cast message types, since I removed the wrapping, it became obsolete
This PR closes #179, it's a rather large change to the codebase, but it should help us identify issues easier in the future, and reduce complexity of the codebase. Changes include:
AblyMessage
, to avoid unnecessary nesting of objects. Previously,AblyMessage
would often wrap anotherAblyMessage
instance which required additional checks on iOS and Android side, since it was never really known if the message was wrapped or not.AblyMessage
, to always useAblyMessage.handle
field for passinghandle
values. Previously,handle
values were often passed asAblyMessage.message
leavingAblyMessage.handle
set to null, which made no sense and introduces additional checks in platform code (we had to check in witch field thehandle
value is present)AblyMessage
together with anempty()
constructor to create instances with empty parameter collectionsinvoke()
orinvokeRaw()
to always provideAblyMessage
instances to platform method calls. This should prevent errors with parsing and casting method calls on Android and iOS. By default, each method will now provide and empty map of parameters if they are not defined anywhereAblyMethodCallHandler
, removing unnecessary nested message checks. I've also unified type of values forhandle
, which now always useslong
, so checks and casts for long/int/Number types were also removed.ablyDo
lambda fromAblyMethodCallHandler
. The lambda was only used to unwrap nestedAblyFlutterMessage
instances and cast message types, since I removed the wrapping, it became obsoleteAblyFlutter
, removing unnecessary nested message checksPushHandlers
, removing unnecessary nested message checksThis is a first step in unifying the communication between Flutter and platform SDK's. I think the next change in that matter would be https://github.com/ably/ably-flutter/issues/359