All Projects → Atmosphere → Wasync

Atmosphere / Wasync

Licence: apache-2.0
WebSockets with fallback transports client library for Node.js, Android and Java

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Wasync

Graphqlws
Implementation of the GraphQL over WebSocket protocol in Go.
Stars: ✭ 139 (-14.2%)
Mutual labels:  websockets
Socktrader
🚀 Websocket based trading bot for 💰cryptocurrencies 📈
Stars: ✭ 152 (-6.17%)
Mutual labels:  websockets
Spring Boot Examples
个人学习 SpringBoot2.x 写的一些示例程序,目前正在持续更新中.....
Stars: ✭ 159 (-1.85%)
Mutual labels:  websockets
Carrot
Distributed WebSocket and HTTP Load Testing Framework in Go
Stars: ✭ 143 (-11.73%)
Mutual labels:  websockets
Minchat
基于tomcat 7. 0.56 websocket的在线客服系统
Stars: ✭ 146 (-9.88%)
Mutual labels:  websockets
Websocket Kit
WebSocket client library built on SwiftNIO
Stars: ✭ 155 (-4.32%)
Mutual labels:  websockets
Http
An opinionated framework for scalable web 🌎
Stars: ✭ 136 (-16.05%)
Mutual labels:  websockets
Dashboard.spatie.be
The source code of dashboard.spatie.be
Stars: ✭ 1,916 (+1082.72%)
Mutual labels:  websockets
Aws Mqtt Client
AWS Websocket Pub/Sub client
Stars: ✭ 147 (-9.26%)
Mutual labels:  websockets
Nodebb
Node.js based forum software built for the modern web
Stars: ✭ 12,303 (+7494.44%)
Mutual labels:  websockets
Wsstat
Websocket stress testing made beautiful
Stars: ✭ 143 (-11.73%)
Mutual labels:  websockets
Websocket
WSServer is a fast, configurable, and extendable WebSocket Server for UNIX systems written in C (C11).
Stars: ✭ 144 (-11.11%)
Mutual labels:  websockets
Kalm.js
The socket manager
Stars: ✭ 155 (-4.32%)
Mutual labels:  websockets
React Native Signalr
Use SignalR with React Native
Stars: ✭ 141 (-12.96%)
Mutual labels:  websockets
Codenames
Stars: ✭ 159 (-1.85%)
Mutual labels:  websockets
Azure Signalr
Azure SignalR Service SDK for .NET
Stars: ✭ 137 (-15.43%)
Mutual labels:  websockets
Pychat
webchat via WebSockets/WebRTC that allows messaging/video call/screen sharing
Stars: ✭ 152 (-6.17%)
Mutual labels:  websockets
Node Jet
Realtime Message Bus for the Web. Javascript Implementation
Stars: ✭ 162 (+0%)
Mutual labels:  websockets
Webssh
🌱 Web based ssh client
Stars: ✭ 2,520 (+1455.56%)
Mutual labels:  websockets
Emberclear
Encrypted Chat. No History. No Logs.
Stars: ✭ 157 (-3.09%)
Mutual labels:  websockets

wAsync: A WebSockets/HTTP Client Library for Asynchronous Communication

wAsync is a Java based library allowing asynchronous communication with any WebServer supporting the WebSocket or Http Protocol. wAsync can be used with Node.js, Android, Atmosphere or any WebSocket Framework. To get started, read this super simple Tutorial or read the FAQ

You can browse the javadoc or browse our samples.

You can download the jar or use Maven

          <dependency>
              <groupId>org.atmosphere</groupId>
              <artifactId>wasync</artifactId>
              <version>2.1.7</version>
          </dependency>

As simple as

        Client client = ClientFactory.getDefault().newClient();

        RequestBuilder request = client.newRequestBuilder()
                .method(Request.METHOD.GET)
                .uri("http://async-io.org")
                .encoder(new Encoder<String, Reader>() {        // Stream the request body
                    @Override
                    public Reader encode(String s) {
                        return new StringReader(s);
                    }
                })
                .decoder(new Decoder<String, Reader>() {
                    @Override
                    public Reader decode(Event type, String s) {
                        return new StringReader(s);
                    }
                })
                .transport(Request.TRANSPORT.WEBSOCKET)                        // Try WebSocket
                .transport(Request.TRANSPORT.LONG_POLLING);                    // Fallback to Long-Polling

        Socket socket = client.create();
        socket.on(new Function<Reader>() {
            @Override
            public void on(Reader r) {
                // Read the response
            }
        }).on(new Function<IOException>() {

            @Override
            public void on(IOException ioe) {
                // Some IOException occurred
            }

        }).open(request.build())
            .fire("echo")
            .fire("bong");

Life cycle of the underlying Socket can easily be implemented as well

           Socket socket = client.create();
           socket.on(Event.CLOSE.name(), new Function<String>() {
               @Override
               public void on(String t) {
               }
           }).on(Event.REOPENED.name(), new Function<String>() {
               @Override
               public void on(String t) {
               }
           }).on(new Function<IOException>() {
               @Override
               public void on(IOException ioe) {
                   ioe.printStackTrace();
               }
           }).on(Event.OPEN.name(), new Function<String>() {
               @Override
               public void on(String t) {
               }
           }).open(request.build());

You can also use the specialized clients. For example, to transparently enable Atmosphere's Protocol

       AtmosphereClient client = ClientFactory.getDefault().newClient(AtmosphereClient.class);

       RequestBuilder request = client.newRequestBuilder()
    		   .method(Request.METHOD.GET)
    		   .uri(targetUrl + "/suspend")
               .trackMessageLength(true)
    		   .transport(Request.TRANSPORT.LONG_POLLING);

or if you want to serialize the fire() method call so events are asynchronously sent in the order the fire method is called

        SerializedClient client = ClientFactory.getDefault().newClient(SerializedClient.class);

        SerializedOptionsBuilder b = client.newOptionsBuilder();
        b.serializedFireStage(new DefaultSerializedFireStage());

        RequestBuilder request = client.newRequestBuilder()
                .method(Request.METHOD.GET)
                .uri(targetUrl + "/suspend")
                .transport(Request.TRANSPORT.WEBSOCKET);

        Socket socket = client.create(b.build());

By default, the FunctionResolver will associate the Decoder's type will be used to invoke the appropriate Function, if defined. For example,

   Decoder<String, POJO> d = new Decoder<String, POJO>() {
             @Override
             public POJO decode(Event type, String s) {
                 if (type.equals(Event.MESSAGE)) {
                    return new POJO(s);
                 } else {
                    return s;
                 }
             }
         }

will be associated to

   Function<String> f = new Function<POJO>() {
             @Override
             public void on(POJO t) {

             }
        }

You can also implement your own FunctionResolver to associate the Function with Decoder

         Socket socket = client.create();
         socket.on("myEvent", new Function<Reader>() { ...}

where myEvent could be read from the response's body.

Want to write an Android Client? See

Build Status

Build Status

[Analytics]

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