All Projects → Rabtman → Wsmanager

Rabtman / Wsmanager

OkHttp WebSocket Manager for Android

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Wsmanager

Ttyd
Share your terminal over the web
Stars: ✭ 4,030 (+1007.14%)
Mutual labels:  websocket
Neffos
A modern, fast and scalable websocket framework with elegant API written in Go
Stars: ✭ 341 (-6.32%)
Mutual labels:  websocket
Geeknews
📚A pure reading App based on Material Design + MVP + RxJava2 + Retrofit + Dagger2 + Realm + Glide
Stars: ✭ 3,496 (+860.44%)
Mutual labels:  okhttp3
Stompjs
Javascript and Typescript Stomp client for Web browsers and node.js apps
Stars: ✭ 324 (-10.99%)
Mutual labels:  websocket
Eureca.io
eureca.io : a nodejs bidirectional RPC that can use WebSocket, WebRTC or XHR fallback as transport layers
Stars: ✭ 341 (-6.32%)
Mutual labels:  websocket
Kotlin Ktor Exposed Starter
Starter RESTful service with websocket notifications using Kotlin, Ktor and Exposed with H2, HikariCP and FlyWay
Stars: ✭ 343 (-5.77%)
Mutual labels:  websocket
Shadowfax
Run Laravel on Swoole.
Stars: ✭ 325 (-10.71%)
Mutual labels:  websocket
Wampsharp
A C# implementation of WAMP (The Web Application Messaging Protocol)
Stars: ✭ 355 (-2.47%)
Mutual labels:  websocket
Libdatachannel
C/C++ WebRTC Data Channels and Media Transport standalone library
Stars: ✭ 336 (-7.69%)
Mutual labels:  websocket
Laravel Swoole
High performance HTTP server based on Swoole. Speed up your Laravel or Lumen applications.
Stars: ✭ 3,726 (+923.63%)
Mutual labels:  websocket
Redux Requests
Declarative AJAX requests and automatic network state management for single-page applications
Stars: ✭ 330 (-9.34%)
Mutual labels:  websocket
Socket.io Client Dart
socket.io-client-dart: Dartlang port of socket.io-client https://github.com/socketio/socket.io-client
Stars: ✭ 333 (-8.52%)
Mutual labels:  websocket
Vue Socket.io
😻 Socket.io implementation for Vuejs and Vuex
Stars: ✭ 3,746 (+929.12%)
Mutual labels:  websocket
Swoole Src
🚀 Coroutine-based concurrency library for PHP
Stars: ✭ 17,175 (+4618.41%)
Mutual labels:  websocket
Androidproject
Android 技术中台,但愿人长久,搬砖不再有
Stars: ✭ 4,398 (+1108.24%)
Mutual labels:  okhttp3
Java Spring Cloud
Distributed tracing for Spring Boot, Cloud and other Spring projects
Stars: ✭ 326 (-10.44%)
Mutual labels:  websocket
Ccxws
WebSocket client for 38 cryptocurrency exchanges
Stars: ✭ 341 (-6.32%)
Mutual labels:  websocket
Websocket
simple php websocket server + demos + yii/yii2 integration + php 7 support
Stars: ✭ 363 (-0.27%)
Mutual labels:  websocket
Leptus
The Erlang REST framework
Stars: ✭ 352 (-3.3%)
Mutual labels:  websocket
Dokit
基于 Spring Boot2、 Jpa、 Spring Security、JWT、redis、Vue的前后端分离的后台管理系统开发平台, 用户管理、菜单管理、角色管理、字典管理、权限控制的方式为RBAC,操作日志、异常日志、接口限流、项目支持数据权限管理,支持一键生成前后端代码(支持在线预览及打包下载),支持前端菜单动态路由 可一键部署服务器应用,数据库。系统中活跃用户状态监控,监视当前系统CPU、内存、磁盘、堆栈等相关信息,基于Element UI在线表单设计及生成Vue代码。
Stars: ✭ 348 (-4.4%)
Mutual labels:  websocket

WsManager

A library that simplifies the use of OkHttp Websocket.

For more information, please see:

https://blog.rabtman.com/2017/01/21/okhttp_ws_use/

https://blog.rabtman.com/2017/01/28/okhttp_ws_source/

Download

Maven:

<dependency>
  <groupId>com.rabtman.wsmanager</groupId>
  <artifactId>wsmanager</artifactId>
  <version>1.0.2</version>
  <type>pom</type>
</dependency>

or Gradle:

compile 'com.rabtman.wsmanager:wsmanager:1.0.2'

How to use

Instantiate a WsManager object:

OkHttpClient okHttpClient = new OkHttpClient().newBuilder()
                      .pingInterval(15, TimeUnit.SECONDS)
                      .retryOnConnectionFailure(true)
                      .build();
WsManager wsManager = new WsManager.Builder(this)
                .wsUrl("ws://localhost:2333/")
                .needReconnect(true)
                .client(okHttpClient)
                .build();

Establish a connection with the server:

wsManager.startConnect();

Listens for server connection status:

wsManager.setWsStatusListener(new WsStatusListener() {
            @Override
            public void onOpen(Response response) {
                super.onOpen(response);
            }

            @Override
            public void onMessage(String text) {
                super.onMessage(text);
            }

            @Override
            public void onMessage(ByteString bytes) {
                super.onMessage(bytes);
            }

            @Override
            public void onReconnect() {
                super.onReconnect();
            }

            @Override
            public void onClosing(int code, String reason) {
                super.onClosing(code, reason);
            }

            @Override
            public void onClosed(int code, String reason) {
                super.onClosed(code, reason);
            }

            @Override
            public void onFailure(Throwable t, Response response) {
                super.onFailure(t, response);
            }
        });

Send message to the server:

//String msg or ByteString byteString
wsManager.sendMessage();

Close the connection to the server:

wsManager.stopConnect();

Preview

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