{"id":13471769,"url":"https://github.com/webbit/webbit","last_synced_at":"2025-03-26T14:32:28.511Z","repository":{"id":1316788,"uuid":"1261652","full_name":"webbit/webbit","owner":"webbit","description":"A Java event based WebSocket and HTTP server","archived":false,"fork":false,"pushed_at":"2023-12-17T03:24:41.000Z","size":20034,"stargazers_count":816,"open_issues_count":47,"forks_count":185,"subscribers_count":78,"default_branch":"master","last_synced_at":"2024-10-30T04:09:42.515Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://webbitserver.org/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webbit.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS"}},"created_at":"2011-01-16T22:49:46.000Z","updated_at":"2024-10-04T07:33:31.000Z","dependencies_parsed_at":"2024-01-06T15:24:36.204Z","dependency_job_id":null,"html_url":"https://github.com/webbit/webbit","commit_stats":{"total_commits":660,"total_committers":39,"mean_commits":"16.923076923076923","dds":"0.41666666666666663","last_synced_commit":"f628a7a3ffdd8c288514784f5b0426faaee2a2e3"},"previous_names":[],"tags_count":64,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webbit%2Fwebbit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webbit%2Fwebbit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webbit%2Fwebbit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webbit%2Fwebbit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webbit","download_url":"https://codeload.github.com/webbit/webbit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245670996,"owners_count":20653466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T16:00:49.115Z","updated_at":"2025-03-26T14:32:27.504Z","avatar_url":"https://github.com/webbit.png","language":"Java","readme":"# Webbit - A Java event based WebSocket and HTTP server\n\n[![Build Status](https://secure.travis-ci.org/webbit/webbit.png)](http://travis-ci.org/webbit/webbit)\n\n## Getting it\n\nPrebuilt JARs are available from the [central Maven repository](http://search.maven.org/#search%7Cga%7C1%7Cwebbit) or the [Sonatype Maven repository](https://oss.sonatype.org/content/repositories/releases/org/webbitserver/webbit/).\n\nAlternatively, you can get the latest code from Git and build it yourself:\n\n    git clone git://github.com/webbit/webbit.git\n    cd webbit\n\n### Make\n\nBuild is done with `make`. On OS-X and Linux this should work out of the box. On Solaris, use `gmake`. On Windows you will need Cygwin.\n\n    make\n\n### Maven\n\n    mvn install\n\n## Quick start\n\nStart a web server on port 8080 and serve some static files:\n\n```java\nWebServer webServer = WebServers.createWebServer(8080)\n            .add(new StaticFileHandler(\"/web\")) // path to web content\n            .start()\n            .get();\n```\n\nThat was easy.\n\nNow let's build a WebSocketHandler.\n\n```java\npublic class HelloWebSockets extends BaseWebSocketHandler {\n    private int connectionCount;\n\n    public void onOpen(WebSocketConnection connection) {\n        connection.send(\"Hello! There are \" + connectionCount + \" other connections active\");\n        connectionCount++;\n    }\n\n    public void onClose(WebSocketConnection connection) {\n        connectionCount--;\n    }\n\n    public void onMessage(WebSocketConnection connection, String message) {\n        connection.send(message.toUpperCase()); // echo back message in upper case\n    }\n\n    public static void main(String[] args) {\n        WebServer webServer = WebServers.createWebServer(8080)\n                .add(\"/hellowebsocket\", new HelloWebSockets())\n                .add(new StaticFileHandler(\"/web\"));\n        webServer.start();\n        System.out.println(\"Server running at \" + webServer.getUri());\n    }\n}\n```\n\nAnd a page that uses the WebSocket (web/index.html)\n\n```html\n\u003chtml\u003e\n  \u003cbody\u003e\n\n    \u003c!-- Send text to websocket --\u003e\n    \u003cinput id=\"userInput\" type=\"text\"\u003e\n    \u003cbutton onclick=\"ws.send(document.getElementById('userInput').value)\"\u003eSend\u003c/button\u003e\n\n    \u003c!-- Results --\u003e\n    \u003cdiv id=\"message\"\u003e\u003c/div\u003e\n\n    \u003cscript\u003e\n      function showMessage(text) {\n        document.getElementById('message').innerHTML = text;\n      }\n\n      var ws = new WebSocket('ws://' + document.location.host + '/hellowebsocket');\n      showMessage('Connecting...');\n      ws.onopen = function() { showMessage('Connected!'); };\n      ws.onclose = function() { showMessage('Lost connection'); };\n      ws.onmessage = function(msg) { showMessage(msg.data); };\n    \u003c/script\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Contributing\n\n### Running JUnit tests\n\n    mvn clean test\n\nor\n\n    make clean test\n\n### Running Autobahn tests\n\n[Autobahn](http://www.tavendo.de/autobahn) is a WebSocket server implemented in Python that comes with an extensive\n[test suite](http://www.tavendo.de/autobahn/testsuite.html) that can be used to test other WebSocket servers as well.\n\nWe're using it to test Webbit.\n\nInstalling Autobahn\n\n    git submodule update --init\n\nRunning Autobahn tests\n\nIn shell A:\n\n    make echo\n\nIn shell B:\n\n    make autobahn\n\nOpen `reports/servers/index.html` to see the results.\n\n## More\n\n+   [Docs on wiki](https://github.com/webbit/webbit/wiki)\n+   [Webbit mailing list](http://groups.google.com/group/webbit)\n+   [@webbitserver](http://twitter.com/webbitserver) on Twitter\n+   A [web based chat room](https://github.com/webbit/webbit/tree/master/src/test/java/samples/chatroom) is available in the samples directory. To try it out: 'make chatroom'\n+   Jay Fields has written a [WebSockets with Clojure introduction](http://blog.jayfields.com/2011/02/clojure-web-socket-introduction.html) that uses Webbit\n\n","funding_links":[],"categories":["Java","III. Network and Integration","Tools per Language","网络编程"],"sub_categories":["4. Http and ssh","Java VM"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebbit%2Fwebbit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebbit%2Fwebbit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebbit%2Fwebbit/lists"}