rmi 0.0.3

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

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

Changelog

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.3

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/invoker.dart';
import 'package:rmi/proxy.dart';
import 'package:rmi/remote_method_invocation.dart';
  
Version Uploaded Documentation 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]
90
Overall:
Weighted score of the above. [more]
48
Learn more about scoring.

We analyzed this package on Dec 8, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in libraries.

Maintenance suggestions

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

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
built_collection ^4.1.0 4.1.0
built_value ^6.1.6 6.1.6
uuid ^1.0.3 1.0.3 2.0.0-rc1
Transitive dependencies
charcode 1.1.2
collection 1.14.11
convert 2.0.2
crypto 2.0.6
fixnum 0.10.9
matcher 0.12.4
meta 1.1.6
path 1.6.2
quiver 2.0.1
stack_trace 1.9.3
typed_data 1.1.6
Dev dependencies
build_runner ^1.1.2
built_value_generator ^6.1.6