Giter Site home page Giter Site logo

jssmp's Introduction

jssmp

jssmp is a Java implementation of the Stupid-Simple Messaging Protocol.

License

BSD 3-clause, see accompanying LICENSE file.

Dependencies

Example usage

Client

// 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);

Server

// 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();

Notes

The server implementation was written for in-process integration testing. It did not go through the kind of extensive testing and optimization required to be considered production-quality.

jssmp's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.