rmi 0.0.4

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 30

Remote Method Invocation for dart #

Build Status

This project provides an solution for remote method invocation in dart without the use of reflection. Since reflection is only available on the Dart VM but not on a JS VM, this solution is entirely based on code generation instead.

Getting Started #

Let's say you want to invoke methods of an ExampleClass looking like this:

// in example.dart
part 'example.g.dart';
class ExampleClass implements RmiTarget {
  void someMethod() {
	print('some stuff');
  }

  ExampleClass();
  // required boilerplate for code generation
  @override
  Object invoke(Invocation invocation) =>
      _$ExampleClassInvoker.invoke(invocation, this);
  factory ExampleClass.getRemote(Context context, String uuid) =>
      _$ExampleClassRmi.getRemote(context, uuid);
  Provision provideRemote(Context context) =>
      _$ExampleClassRmi.provideRemote(context, this);
}

And you have the actual object present on machine A:

ExampleClass exampleObject = new ExampleClass();
/// ...setup some network connection, get a Stream and a StreamSink from it
Stream input = ...
StreamSink output = ...
Provision provision = exampleObject.provideRemote(new Context(input, output));
/// provision contains the uuid which identifies the object on this machine

On machine B:

/// Again we have the input and output you get from your network 
/// and additionally you have to provide the uuid from before
Stream input = ...
StreamSink output = ...
String uuid = ... provision.uuid // from above
ExampleClass remoteObject = ExampleClass.getRemote(new Context(input, output), uuid);
remoteObject.someMethod(); // prints 'some stuff' on the other machine

TODO #

  • generator warning when no factory was implemented
  • also for part ...
  • not invocable, not proxied method annotation
  • operators
  • think about object methods, tostring hashcode
  • check lang spec for other members what else could be here
  • Serialize exceptions
  • send stack on exception
  • Add else clause to invoker to provide an error message
  • write doc
  • cleanup exports
  • write install script
  • if static getRemoteis not specified, do not write it for stub constructors simply put a waringing
  • STREAMS!!!!
  • thorw exceptions from invoke
  • Proxy does implement, extend should be possible
  • sosuchmethod...
  • reduce tests to a minimum code
  • warn on rmi non future method
  • warn for contrast metadata
  • class hierarchy metadata
  • pass stream and future null arguments

Changelog #

0.0.4 #

  • JSON Serialization instead of build_values
  • Streams and Futures can be transferred
  • operators implemented
  • metaflags added, possibly forces a RmiTarget to be serialized instead of remote implemented

0.0.3 #

Compile Error fixed

0.0.2 #

Added examples

0.0.1 #

Initial version with all basics implemented

example/lib/example.dart

import 'package:rmi/remote_method_invocation.dart';
import 'package:rmi/proxy.dart';
import 'dart:async';

part 'example.g.dart';

class ExampleClass implements RmiTarget {
  void someMethod() {
    print('some stuff');
  }

  ExampleClass();
  // required boilerplate for code generation
  @override
  Object invoke(Invocation invocation) =>
      _$ExampleClassInvoker.invoke(invocation, this);
  factory ExampleClass.getRemote(Context context, String uuid) =>
      _$ExampleClassRmi.getRemote(context, uuid);
  Provision provideRemote(Context context) =>
      _$ExampleClassRmi.provideRemote(context, this);
}

main() {
  StreamController<String> aToB = StreamController();
  StreamController<String> bToA = StreamController();

  ExampleClass remoteTarget = new ExampleClass();
  var provision = remoteTarget.provideRemote(new Context(aToB.stream, bToA));

  ExampleClass proxy =
      ExampleClass.getRemote(new Context(bToA.stream, aToB), provision.uuid);

  proxy.someMethod();
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  rmi: ^0.0.4

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:rmi/rmi.dart';
  
Version Uploaded Documentation Archive
0.0.4 Jan 21, 2019 Go to the documentation of rmi 0.0.4 Download rmi 0.0.4 archive
0.0.3 Dec 8, 2018 Go to the documentation of rmi 0.0.3 Download rmi 0.0.3 archive
0.0.2 Dec 8, 2018 Go to the documentation of rmi 0.0.2 Download rmi 0.0.2 archive
0.0.1 Dec 8, 2018 Go to the documentation of rmi 0.0.1 Download rmi 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
30
Learn more about scoring.

We analyzed this package on Apr 24, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:rmi/rmi.dart.

Maintenance issues and suggestions

Prefer published dependencies. (-100 points)

The source code in a git repository is mutable and could disappear.

Use constrained dependencies. (-20 points)

The pubspec.yaml contains 2 dependencies without version constraints. Specify version ranges for the following dependencies: json_annotation, json_serialization.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0-dev <3.0.0
json_annotation any 2.2.0
json_serialization 0.0.1
uuid ^1.0.3 1.0.3 2.0.1
Transitive dependencies
charcode 1.1.2
collection 1.14.11
convert 2.1.1
crypto 2.0.6
typed_data 1.1.6
Dev dependencies
build_runner ^1.1.2
json_serializable