All Projects → a3349384 → Easymessenger

a3349384 / Easymessenger

一款Android平台上基于Binder的IPC进程间通信库

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Easymessenger

Flying Pigeon
flying-pigeon 是一个IPC 跨进程通信组件,底层是匿名内存+Binder , 突破1MB大小限制,无需写AIDL文件,让实现跨进程通信就像写一个接口一样简单
Stars: ✭ 97 (+304.17%)
Mutual labels:  binder, ipc
binder-for-linux
An experimental project to port Android Binder IPC subsystem to Ubuntu Linux.
Stars: ✭ 110 (+358.33%)
Mutual labels:  binder, ipc
libgbinder
GLib-style interface to binder
Stars: ✭ 21 (-12.5%)
Mutual labels:  binder, ipc
Dnpipes
Distributed Named Pipes
Stars: ✭ 452 (+1783.33%)
Mutual labels:  ipc
Microservices
Microservices from Design to Deployment 中文版 《微服务:从设计到部署》
Stars: ✭ 4,637 (+19220.83%)
Mutual labels:  ipc
Raftlib
The RaftLib C++ library, streaming/dataflow concurrency via C++ iostream-like operators
Stars: ✭ 717 (+2887.5%)
Mutual labels:  ipc
Csc deeplearning
3-day dive into deep learning at csc
Stars: ✭ 22 (-8.33%)
Mutual labels:  binder
Course Starter Python
👩‍🏫🐍 Starter repo for building interactive Python courses
Stars: ✭ 440 (+1733.33%)
Mutual labels:  binder
Aptmap
A map displaying threat actors from the misp-galaxy
Stars: ✭ 17 (-29.17%)
Mutual labels:  apt
Zebra
🦓 A Useful Package Manager for iOS
Stars: ✭ 667 (+2679.17%)
Mutual labels:  apt
Pyro4
Pyro 4.x - Python remote objects
Stars: ✭ 641 (+2570.83%)
Mutual labels:  ipc
Scalecube Services
ScaleCube Services is a high throughput, low latency reactive microservices library built to scale. it features: API-Gateways, service-discovery, service-load-balancing, the architecture supports plug-and-play service communication modules and features. built to provide performance and low-latency real-time stream-processing. its open and designed to accommodate changes. (no sidecar in a form of broker or any kind)
Stars: ✭ 482 (+1908.33%)
Mutual labels:  ipc
Numpy 100
100 numpy exercises (with solutions)
Stars: ✭ 7,681 (+31904.17%)
Mutual labels:  binder
Electron Better Ipc
Simplified IPC communication for Electron apps
Stars: ✭ 463 (+1829.17%)
Mutual labels:  ipc
Quickviz
Visualize a pandas dataframe in a few clicks
Stars: ✭ 18 (-25%)
Mutual labels:  binder
Andlinker
AndLinker is a IPC library for Android, which combines the features of AIDL and Retrofit. Allows IPC call seamlessly compose with RxJava and RxJava2 call adapters.
Stars: ✭ 440 (+1733.33%)
Mutual labels:  ipc
Ts3server Package
A script that generates a debian package for a TeamSpeak 3 Server
Stars: ✭ 5 (-79.17%)
Mutual labels:  apt
Aeron
Efficient reliable UDP unicast, UDP multicast, and IPC message transport
Stars: ✭ 5,782 (+23991.67%)
Mutual labels:  ipc
Mappedbus
Mappedbus is a low latency message bus for Java microservices utilizing shared memory. http://mappedbus.io
Stars: ✭ 613 (+2454.17%)
Mutual labels:  ipc
K8cscan
K8Cscan大型内网渗透自定义插件化扫描神器,包含信息收集、网络资产、漏洞扫描、密码爆破、漏洞利用,程序采用多线程批量扫描大型内网多个IP段C段主机,目前插件包含: C段旁注扫描、子域名扫描、Ftp密码爆破、Mysql密码爆破、Oracle密码爆破、MSSQL密码爆破、Windows/Linux系统密码爆破、存活主机扫描、端口扫描、Web信息探测、操作系统版本探测、Cisco思科设备扫描等,支持调用任意外部程序或脚本,支持Cobalt Strike联动
Stars: ✭ 693 (+2787.5%)
Mutual labels:  ipc

