java net-pull

net-pull implementation in java.

License

License

Categories

Categories

Net
GroupId

GroupId

com.zmannotes
ArtifactId

ArtifactId

net-pull
Last Version

Last Version

2.1.3
Release Date

Release Date

Type

Type

jar
Description

Description

java net-pull
net-pull implementation in java.
Project URL

Project URL

https://github.com/zman2013/net-pull
Source Code Management

Source Code Management

https://github.com/zman2013/net-pull

Download net-pull

How to add to project

<!-- https://jarcasting.com/artifacts/com.zmannotes/net-pull/ -->
<dependency>
    <groupId>com.zmannotes</groupId>
    <artifactId>net-pull</artifactId>
    <version>2.1.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.zmannotes/net-pull/
implementation 'com.zmannotes:net-pull:2.1.3'
// https://jarcasting.com/artifacts/com.zmannotes/net-pull/
implementation ("com.zmannotes:net-pull:2.1.3")
'com.zmannotes:net-pull:jar:2.1.3'
<dependency org="com.zmannotes" name="net-pull" rev="2.1.3">
  <artifact name="net-pull" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.zmannotes', module='net-pull', version='2.1.3')
)
libraryDependencies += "com.zmannotes" % "net-pull" % "2.1.3"
[com.zmannotes/net-pull "2.1.3"]

Dependencies

compile (1)

Group / Artifact Type Version
com.zmannotes.stream : pull-stream jar 2.1.3

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-core jar 3.1.0

Project Modules

There are no modules declared in this project.

Travis Build Coverage Status

net-pull

Providing idiomatic interfaces of the client & server to implement the net pull-stream.

dependency

<dependency>
    <groupId>com.zmannotes</groupId>
    <artifactId>net-pull</artifactId>
    <version>2.1.3</version>
</dependency>

interfaces

IClient

public interface IClient<T> {

    /**
     * 连接目标服务地址
     * @param ip    ip
     * @param port  端口
     */
    void connect(String ip, int port) ;

    /**
     * 主动断开连接
     */
    void disconnect();

    /**
     * 成功连接到server时的回调函数
     * @param callback 回调函数
     */
    IClient onConnected(Consumer<T> callback);

    /**
     * 连接断开时回调
     * @param callback 回调函数
     */
    IClient onDisconnected(Runnable callback);

    /**
     * 连接发生异常时回调
     * @param callback  回调函数
     */
    IClient onThrowable(Consumer<Throwable> callback);

}

IServer

public interface IServer {

    /**
     * 启动Server,监听端口
     * @param port 监听的端口
     */
    void listen(int port);

    /**
     * 停止server,断开所有连接
     */
    void close();

    /**
     * 有新client接入时,回调callback函数
     *
     * @param callback  回调函数,参数:Integer: 连接唯一id,IDuplex:双工流
     */
    IServer onAccept(BiConsumer<Integer, T> callback);

    /**
     * 连接断开时回调
     * @param callback 回调函数,参数为:connectionId 连接唯一id
     *
     */
    IServer onDisconnect(Consumer<Integer> callback);

    /**
     * server停止成功时回调
     * @param callback 回调函数
     */
    IServer onClosed(Runnable callback);

    /**
     * server运行发生异常时回调
     * @param callback 回调函数
     */
    IServer onThrowable(Consumer<Throwable> callback);

}

example

clientTest
        .onConnected(connectCallback)
        .onDisconnected(disconnectCallback)
        .onThrowable(throwableCallback)
        .connect("ip", 0);

Versions

Version
2.1.3
2.1.0
1.0.0
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3