swagger-api/swagger-socket được TopGit xếp vào nhóm dự án mã nguồn mở, với 391 sao trên GitHub, viết chủ yếu bằng Java. Swagger Socket: A REST over WebSocket
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
The SwaggerSocket protocol allows any existing REST Resources to be executed on top of the WebSocket Protocol. Resources can be deployed as it is, without any modification and take advantage of the SwaggerSocket protocol.
Join the community
You can subscribe to our Google Group.
Download SwaggerSocket
Using Maven or SBT
<!-- Server side -->
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swaggersocket-server</artifactId>
<version>2.1.0</version>
</dependency>
<!-- Client side when using jquery.swaggersocket.js -->
<dependency>
<groupId>org.atmosphere.client</groupId>
<artifactId>jquery</artifactId>
<version>2.2.13</version>
<type>war</type>
</dependency>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swaggersocket.jquery</artifactId>
<version>2.1.0</version>
<type>war</type>
</dependency>
<!-- Client side when using swaggersocket.js -->
<dependency>
<groupId>org.atmosphere.client</groupId>
<artifactId>javascript</artifactId>
<version>2.2.13</version>
<type>war</type>
</dependency>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swaggersocket.js</artifactId>
<version>2.1.0</version>
<type>war</type>
</dependency>
Manual download here
Getting Started
The quickest way to see how the protocol works is to try the samples. You can download them from here. Just do
and then point your browser to http://127.0.0.1:8080
You can also build the sample yourself and use Jetty instead of NettoSphere.
By default, jetty9 is used in this case, but this can be changed with profile -Pjetty8
% git clone https://github.com/swagger-api/swagger-socket.git
% cd swagger-socket
% mvn
% cd samples/swaggersocket-{sample_name}
% mvn jetty:run
Take a look at HelloWorld mini tutorial.
You can also look at our real time samples:
Twitter's Real Time Search client code | server code | download sample | README
Wordnik's Real Time Search client code | server code | download sample | README
For Webapp samples, you can also download our war files and deploy them to any WebServer supporting WebSockets.
Note that both both Wordnik and Twitter Samples require a valid key to be configured in their corresponding web.xml file or passed as the command arguments when using nettosphere.sh. For details, refer to the README file of each sample project.
Add bi-directional support to your REST application
You can also add bi-directional support to your REST resources by extending your application using the Atmosphere Framework.
Quick Overview
To enable SwaggerSocket, add the following in your web.xml.
In addition, configure additional init-param parameters required to run the application. For example,
when using jersey to load resources under package com.wordnik.swaggersocket.samples.
// use new jQuery.swaggersocket... when using jQuery, otherwise use new swaggersocket...
var swaggerSocket = new jQuery.swaggersocket.SwaggerSocket();
Listeners are per Request. The responses will be delivered as they come and can be correlated with their associated request using response.getRequest().
// use new jQuery.swaggersocket... when using jQuery, otherwise use new swaggersocket...
var ss = new jQuery.swaggersocket.SwaggerSocketListener();
ss.onOpen = function(response) {};
ss.onClose = function(Response) {}; // Called when the Websocket gets closed
ss.onError = function(Response) {}; // When an error occurs
ss.onResponse = function(Response) {}; // When a response is ready
ss.onResponses = function (Response) {}; // A List of all the ready responses
Opening a connection
// use new jQuery.swaggersocket... when using jQuery, otherwise use new swaggersocket...
var request = new jQuery.swaggersocket.Request()
.path(document.location.toString())
.listener(ss);
swaggerSocket.open(request);
Sending requests -- You can send an array of Requests or single Request.
var requests = new Array();
// use new jQuery.swaggersocket... when using jQuery, otherwise use new swaggersocket...
requests[0] = new jQuery.swaggersocket.Request()
.path("path1")
.method("POST")
.data("FOO")
.dataFormat("text/plain")
.listener(ss);
requests[1] = new jQuery.swaggersocket.Request()
.path("/path2")
.method("POST")
.data("BAR")
.dataFormat("text/plain")
.listener(ss);
swaggerSocket.send(requests);
SwaggerSocket Scala API
The SwaggerSocket protocol can also be used using the Scala language. The SwaggerSocket Scala library is using Asynchronous I/O so all the API calls are non blocking. First, you need to hanshake using
val ss = SwaggerSocket().open(new Request.Builder().path(getTargetUrl + "/").build())
Then you are ready to start sending requests. As simple as:
// send (Request, SwaggerSoketListener )
// or send (Array[Request], SwaggerSoketListener)
ss.send(new Request.Builder()
.path("/b")
.method("POST")
.body("Yo!")
.dataFormat("application/json")
.build(), new SwaggerSocketListener() {
override def error(e: SwaggerSocketException) {
// Invoked when an exception occurs
}
override def message(r: Request, s: Response) {
// Response is delievered here
}
})
Once completed, you just need to close
ss.close
SwaggerSocket on Node.js
SwaggerSocket client (From 2.0.0) is available for Node.js. To see how it works, see the swaggersocket-echo-node-client sample.
SwaggerSocket on OSGi
SwaggerSocket (From 2.0.1) is not only OSGi enabled but also available as a Karaf feature. To see how it works, see the swaggersocket-cxf-osgi-echo sample.
How the protocol works
To read more about how the protocol works, take a look at the SwaggerSocket Protocol Specification
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/swagger-api/swagger-socket là nguồn chính thức.
swagger-api/swagger-socket có bao nhiêu sao?
swagger-api/swagger-socket có 391 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/swagger-api/swagger-socket. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
swagger-api/swagger-socket có phải mã nguồn mở không?
TopGit chưa ghi nhận license cho swagger-api/swagger-socket. Phần lớn repo public trên GitHub là mã nguồn mở, nhưng điều khoản khác nhau từng repo — mở file LICENSE để xác nhận.
swagger-api/swagger-socket còn đang phát triển không?
Commit gần nhất trên swagger-api/swagger-socket là 7.1 năm trước (theo timestamp GitHub). Repo có 57 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
swagger-api/swagger-socket là gì?
swagger-api/swagger-socket (swagger-api/swagger-socket) là dự án Java trên GitHub. Theo mô tả gốc: Swagger Socket: A REST over WebSocket
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về swagger-socket?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về swagger-socket.