EasyMessenger

一款用于Android平台的基于Binder的进程间通信库,采用annotationProcessor生成IPC通信需要的代码。EasyMessenger相对于AIDL具备如下优势:

  • 采用Java声明接口,更方便
  • 接口方法支持重载
  • 同时支持同步和异步通信

EasyMessenger目前支持如下数据类型:

  • boolean, byte, char, short, int, long, float, double
  • boolean[], byte[], char[], int[], long[], float[], double[]
  • String, String[]
  • Parcelable, Parcelable[]
  • Serializable
  • ArrayList(泛型参数只能是简单类型或者Parcelable)
  • enum(需要实现parcelable)

下载


Client和Server工程均需引用下面的依赖.

implementation 'cn.zmy:easymessenger-lib:0.3'
annotationProcessor 'cn.zmy:easymessenger-compiler:0.3'

开始使用


Server端


Server实现需要提供给Client功能,例如:

@BinderServer
public class FunctionImpl
{
    //必须是pubic
    //方法名称、参数数量、类型、顺序必须和client的接口一致
    public int add(int num1, int num2)
    {
        return num1 + num2;
    }
}

注意,实现类上面标注了@BinderServer注解,表示这个类是一个Server的实现。

build项目之后会生成FunctionImplProvider类,这是一个ContentProvider,其命名规则为:Server实现类的名称 + Provider。

接下来,需要将生成的ContentProviderAndroidManifest.xml中予以声明:

<provider
    android:authorities="your-authorities"
    android:name="xx.xx.FunctionImplProvider"
    android:exported="true"/>

请记住android:authorities的值,它是Client和Server之间进行通信的钥匙。

Client端


Client只需要照着Server的实现,声明同样签名的接口方法即可:

@BinderClient(key = "your-authorities")
public interface ClientInterface
{
    int add(int num1, int num2);
}

其上面标注了@BinderClient注解,表示类是一个Client接口。需要注意的是,@BinderClient注解需要设置其key参数的值, 其值即为Server项目中ContentProviderandroid:authorities的值。

build项目之后,会生成ClientInterfaceHelper类,开发者也正是通过这个生成Helper类来和Server进行IPC通信的。Helper类的命名规则为:Client接口的名称 + Helper。接下来看一下Client如何使用Helper发起IPC请求。

//使用之前需要初始化,需要传递application类型的context
ClientInterfaceHelper.instance.__init(appContext);
    
//同步IPC示例。在IPC完成之前,线程会阻塞
int result = ClientInterfaceHelper.instance.add(1, 2);
    
//异步IPC示例。线程不会阻塞
ClientInterfaceHelper.instance.addAsync(1, 2, new IntCallback()
{
    @Override
    public void onSuccess(int result)
    {
        //调用成功
    }

    @Override
    public void onError(Exception ex)
    {
        //调用失败
    }
});

限制

API Level >= 18

API Level < 18的项目可以使用:

implementation 'cn.zmy:easymessenger-lib:0.2'
annotationProcessor 'cn.zmy:easymessenger-compiler:0.2'

EasyMessenger目前只支持下面的数据类型:

  • boolean, byte, char, short, int, long, float, double
  • boolean[], byte[], char[], int[], long[], float[], double[]
  • String, String[]
  • Parcelable, Parcelable[]
  • Serializable
  • ArrayList(泛型参数只能是简单类型或者Parcelable)
  • enum(需要实现parcelable)

ContentProvider的限制

由于EasyMessenger使用ContentProvider来获取Server的Binder的代理,而ContentProvider会先于Application#onCreate初始化,所以对于一些初始化代码可能需要放置于Application#attachBaseContext中。

License


Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].