Java 版 SSMP 协议实现 jssmp

码农软件 · 软件分类 · 协议和规范 · 2019-10-12 20:29:31

软件介绍

jssmp 是 Java 版 SSMP 开源实现。

依赖:

  • JDK 1.8 or higher

  • netty 3.10+

  • slf4j 1.7+

  • guava 17+

客户端

// given: SSLEngine sslEngine;
SSMPClient c = new SSMPClient("localhost", 1234, new HashedWheelTimer(),
        new NioClientSocketChannelFactory(), () -> new SslHandler(sslEngine),
        e -> System.out.println("event: " + e));
c.connect(SSMPIdentifier.fromInternal("foo"),
        SSMPIdentifier.fromInternal("secret"), "NotARealSecret",
        new ConnectionListener() {
            @Override public void connected() { System.out.println("connected"); }
            @Override public void disconnected() { System.out.println("disconnected"); }
        });
SSMPResponse r = c.request(SSMPRequest.ucast(SSMPIdentifier.fromInternal("bar"),
        "Hello World!")).get();
System.out.println("response: " + r);

服务器端

// given: SSLEngine sslEngine;
SSMPServer s = new SSMPServer(new InetSocketAddress("localhost", 1234),
        new HashedWheelTimer(), new NioServerSocketChannelFactory(),
        () -> new SslHandler(sslEngine),
        new Authenticator() {
            @Override public boolean authenticate(SSMPIdentifier id, SSMPIdentifier scheme, String cred) {
                return scheme.toString().equals("secret") && cred.equals("NotARealSecret");
            }
            @Override public ChannelBuffer unauthorized() {
                return ChannelBuffers.wrappedBuffer("401 secret\n".getBytes(StandardCharsets.US_ASCII));
            }
        });
s.start();

本文地址:https://www.codercto.com/soft/d/16622.html

Programming PHP

Programming PHP

Rasmus Lerdorf、Kevin Tatroe、Peter MacIntyre / O'Reilly Media / 2006-5-5 / USD 39.99

Programming PHP, 2nd Edition, is the authoritative guide to PHP 5 and is filled with the unique knowledge of the creator of PHP (Rasmus Lerdorf) and other PHP experts. When it comes to creating websit......一起来看看 《Programming PHP》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

随机密码生成器
随机密码生成器

多种字符组合密码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换