├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── build.gradle ├── gradle.properties ├── gradle ├── maven.gradle ├── setup.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src ├── modules ├── README.md ├── ceylon │ └── webapp │ │ ├── README.md │ │ └── mods │ │ └── io.vertx~example-web-app~1.0.1 │ │ ├── App.ceylon │ │ ├── StaticData.ceylon │ │ ├── mod.json │ │ ├── server-keystore.jks │ │ └── web │ │ ├── css │ │ ├── README │ │ ├── bootstrap.less │ │ ├── forms.less │ │ ├── mixins.less │ │ ├── patterns.less │ │ ├── reset.less │ │ ├── scaffolding.less │ │ ├── tables.less │ │ ├── type.less │ │ └── variables.less │ │ ├── index.html │ │ ├── js │ │ ├── client_app.js │ │ └── vertxbus.js │ │ └── js3rdparty │ │ ├── README │ │ ├── bootstrap-alerts.js │ │ ├── bootstrap-tabs.js │ │ ├── jquery-1.7.1.min.js │ │ ├── knockout-2.0.0.js │ │ ├── less-1.2.1.min.js │ │ └── sockjs-min-0.3.4.js ├── groovy │ ├── deploymod │ │ ├── Deploy.groovy │ │ ├── README.md │ │ └── mods │ │ │ └── io.vertx~my-mod~1.0 │ │ │ ├── app.js │ │ │ └── mod.json │ └── webapp │ │ ├── README.md │ │ └── mods │ │ └── io.vertx~example-web-app~1.0 │ │ ├── App.groovy │ │ ├── StaticData.groovy │ │ ├── mod.json │ │ ├── server-keystore.jks │ │ └── web │ │ ├── css │ │ ├── README │ │ ├── bootstrap.less │ │ ├── forms.less │ │ ├── mixins.less │ │ ├── patterns.less │ │ ├── reset.less │ │ ├── scaffolding.less │ │ ├── tables.less │ │ ├── type.less │ │ └── variables.less │ │ ├── index.html │ │ ├── js │ │ ├── client_app.js │ │ └── vertxbus.js │ │ └── js3rdparty │ │ ├── README │ │ ├── bootstrap-alerts.js │ │ ├── bootstrap-tabs.js │ │ ├── jquery-1.7.1.min.js │ │ ├── knockout-2.0.0.js │ │ ├── less-1.2.1.min.js │ │ └── sockjs-min-0.3.4.js ├── java │ └── javasource │ │ ├── README.md │ │ └── mods │ │ └── io.vertx~simple-source-mod~1.0 │ │ ├── EchoServer.java │ │ └── mod.json ├── javascript │ ├── angularjs │ │ ├── README.md │ │ └── mods │ │ │ └── io.vertx~example-web-app~1.0 │ │ │ ├── app.js │ │ │ ├── mod.json │ │ │ ├── server-keystore.jks │ │ │ ├── static_data.js │ │ │ └── web │ │ │ ├── css │ │ │ ├── README │ │ │ ├── bootstrap.less │ │ │ ├── forms.less │ │ │ ├── mixins.less │ │ │ ├── patterns.less │ │ │ ├── reset.less │ │ │ ├── scaffolding.less │ │ │ ├── tables.less │ │ │ ├── type.less │ │ │ └── variables.less │ │ │ ├── index.html │ │ │ ├── js │ │ │ ├── client_app.js │ │ │ └── vertxbus.js │ │ │ └── js3rdparty │ │ │ ├── README │ │ │ ├── angular-1.0.1.js │ │ │ ├── bootstrap-alerts.js │ │ │ ├── bootstrap-tabs.js │ │ │ ├── jquery-1.7.1.min.js │ │ │ ├── less-1.2.1.min.js │ │ │ └── sockjs-min-0.3.4.js │ ├── deploymod │ │ ├── README.md │ │ ├── deploy.js │ │ └── mods │ │ │ └── org.foo~my-mod~1.0 │ │ │ ├── app.js │ │ │ └── mod.json │ ├── includemod │ │ └── mods │ │ │ ├── com.acme~common-stuff~v1.0 │ │ │ ├── bar.js │ │ │ ├── mod.json │ │ │ └── test.js │ │ │ └── com.acme~module1~v1.0 │ │ │ ├── mod.json │ │ │ └── run_module_1.js │ └── webapp │ │ ├── README.md │ │ └── mods │ │ └── io.vertx~example-web-app~1.0 │ │ ├── app.js │ │ ├── mod.json │ │ ├── mods │ │ ├── io.vertx~mod-auth-mgr~2.0.0-CR1 │ │ │ └── mod.json │ │ ├── io.vertx~mod-mongo-persistor~2.0.0-CR1 │ │ │ ├── lib │ │ │ │ └── mongo-java-driver-2.11.1.jar │ │ │ └── mod.json │ │ ├── io.vertx~mod-web-server~2.0.0-CR1 │ │ │ └── mod.json │ │ └── io.vertx~mod-web-server~2.0.0-CR2-SNAPSHOT │ │ │ └── mod.json │ │ ├── server-keystore.jks │ │ ├── static_data.js │ │ └── web │ │ ├── css │ │ ├── README │ │ ├── bootstrap.less │ │ ├── forms.less │ │ ├── mixins.less │ │ ├── patterns.less │ │ ├── reset.less │ │ ├── scaffolding.less │ │ ├── tables.less │ │ ├── type.less │ │ └── variables.less │ │ ├── index.html │ │ ├── js │ │ ├── client_app.js │ │ └── vertxbus.js │ │ └── js3rdparty │ │ ├── README │ │ ├── bootstrap-alerts.js │ │ ├── bootstrap-tabs.js │ │ ├── jquery-1.7.1.min.js │ │ ├── knockout-2.0.0.js │ │ ├── less-1.2.1.min.js │ │ └── sockjs-min-0.3.4.js ├── python │ └── webapp │ │ ├── README.md │ │ └── mods │ │ └── io.vertx~example-web-app~1.0 │ │ ├── app.py │ │ ├── mod.json │ │ ├── server-keystore.jks │ │ ├── static_data.py │ │ └── web │ │ ├── css │ │ ├── README │ │ ├── bootstrap.less │ │ ├── forms.less │ │ ├── mixins.less │ │ ├── patterns.less │ │ ├── reset.less │ │ ├── scaffolding.less │ │ ├── tables.less │ │ ├── type.less │ │ └── variables.less │ │ ├── index.html │ │ ├── js │ │ ├── client_app.js │ │ └── vertxbus.js │ │ └── js3rdparty │ │ ├── README │ │ ├── bootstrap-alerts.js │ │ ├── bootstrap-tabs.js │ │ ├── jquery-1.7.1.min.js │ │ ├── knockout-2.0.0.js │ │ ├── less-1.2.1.min.js │ │ └── sockjs-min-0.3.4.js ├── ruby │ └── webapp │ │ ├── README.md │ │ └── mods │ │ └── io.vertx~example-web-app~1.0 │ │ ├── app.rb │ │ ├── mod.json │ │ ├── server-keystore.jks │ │ ├── static_data.rb │ │ └── web │ │ ├── css │ │ ├── README │ │ ├── bootstrap.less │ │ ├── forms.less │ │ ├── mixins.less │ │ ├── patterns.less │ │ ├── reset.less │ │ ├── scaffolding.less │ │ ├── tables.less │ │ ├── type.less │ │ └── variables.less │ │ ├── index.html │ │ ├── js │ │ ├── client_app.js │ │ └── vertxbus.js │ │ └── js3rdparty │ │ ├── README │ │ ├── bootstrap-alerts.js │ │ ├── bootstrap-tabs.js │ │ ├── jquery-1.7.1.min.js │ │ ├── knockout-2.0.0.js │ │ ├── less-1.2.1.min.js │ │ └── sockjs-min-0.3.4.js └── scala │ └── webapp │ ├── README.md │ └── mods │ └── io.vertx~example-web-app~1.0 │ ├── app.scala │ ├── mod.json │ ├── mods │ ├── io.vertx~mod-auth-mgr~2.0.0-CR1 │ │ └── mod.json │ ├── io.vertx~mod-mongo-persistor~2.0.0-CR1 │ │ ├── lib │ │ │ └── mongo-java-driver-2.11.1.jar │ │ └── mod.json │ ├── io.vertx~mod-web-server~2.0.0-CR1 │ │ └── mod.json │ └── io.vertx~mod-web-server~2.0.0-CR2-SNAPSHOT │ │ └── mod.json │ ├── server-keystore.jks │ ├── static_data.js │ └── web │ ├── css │ ├── README │ ├── bootstrap.less │ ├── forms.less │ ├── mixins.less │ ├── patterns.less │ ├── reset.less │ ├── scaffolding.less │ ├── tables.less │ ├── type.less │ └── variables.less │ ├── index.html │ ├── js │ ├── client_app.js │ └── vertxbus.js │ └── js3rdparty │ ├── README │ ├── bootstrap-alerts.js │ ├── bootstrap-tabs.js │ ├── jquery-1.7.1.min.js │ ├── knockout-2.0.0.js │ ├── less-1.2.1.min.js │ └── sockjs-min-0.3.4.js └── raw ├── README.md ├── ceylon ├── README.md ├── asyncstart │ └── Starter.ceylon ├── echo │ ├── EchoClient.ceylon │ └── EchoServer.ceylon ├── eventbus_pointtopoint │ ├── Receiver.ceylon │ └── Sender.ceylon ├── eventbus_pubsub │ ├── Receiver.ceylon │ └── Sender.ceylon ├── eventbusbridge │ ├── BridgeServer.ceylon │ ├── index.html │ └── vertxbus.js ├── fanout │ └── FanoutServer.ceylon ├── http │ ├── ClientExample.ceylon │ └── ServerExample.ceylon ├── httphelloworld │ └── HelloWorldServer.ceylon ├── https │ ├── ClientExample.ceylon │ └── ServerExample.ceylon ├── proxyserver │ ├── Client.ceylon │ ├── ProxyServer.ceylon │ └── Server.ceylon ├── route_match │ └── RouteMatchExample.ceylon ├── sendfile │ ├── SendFileExample.ceylon │ ├── index.html │ ├── page1.html │ └── page2.html ├── server-keystore.jks ├── simpleform │ ├── SimpleFormServer.ceylon │ └── index.html ├── simpleformupload │ ├── SimpleFormUploadServer.ceylon │ └── index.html ├── sockjs │ ├── SockJSExample.ceylon │ └── index.html ├── ssl │ ├── SSLClient.ceylon │ └── SSLServer.ceylon ├── upload │ ├── UploadClient.ceylon │ ├── UploadServer.ceylon │ └── upload.txt └── websockets │ ├── WebsocketsClient.ceylon │ ├── WebsocketsExample.ceylon │ └── ws.html ├── clojure ├── README.md ├── async │ ├── .gitignore │ ├── README.md │ ├── project.clj │ └── src │ │ └── async │ │ └── core.clj ├── echo │ ├── echo-client.clj │ └── echo-server.clj ├── embedded │ ├── .gitignore │ ├── README.md │ ├── project.clj │ └── src │ │ └── embedded │ │ └── core.clj ├── eventbus_pointtopoint │ ├── receiver.clj │ └── sender.clj ├── eventbus_pubsub │ ├── receiver.clj │ └── sender.clj ├── eventbusbridge-cljs │ ├── .gitignore │ ├── README.md │ ├── bridge-server.clj │ ├── project.clj │ ├── resources │ │ └── index.html │ └── src │ │ └── eventbusbridge_cljs │ │ └── client.cljs ├── eventbusbridge │ ├── bridge-server.clj │ ├── index.html │ └── vertxbus.js ├── fanout │ └── server.clj ├── http │ ├── client.clj │ └── server.clj ├── https │ ├── client.clj │ └── server.clj ├── proxy │ ├── client.clj │ ├── proxy-server.clj │ └── server.clj ├── pubsub │ └── server.clj ├── repl │ └── server.clj ├── route_match │ ├── index.html │ └── router.clj ├── sendfile │ ├── index.html │ ├── page1.html │ ├── page2.html │ └── send-file.clj ├── server-keystore.jks ├── sockjs │ ├── index.html │ └── sockjs.clj ├── ssl │ ├── client.clj │ └── server.clj ├── udp │ ├── udp-group-listener.clj │ ├── udp-group-sender.clj │ ├── udp-listener.clj │ └── udp-sender.clj ├── upload │ ├── client.clj │ ├── server.clj │ └── upload.txt └── websockets │ ├── web-socket.clj │ └── ws.html ├── coffeescript ├── commonjs │ ├── handler.coffee │ ├── main.coffee │ └── server.coffee ├── echo │ ├── echo_client.coffee │ └── echo_server.coffee ├── http │ └── http_server.coffee └── load │ ├── brew.coffee │ └── flat_white.coffee ├── groovy ├── README.md ├── echo │ ├── EchoClient.groovy │ └── EchoServer.groovy ├── eventbus_pointtopoint │ ├── Receiver.groovy │ └── Sender.groovy ├── eventbus_pubsub │ ├── Receiver.groovy │ └── Sender.groovy ├── eventbusbridge │ ├── BridgeServer.groovy │ ├── index.html │ └── vertxbus.js ├── fanout │ └── FanoutServer.groovy ├── http │ ├── Client.groovy │ └── Server.groovy ├── https │ ├── Client.groovy │ └── Server.groovy ├── proxy │ ├── Client.groovy │ ├── Proxy.groovy │ └── Server.groovy ├── pubsub │ └── PubSubServer.groovy ├── route_match │ ├── RouteMatchServer.groovy │ └── index.html ├── sendfile │ ├── SendFile.groovy │ ├── index.html │ ├── page1.html │ └── page2.html ├── server-keystore.jks ├── simpleform │ ├── SimpleFormServer.groovy │ └── index.html ├── simpleformupload │ ├── SimpleFormUploadServer.groovy │ └── index.html ├── sockjs │ ├── SockJSExample.groovy │ └── index.html ├── ssl │ ├── Client.groovy │ └── Server.groovy ├── upload │ ├── Client.groovy │ ├── Server.groovy │ └── upload.txt └── websockets │ ├── WebSocketsClient.groovy │ ├── WebSocketsServer.groovy │ └── ws.html ├── java ├── README.md ├── ebb_memleak_test │ ├── BridgeServer.java │ ├── ServerHook.java │ ├── index.html │ ├── sockjs-0.3.4.js │ └── vertxbus.js ├── echo │ ├── EchoClient.java │ └── EchoServer.java ├── eventbus_pointtopoint │ ├── Receiver.java │ └── Sender.java ├── eventbus_pubsub │ ├── Receiver.java │ └── Sender.java ├── eventbusbridge │ ├── BridgeServer.java │ ├── ServerHook.java │ ├── index.html │ └── vertxbus.js ├── fanout │ └── FanoutServer.java ├── http │ ├── ClientExample.java │ └── ServerExample.java ├── httphelloworld │ └── HelloWorldServer.java ├── httpperf │ ├── PerfClient.java │ ├── PerfServer.java │ ├── README.md │ ├── foo.html │ ├── nodejs-cluster-server.js │ ├── nodejs-server.js │ ├── vertx-server.groovy │ ├── vertx-server.js │ └── vertx_server.rb ├── https │ ├── ClientExample.java │ └── ServerExample.java ├── perf │ └── RateCounter.java ├── proxy │ ├── Client.java │ ├── ProxyServer.java │ └── Server.java ├── pubsub │ └── PubSubServer.java ├── resourceload │ ├── Quux.java │ ├── ResourceLoadExample.java │ ├── bar.txt │ └── foo.xml ├── route_match │ ├── RouteMatchExample.java │ └── index.html ├── sendfile │ ├── SendFileExample.java │ ├── index.html │ ├── page1.html │ └── page2.html ├── server-keystore.jks ├── simpleform │ ├── SimpleFormServer.java │ └── index.html ├── simpleformupload │ ├── SimpleFormUploadServer.java │ └── index.html ├── sockjs │ ├── SockJSExample.java │ └── index.html ├── ssl │ ├── SSLClient.java │ └── SSLServer.java ├── upload │ ├── UploadClient.java │ ├── UploadServer.java │ └── upload.txt ├── websockets │ ├── WebsocketsClient.java │ ├── WebsocketsExample.java │ └── ws.html └── wsperf │ ├── ConnectClient.java │ ├── ConnectServer.java │ ├── PerfClient.java │ ├── PerfServer.java │ └── vertx-server.js ├── javascript ├── README.md ├── commonjs │ ├── handler.js │ ├── main.js │ └── server.js ├── config │ ├── conf.json │ └── configured.js ├── conn_perf │ ├── conn_client.js │ └── conn_server.js ├── deploy │ ├── child.js │ └── deployer.js ├── deploy_many │ ├── child.js │ └── mem.js ├── eb_perf │ ├── handler.js │ └── sender.js ├── echo │ ├── echo_client.js │ └── echo_server.js ├── eventbus_pointtopoint │ ├── receiver.js │ └── sender.js ├── eventbus_pubsub │ ├── receiver.js │ └── sender.js ├── eventbusbridge │ ├── bridge_server.js │ ├── index.html │ └── vertxbus.js ├── fanout │ └── fanout_server.js ├── http │ ├── http_client.js │ └── http_server.js ├── httphelloworld │ └── http_server.js ├── https │ ├── https_client.js │ └── https_server.js ├── proxy │ ├── http_client.js │ ├── http_server.js │ └── proxy_server.js ├── pubsub │ └── pubsub_server.js ├── route_match │ ├── index.html │ └── route_match_example.js ├── sendfile │ ├── index.html │ ├── page1.html │ ├── page2.html │ └── sendfile.js ├── server-keystore.jks ├── sockjs │ ├── index.html │ └── sockjs.js ├── ssl │ ├── ssl_client.js │ └── ssl_server.js ├── upload │ ├── upload.txt │ ├── upload_client.js │ └── upload_server.js └── websockets │ ├── ws.html │ ├── ws_client.js │ └── ws_server.js ├── python ├── README.md ├── deploy_many │ ├── child.py │ └── mem.py ├── echo │ ├── echo_client.py │ └── echo_server.py ├── eventbus_pointtopoint │ ├── receiver.py │ └── sender.py ├── eventbus_pubsub │ ├── receiver.py │ └── sender.py ├── eventbusbridge │ ├── bridge_server.py │ ├── index.html │ └── vertxbus.js ├── fanout │ └── fanout_server.py ├── http │ ├── http_client.py │ └── http_server.py ├── https │ ├── https_client.py │ └── https_server.py ├── proxy │ ├── http_client.py │ ├── http_server.py │ └── proxy_server.py ├── pubsub │ └── pubsub_server.py ├── route_match │ ├── index.html │ └── route_match_server.py ├── sendfile │ ├── index.html │ ├── page1.html │ ├── page2.html │ └── sendfile.py ├── server-keystore.jks ├── sockjs │ ├── index.html │ └── sockjs.py ├── ssl │ ├── ssl_client.py │ └── ssl_server.py ├── upload │ ├── upload.txt │ ├── upload_client.py │ └── upload_server.py └── websockets │ ├── websockets.py │ └── ws.html ├── ruby ├── README.md ├── deploy_many │ ├── child.rb │ └── mem.rb ├── echo │ ├── echo_client.rb │ └── echo_server.rb ├── eventbus_pointtopoint │ ├── receiver.rb │ └── sender.rb ├── eventbus_pubsub │ ├── receiver.rb │ └── sender.rb ├── eventbusbridge │ ├── bridge_server.rb │ ├── index.html │ └── vertxbus.js ├── fanout │ └── fanout_server.rb ├── http │ ├── http_client.rb │ └── http_server.rb ├── https │ ├── https_client.rb │ └── https_server.rb ├── proxy │ ├── http_client.rb │ ├── http_server.rb │ └── proxy_server.rb ├── pubsub │ └── pubsub_server.rb ├── route_match │ ├── index.html │ └── route_match_example.rb ├── sendfile │ ├── index.html │ ├── page1.html │ ├── page2.html │ └── sendfile.rb ├── server-keystore.jks ├── sockjs │ ├── index.html │ └── sockjs.rb ├── ssl │ ├── ssl_client.rb │ └── ssl_server.rb ├── upload │ ├── upload.txt │ ├── upload_client.rb │ └── upload_server.rb └── websockets │ ├── websockets.rb │ └── ws.html └── scala ├── README.md ├── echo ├── EchoClient.scala └── EchoServer.scala ├── eventbus_pointtopoint ├── Receiver.scala └── Sender.scala ├── eventbus_pubsub ├── Receiver.scala └── Sender.scala ├── fanout └── FanoutServer.scala ├── http ├── Client.scala └── Server.scala ├── https ├── ClientExample.scala └── ServerExample.scala ├── perf └── RateCounter.scala ├── proxy ├── Client.scala ├── ProxyServer.scala └── Server.scala ├── pubsub └── PubSubServer.scala ├── resourceload ├── ResourceLoadExample.scala ├── bar.txt └── foo.xml ├── route_match ├── RouteMatchExample.scala └── index.html ├── sendfile ├── SendFileExample.scala ├── index.html ├── page1.html └── page2.html ├── server-keystore.jks ├── simpleform ├── SimpleFormServer.scala └── index.html ├── simpleformupload ├── SimpleFormUploadServer.scala └── index.html ├── sockjs ├── SockJSExample.scala └── index.html ├── ssl ├── SSLClient.scala └── SSLServer.scala ├── upload ├── UploadClient.scala ├── UploadServer.scala └── upload.txt ├── websockets ├── WebsocketsClient.scala ├── WebsocketsExample.scala └── ws.html └── wsperf ├── ConnectClient.scala ├── ConnectServer.scala ├── PerfClient.scala ├── PerfServer.scala └── vertx-server.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .gradle 3 | .idea 4 | .classpath 5 | .project 6 | .settings 7 | .yardoc 8 | .yardopts 9 | bin 10 | build 11 | target 12 | out 13 | *.iml 14 | *.ipr 15 | *.iws 16 | test-output 17 | Scratch.java 18 | ScratchTest.java 19 | test-results 20 | test-tmp 21 | *.class 22 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | vert.x is licensed under the Apache License, Version 2.0 (the "License"); 2 | you may not use this file except in compliance with the License. 3 | 4 | You may obtain a copy of the License at 5 | 6 | http://www.apache.org/licenses/LICENSE-2.0 -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vert.x 2.x is **deprecated** - use instead https://github.com/vert-x3/vertx-examples 2 | 3 | ## Vert.x 2.x Examples 4 | 5 | This project contains various examples of using Vert.x 2.x 6 | 7 | Simple examples of raw verticles are in the directory `src/raw`. 8 | 9 | Examples using modules are in the directory `src/modules`. 10 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2011 the original author or authors. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | version=1.0.0-SNAPSHOT 17 | group=io.vertx 18 | gradleVersion=1.5 19 | vertxVersion=2.1M2-SNAPSHOT 20 | junitVersion=4.11 21 | -------------------------------------------------------------------------------- /gradle/setup.gradle: -------------------------------------------------------------------------------- 1 | 2 | task wrapper(type: Wrapper, description: "Create a Gradle self-download wrapper") { 3 | group = 'Project Setup' 4 | gradleVersion = rootProject.gradleVersion 5 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Apr 08 15:40:42 BST 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=http\://services.gradle.org/distributions/gradle-1.5-bin.zip 7 | -------------------------------------------------------------------------------- /src/modules/README.md: -------------------------------------------------------------------------------- 1 | # Vert.x JavaScript Module Examples 2 | 3 | Here are some basic examples demonstrating modules 4 | 5 | Prerequisites: 6 | 7 | 1) The bin directory from the distro must be on your PATH - this should have been done as part of the install procedure. 8 | 9 | 2) JDK/JRE 1.7.0+ must be installed and the JDK/JRE bin directory must be on your PATH 10 | 11 | Please see the README.md file in the sub directories for more information -------------------------------------------------------------------------------- /src/modules/ceylon/webapp/README.md: -------------------------------------------------------------------------------- 1 | # "Real-time" Web Application Example 2 | 3 | This is a full end-end "real-time" web appplication which has a modern JavaScript client side MVVM application that communicates via the event bus with a persistor. 4 | 5 | It's the same application from the tutorial. 6 | 7 | You will need an instance of MongoDB server (with default settings) running on localhost. 8 | 9 | To run: 10 | 11 | vertx runmod io.vertx~example-web-app~1.0 12 | 13 | To see log output set the following in `conf/logging.properties` in the Vert.x install directory. 14 | 15 | org.vertx.level=FINE 16 | 17 | Then point your browser at https://localhost:8080 and start shopping! (Note it's https not http!) 18 | 19 | The example uses knockout.js at the client side to render the application. Vert.x is completely agnostic as to what 20 | client side toolkit you use - we have just chosen this for this example. 21 | 22 | The example uses the Vert.x event bus to extend into client side JavaScript so the browser can communicate with 23 | server side components. -------------------------------------------------------------------------------- /src/modules/ceylon/webapp/mods/io.vertx~example-web-app~1.0.1/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "App.ceylon" 3 | } -------------------------------------------------------------------------------- /src/modules/ceylon/webapp/mods/io.vertx~example-web-app~1.0.1/server-keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/modules/ceylon/webapp/mods/io.vertx~example-web-app~1.0.1/server-keystore.jks -------------------------------------------------------------------------------- /src/modules/ceylon/webapp/mods/io.vertx~example-web-app~1.0.1/web/css/README: -------------------------------------------------------------------------------- 1 | css (less) stuff used by Twitter bootstrap 2 | 3 | Vert.x doesn't require anything here, it's just because we have chosen to build the front end app using Bootstrap but you could use whatever toolset you are more comfortable with. -------------------------------------------------------------------------------- /src/modules/ceylon/webapp/mods/io.vertx~example-web-app~1.0.1/web/css/bootstrap.less: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap @VERSION 3 | * 4 | * Copyright 2011 Twitter, Inc 5 | * Licensed under the Apache License v2.0 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Designed and built with all the love in the world @twitter by @mdo and @fat. 9 | * Date: @DATE 10 | */ 11 | 12 | // CSS Reset 13 | @import "reset"; 14 | 15 | // Core variables and mixins 16 | @import "variables"; // Modify this for custom colors, font-sizes, etc 17 | @import "mixins"; 18 | 19 | // Grid system and page structure 20 | @import "scaffolding"; 21 | 22 | // Styled patterns and elements 23 | @import "type"; 24 | @import "forms"; 25 | @import "tables"; 26 | @import "patterns"; -------------------------------------------------------------------------------- /src/modules/ceylon/webapp/mods/io.vertx~example-web-app~1.0.1/web/js3rdparty/README: -------------------------------------------------------------------------------- 1 | This is the 3rd party JS libs used by the front-end JS app. 2 | 3 | The only thing that vert.x actually needs here is SockJS. 4 | 5 | The rest is just because we decided to make the fron end app using knockout.js and Twitter bootstrap, but you could use whatever front-end JS toolkit you are most comfortable with. -------------------------------------------------------------------------------- /src/modules/groovy/deploymod/Deploy.groovy: -------------------------------------------------------------------------------- 1 | package deploymod 2 | 3 | println "Deploying module" 4 | 5 | conf = ["some-var" : "hello"] 6 | 7 | container.deployModule("io.vertx~my-mod~1.0", conf, 1) { asyncResult -> 8 | if (asyncResult.succeeded()) { 9 | println "This gets called when deployment is complete, deployment id is $asyncResult.result()" 10 | } else { 11 | println "Failed to deploy ${asyncResult.cause()}" 12 | } 13 | } -------------------------------------------------------------------------------- /src/modules/groovy/deploymod/README.md: -------------------------------------------------------------------------------- 1 | # Example of programmatically deploying a module 2 | 3 | This example shows how to programmatically deploy a module from a verticle. 4 | 5 | To run: 6 | 7 | vertx run Deploy.groovy 8 | -------------------------------------------------------------------------------- /src/modules/groovy/deploymod/mods/io.vertx~my-mod~1.0/app.js: -------------------------------------------------------------------------------- 1 | var container = require('vertx/container') 2 | var console = require('vertx/console') 3 | 4 | console.log("in MyMod!") 5 | 6 | // Display the value from the config 7 | console.log("some-var is " + container.config['some-var']) 8 | -------------------------------------------------------------------------------- /src/modules/groovy/deploymod/mods/io.vertx~my-mod~1.0/mod.json: -------------------------------------------------------------------------------- 1 | // This is the module descriptor - all modules must have one 2 | 3 | { 4 | "main": "app.js" // Main tells Vert.x which verticle to start when the module is deployed 5 | } -------------------------------------------------------------------------------- /src/modules/groovy/webapp/README.md: -------------------------------------------------------------------------------- 1 | # "Real-time" Web Application Example 2 | 3 | This is a full end-end "real-time" web appplication which has a modern JavaScript client side MVVM application that communicates via the event bus with a persistor. 4 | 5 | It's the same application from the tutorial. 6 | 7 | You will need an instance of MongoDB server (with default settings) running on localhost. 8 | 9 | To run: 10 | 11 | vertx runmod io.vertx~example-web-app~1.0 12 | 13 | To see log output set the following in `conf/logging.properties` in the Vert.x install directory. 14 | 15 | org.vertx.level=FINE 16 | 17 | Then point your browser at https://localhost:8080 and start shopping! (Note it's https not http!) 18 | 19 | The example uses knockout.js at the client side to render the application. Vert.x is completely agnostic as to what 20 | client side toolkit you use - we have just chosen this for this example. 21 | 22 | The example uses the Vert.x event bus to extend into client side JavaScript so the browser can communicate with 23 | server side components. -------------------------------------------------------------------------------- /src/modules/groovy/webapp/mods/io.vertx~example-web-app~1.0/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "App.groovy" 3 | } -------------------------------------------------------------------------------- /src/modules/groovy/webapp/mods/io.vertx~example-web-app~1.0/server-keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/modules/groovy/webapp/mods/io.vertx~example-web-app~1.0/server-keystore.jks -------------------------------------------------------------------------------- /src/modules/groovy/webapp/mods/io.vertx~example-web-app~1.0/web/css/README: -------------------------------------------------------------------------------- 1 | css (less) stuff used by Twitter bootstrap 2 | 3 | Vert.x doesn't require anything here, it's just because we have chosen to build the front end app using Bootstrap but you could use whatever toolset you are more comfortable with. -------------------------------------------------------------------------------- /src/modules/groovy/webapp/mods/io.vertx~example-web-app~1.0/web/css/bootstrap.less: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap @VERSION 3 | * 4 | * Copyright 2011 Twitter, Inc 5 | * Licensed under the Apache License v2.0 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Designed and built with all the love in the world @twitter by @mdo and @fat. 9 | * Date: @DATE 10 | */ 11 | 12 | // CSS Reset 13 | @import "reset"; 14 | 15 | // Core variables and mixins 16 | @import "variables"; // Modify this for custom colors, font-sizes, etc 17 | @import "mixins"; 18 | 19 | // Grid system and page structure 20 | @import "scaffolding"; 21 | 22 | // Styled patterns and elements 23 | @import "type"; 24 | @import "forms"; 25 | @import "tables"; 26 | @import "patterns"; -------------------------------------------------------------------------------- /src/modules/groovy/webapp/mods/io.vertx~example-web-app~1.0/web/js3rdparty/README: -------------------------------------------------------------------------------- 1 | This is the 3rd party JS libs used by the front-end JS app. 2 | 3 | The only thing that vert.x actually needs here is SockJS. 4 | 5 | The rest is just because we decided to make the fron end app using knockout.js and Twitter bootstrap, but you could use whatever front-end JS toolkit you are most comfortable with. -------------------------------------------------------------------------------- /src/modules/java/javasource/README.md: -------------------------------------------------------------------------------- 1 | # Simple Java Source Module 2 | 3 | This example shows how you can have Java source verticles (i.e. not precompiled Java) as mains in 4 | a basic module. 5 | 6 | This example is a simple echo server 7 | 8 | To run: 9 | 10 | vertx runmod io.vertx~simple-source-mod~1.0 -------------------------------------------------------------------------------- /src/modules/java/javasource/mods/io.vertx~simple-source-mod~1.0/EchoServer.java: -------------------------------------------------------------------------------- 1 | import org.vertx.java.core.Handler; 2 | import org.vertx.java.core.net.NetSocket; 3 | import org.vertx.java.core.streams.Pump; 4 | import org.vertx.java.platform.Verticle; 5 | 6 | /* 7 | Simple Echo Server Java Source Verticle - note that it doesn't have to be pre-compiled! 8 | */ 9 | public class EchoServer extends Verticle { 10 | 11 | public void start() { 12 | vertx.createNetServer().connectHandler(new Handler() { 13 | public void handle(final NetSocket socket) { 14 | Pump.createPump(socket, socket).start(); 15 | } 16 | }).listen(1234); 17 | } 18 | } -------------------------------------------------------------------------------- /src/modules/java/javasource/mods/io.vertx~simple-source-mod~1.0/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "EchoServer.java" 3 | } -------------------------------------------------------------------------------- /src/modules/javascript/angularjs/README.md: -------------------------------------------------------------------------------- 1 | # "Real-time" Web Application Example 2 | 3 | This is basically the same as the `webapp` example in the sibling directory, but instead of using knockout.js it uses 4 | AngularJS 5 | 6 | To run: 7 | 8 | vertx runmod io.vertx~example-web-app~1.0 -------------------------------------------------------------------------------- /src/modules/javascript/angularjs/mods/io.vertx~example-web-app~1.0/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "app.js" 3 | } -------------------------------------------------------------------------------- /src/modules/javascript/angularjs/mods/io.vertx~example-web-app~1.0/server-keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/modules/javascript/angularjs/mods/io.vertx~example-web-app~1.0/server-keystore.jks -------------------------------------------------------------------------------- /src/modules/javascript/angularjs/mods/io.vertx~example-web-app~1.0/web/css/README: -------------------------------------------------------------------------------- 1 | css (less) stuff used by Twitter bootstrap 2 | 3 | Vert.x doesn't require anything here, it's just because we have chosen to build the front end app using Bootstrap but you could use whatever toolset you are more comfortable with. -------------------------------------------------------------------------------- /src/modules/javascript/angularjs/mods/io.vertx~example-web-app~1.0/web/css/bootstrap.less: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap @VERSION 3 | * 4 | * Copyright 2011 Twitter, Inc 5 | * Licensed under the Apache License v2.0 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Designed and built with all the love in the world @twitter by @mdo and @fat. 9 | * Date: @DATE 10 | */ 11 | 12 | // CSS Reset 13 | @import "reset"; 14 | 15 | // Core variables and mixins 16 | @import "variables"; // Modify this for custom colors, font-sizes, etc 17 | @import "mixins"; 18 | 19 | // Grid system and page structure 20 | @import "scaffolding"; 21 | 22 | // Styled patterns and elements 23 | @import "type"; 24 | @import "forms"; 25 | @import "tables"; 26 | @import "patterns"; -------------------------------------------------------------------------------- /src/modules/javascript/angularjs/mods/io.vertx~example-web-app~1.0/web/js3rdparty/README: -------------------------------------------------------------------------------- 1 | This is the 3rd party JS libs used by the front-end JS app. 2 | 3 | The only thing that vert.x actually needs here is SockJS. 4 | 5 | The rest is just because we decided to make the fron end app using knockout.js and Twitter bootstrap, but you could use whatever front-end JS toolkit you are most comfortable with. -------------------------------------------------------------------------------- /src/modules/javascript/deploymod/README.md: -------------------------------------------------------------------------------- 1 | # Example of programmatically deploying a module 2 | 3 | This example shows how to programmatically deploy a module from a verticle. 4 | 5 | To run: 6 | 7 | vertx run deploy.js -------------------------------------------------------------------------------- /src/modules/javascript/deploymod/deploy.js: -------------------------------------------------------------------------------- 1 | var container = require('vertx/container'); 2 | var console = require('vertx/console'); 3 | 4 | console.log("Deploying module"); 5 | 6 | var conf = {"some-var" : "hello"}; 7 | 8 | container.deployModule("org.foo~my-mod~1.0", conf, 1, function(err, deploymentID) { 9 | if (err) { 10 | console.log("Failed to deploy: " + err); 11 | } else { 12 | console.log("This gets called when deployment is complete, deployment id is " + deploymentID); 13 | } 14 | }); 15 | -------------------------------------------------------------------------------- /src/modules/javascript/deploymod/mods/org.foo~my-mod~1.0/app.js: -------------------------------------------------------------------------------- 1 | var container = require('vertx/container'); 2 | var console = require('vertx/console'); 3 | 4 | console.log("in MyMod!") 5 | console.log("some-var is " + container.config['some-var']) 6 | -------------------------------------------------------------------------------- /src/modules/javascript/deploymod/mods/org.foo~my-mod~1.0/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "app.js" 3 | } -------------------------------------------------------------------------------- /src/modules/javascript/includemod/mods/com.acme~common-stuff~v1.0/bar.js: -------------------------------------------------------------------------------- 1 | var sayHello = function(name) { 2 | return "Hello " + name; 3 | }; 4 | 5 | module.exports.sayHello = sayHello; 6 | -------------------------------------------------------------------------------- /src/modules/javascript/includemod/mods/com.acme~common-stuff~v1.0/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /src/modules/javascript/includemod/mods/com.acme~common-stuff~v1.0/test.js: -------------------------------------------------------------------------------- 1 | //Test if requiring bar lib works locally 2 | var bar = require("./bar.js"); 3 | 4 | if (bar.sayHello("User") == "Hello User") { 5 | console.log("requiring bar.js works"); 6 | } else { 7 | console.log("requiring bar.js didn't work"); 8 | } 9 | -------------------------------------------------------------------------------- /src/modules/javascript/includemod/mods/com.acme~module1~v1.0/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "includes": "com.acme~common-stuff~v1.0", 3 | "main": "run_module_1.js" 4 | } 5 | -------------------------------------------------------------------------------- /src/modules/javascript/includemod/mods/com.acme~module1~v1.0/run_module_1.js: -------------------------------------------------------------------------------- 1 | var vertx = require('vertx'); 2 | var console = require('vertx/console'); 3 | var bar = require('bar.js'); 4 | 5 | var server = vertx.createHttpServer(); 6 | 7 | server.requestHandler(function(request) { 8 | request.response.end(bar.sayHello("User")); 9 | }); 10 | 11 | server.listen(8181, 'localhost', function(err) { 12 | if (!err) { 13 | console.log("Server listening on 8181"); 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /src/modules/javascript/webapp/README.md: -------------------------------------------------------------------------------- 1 | # "Real-time" Web Application Example 2 | 3 | This is a full end-end "real-time" web appplication which has a modern JavaScript client side MVVM application that communicates via the event bus with a persistor. 4 | 5 | It's the same application from the tutorial. 6 | 7 | You will need an instance of MongoDB server (with default settings) running on localhost. 8 | 9 | To run: 10 | 11 | vertx runmod io.vertx~example-web-app~1.0 12 | 13 | To see log output set the following in `conf/logging.properties` in the Vert.x install directory. 14 | 15 | org.vertx.level=FINE 16 | 17 | Then point your browser at https://localhost:8080 and start shopping! (Note it's https not http!) 18 | 19 | The example uses knockout.js at the client side to render the application. Vert.x is completely agnostic as to what 20 | client side toolkit you use - we have just chosen this for this example. 21 | 22 | The example uses the Vert.x event bus to extend into client side JavaScript so the browser can communicate with 23 | server side components. -------------------------------------------------------------------------------- /src/modules/javascript/webapp/mods/io.vertx~example-web-app~1.0/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "app.js" 3 | } -------------------------------------------------------------------------------- /src/modules/javascript/webapp/mods/io.vertx~example-web-app~1.0/mods/io.vertx~mod-auth-mgr~2.0.0-CR1/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "org.vertx.mods.AuthManager", 3 | 4 | "description":"Simple auth-manager module for Vert.x", 5 | "licenses": ["The Apache Software License Version 2.0"], 6 | "author": "purplefox", 7 | "keywords": ["security", "auth", "authorisation", "authorization", "authentication", "login", "session"], 8 | "homepage": "https://github.com/vert-x/mod-auth-mgr" 9 | } -------------------------------------------------------------------------------- /src/modules/javascript/webapp/mods/io.vertx~example-web-app~1.0/mods/io.vertx~mod-mongo-persistor~2.0.0-CR1/lib/mongo-java-driver-2.11.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/modules/javascript/webapp/mods/io.vertx~example-web-app~1.0/mods/io.vertx~mod-mongo-persistor~2.0.0-CR1/lib/mongo-java-driver-2.11.1.jar -------------------------------------------------------------------------------- /src/modules/javascript/webapp/mods/io.vertx~example-web-app~1.0/mods/io.vertx~mod-mongo-persistor~2.0.0-CR1/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "org.vertx.mods.MongoPersistor", 3 | "worker": true, 4 | "multi-threaded": true, 5 | 6 | "description":"MongoDB persistor module for Vert.x", 7 | "licenses": ["The Apache Software License Version 2.0"], 8 | "author": "purplefox", 9 | "keywords": ["mongo", "mongodb", "database", "databases", "persistence", "json", "nosql"], 10 | "homepage": "https://github.com/vert-x/mod-mongo-persistor" 11 | } -------------------------------------------------------------------------------- /src/modules/javascript/webapp/mods/io.vertx~example-web-app~1.0/mods/io.vertx~mod-web-server~2.0.0-CR1/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "org.vertx.mods.web.WebServer", 3 | "preserve-cwd": true, 4 | 5 | "description":"Simple web server module for Vert.x", 6 | "licenses": ["The Apache Software License Version 2.0"], 7 | "author": "purplefox", 8 | "keywords": ["webserver", "web", "serve", "html", "http", "web-server", "sockjs", "bridge", "sockjs-bridge", "js"], 9 | "homepage": "https://github.com/vert-x/mod-web-server" 10 | } -------------------------------------------------------------------------------- /src/modules/javascript/webapp/mods/io.vertx~example-web-app~1.0/mods/io.vertx~mod-web-server~2.0.0-CR2-SNAPSHOT/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "org.vertx.mods.web.WebServer", 3 | "preserve-cwd": true, 4 | 5 | "description":"Simple web server module for Vert.x", 6 | "licenses": ["The Apache Software License Version 2.0"], 7 | "author": "purplefox", 8 | "keywords": ["webserver", "web", "serve", "html", "http", "web-server", "sockjs", "bridge", "sockjs-bridge", "js"], 9 | "homepage": "https://github.com/vert-x/mod-web-server" 10 | } -------------------------------------------------------------------------------- /src/modules/javascript/webapp/mods/io.vertx~example-web-app~1.0/server-keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/modules/javascript/webapp/mods/io.vertx~example-web-app~1.0/server-keystore.jks -------------------------------------------------------------------------------- /src/modules/javascript/webapp/mods/io.vertx~example-web-app~1.0/web/css/README: -------------------------------------------------------------------------------- 1 | css (less) stuff used by Twitter bootstrap 2 | 3 | Vert.x doesn't require anything here, it's just because we have chosen to build the front end app using Bootstrap but you could use whatever toolset you are more comfortable with. -------------------------------------------------------------------------------- /src/modules/javascript/webapp/mods/io.vertx~example-web-app~1.0/web/css/bootstrap.less: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap @VERSION 3 | * 4 | * Copyright 2011 Twitter, Inc 5 | * Licensed under the Apache License v2.0 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Designed and built with all the love in the world @twitter by @mdo and @fat. 9 | * Date: @DATE 10 | */ 11 | 12 | // CSS Reset 13 | @import "reset"; 14 | 15 | // Core variables and mixins 16 | @import "variables"; // Modify this for custom colors, font-sizes, etc 17 | @import "mixins"; 18 | 19 | // Grid system and page structure 20 | @import "scaffolding"; 21 | 22 | // Styled patterns and elements 23 | @import "type"; 24 | @import "forms"; 25 | @import "tables"; 26 | @import "patterns"; -------------------------------------------------------------------------------- /src/modules/javascript/webapp/mods/io.vertx~example-web-app~1.0/web/js3rdparty/README: -------------------------------------------------------------------------------- 1 | This is the 3rd party JS libs used by the front-end JS app. 2 | 3 | The only thing that vert.x actually needs here is SockJS. 4 | 5 | The rest is just because we decided to make the fron end app using knockout.js and Twitter bootstrap, but you could use whatever front-end JS toolkit you are most comfortable with. -------------------------------------------------------------------------------- /src/modules/python/webapp/README.md: -------------------------------------------------------------------------------- 1 | # "Real-time" Web Application Example 2 | 3 | This is a full end-end "real-time" web appplication which has a modern JavaScript client side MVVM application that communicates via the event bus with a persistor. 4 | 5 | It's the same application from the tutorial. 6 | 7 | You will need an instance of MongoDB server (with default settings) running on localhost. 8 | 9 | To run: 10 | 11 | vertx runmod io.vertx~example-web-app~1.0 12 | 13 | To see log output set the following in `conf/logging.properties` in the Vert.x install directory. 14 | 15 | org.vertx.level=FINE 16 | 17 | Then point your browser at https://localhost:8080 and start shopping! (Note it's https not http!) 18 | 19 | The example uses knockout.js at the client side to render the application. Vert.x is completely agnostic as to what 20 | client side toolkit you use - we have just chosen this for this example. 21 | 22 | The example uses the Vert.x event bus to extend into client side JavaScript so the browser can communicate with 23 | server side components. -------------------------------------------------------------------------------- /src/modules/python/webapp/mods/io.vertx~example-web-app~1.0/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "app.py" 3 | } -------------------------------------------------------------------------------- /src/modules/python/webapp/mods/io.vertx~example-web-app~1.0/server-keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/modules/python/webapp/mods/io.vertx~example-web-app~1.0/server-keystore.jks -------------------------------------------------------------------------------- /src/modules/python/webapp/mods/io.vertx~example-web-app~1.0/web/css/README: -------------------------------------------------------------------------------- 1 | css (less) stuff used by Twitter bootstrap 2 | 3 | Vert.x doesn't require anything here, it's just because we have chosen to build the front end app using Bootstrap but you could use whatever toolset you are more comfortable with. -------------------------------------------------------------------------------- /src/modules/python/webapp/mods/io.vertx~example-web-app~1.0/web/css/bootstrap.less: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap @VERSION 3 | * 4 | * Copyright 2011 Twitter, Inc 5 | * Licensed under the Apache License v2.0 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Designed and built with all the love in the world @twitter by @mdo and @fat. 9 | * Date: @DATE 10 | */ 11 | 12 | // CSS Reset 13 | @import "reset"; 14 | 15 | // Core variables and mixins 16 | @import "variables"; // Modify this for custom colors, font-sizes, etc 17 | @import "mixins"; 18 | 19 | // Grid system and page structure 20 | @import "scaffolding"; 21 | 22 | // Styled patterns and elements 23 | @import "type"; 24 | @import "forms"; 25 | @import "tables"; 26 | @import "patterns"; -------------------------------------------------------------------------------- /src/modules/python/webapp/mods/io.vertx~example-web-app~1.0/web/js3rdparty/README: -------------------------------------------------------------------------------- 1 | This is the 3rd party JS libs used by the front-end JS app. 2 | 3 | The only thing that vert.x actually needs here is SockJS. 4 | 5 | The rest is just because we decided to make the fron end app using knockout.js and Twitter bootstrap, but you could use whatever front-end JS toolkit you are most comfortable with. -------------------------------------------------------------------------------- /src/modules/ruby/webapp/README.md: -------------------------------------------------------------------------------- 1 | # "Real-time" Web Application Example 2 | 3 | This is a full end-end "real-time" web appplication which has a modern JavaScript client side MVVM application that communicates via the event bus with a persistor. 4 | 5 | It's the same application from the tutorial. 6 | 7 | You will need an instance of MongoDB server (with default settings) running on localhost. 8 | 9 | To run: 10 | 11 | vertx runmod io.vertx~example-web-app~1.0 12 | 13 | To see log output set the following in `conf/logging.properties` in the Vert.x install directory. 14 | 15 | org.vertx.level=FINE 16 | 17 | Then point your browser at https://localhost:8080 and start shopping! (Note it's https not http!) 18 | 19 | The example uses knockout.js at the client side to render the application. Vert.x is completely agnostic as to what 20 | client side toolkit you use - we have just chosen this for this example. 21 | 22 | The example uses the Vert.x event bus to extend into client side JavaScript so the browser can communicate with 23 | server side components. -------------------------------------------------------------------------------- /src/modules/ruby/webapp/mods/io.vertx~example-web-app~1.0/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "app.rb" 3 | } -------------------------------------------------------------------------------- /src/modules/ruby/webapp/mods/io.vertx~example-web-app~1.0/server-keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/modules/ruby/webapp/mods/io.vertx~example-web-app~1.0/server-keystore.jks -------------------------------------------------------------------------------- /src/modules/ruby/webapp/mods/io.vertx~example-web-app~1.0/web/css/README: -------------------------------------------------------------------------------- 1 | css (less) stuff used by Twitter bootstrap 2 | 3 | Vert.x doesn't require anything here, it's just because we have chosen to build the front end app using Bootstrap but you could use whatever toolset you are more comfortable with. -------------------------------------------------------------------------------- /src/modules/ruby/webapp/mods/io.vertx~example-web-app~1.0/web/css/bootstrap.less: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap @VERSION 3 | * 4 | * Copyright 2011 Twitter, Inc 5 | * Licensed under the Apache License v2.0 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Designed and built with all the love in the world @twitter by @mdo and @fat. 9 | * Date: @DATE 10 | */ 11 | 12 | // CSS Reset 13 | @import "reset"; 14 | 15 | // Core variables and mixins 16 | @import "variables"; // Modify this for custom colors, font-sizes, etc 17 | @import "mixins"; 18 | 19 | // Grid system and page structure 20 | @import "scaffolding"; 21 | 22 | // Styled patterns and elements 23 | @import "type"; 24 | @import "forms"; 25 | @import "tables"; 26 | @import "patterns"; -------------------------------------------------------------------------------- /src/modules/ruby/webapp/mods/io.vertx~example-web-app~1.0/web/js3rdparty/README: -------------------------------------------------------------------------------- 1 | This is the 3rd party JS libs used by the front-end JS app. 2 | 3 | The only thing that vert.x actually needs here is SockJS. 4 | 5 | The rest is just because we decided to make the fron end app using knockout.js and Twitter bootstrap, but you could use whatever front-end JS toolkit you are most comfortable with. -------------------------------------------------------------------------------- /src/modules/scala/webapp/README.md: -------------------------------------------------------------------------------- 1 | # "Real-time" Web Application Example 2 | 3 | This is a full end-end "real-time" web appplication which has a modern JavaScript client side MVVM application that communicates via the event bus with a persistor. 4 | 5 | It's the same application from the tutorial. 6 | 7 | You will need an instance of MongoDB server (with default settings) running on localhost. 8 | 9 | To run: 10 | 11 | vertx runmod io.vertx~example-web-app~1.0 12 | 13 | To see log output set the following in `conf/logging.properties` in the Vert.x install directory. 14 | 15 | org.vertx.level=FINE 16 | 17 | Then point your browser at https://localhost:8080 and start shopping! (Note it's https not http!) 18 | 19 | The example uses knockout.js at the client side to render the application. Vert.x is completely agnostic as to what 20 | client side toolkit you use - we have just chosen this for this example. 21 | 22 | The example uses the Vert.x event bus to extend into client side JavaScript so the browser can communicate with 23 | server side components. -------------------------------------------------------------------------------- /src/modules/scala/webapp/mods/io.vertx~example-web-app~1.0/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "app.scala" 3 | } -------------------------------------------------------------------------------- /src/modules/scala/webapp/mods/io.vertx~example-web-app~1.0/mods/io.vertx~mod-auth-mgr~2.0.0-CR1/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "org.vertx.mods.AuthManager", 3 | 4 | "description":"Simple auth-manager module for Vert.x", 5 | "licenses": ["The Apache Software License Version 2.0"], 6 | "author": "purplefox", 7 | "keywords": ["security", "auth", "authorisation", "authorization", "authentication", "login", "session"], 8 | "homepage": "https://github.com/vert-x/mod-auth-mgr" 9 | } -------------------------------------------------------------------------------- /src/modules/scala/webapp/mods/io.vertx~example-web-app~1.0/mods/io.vertx~mod-mongo-persistor~2.0.0-CR1/lib/mongo-java-driver-2.11.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/modules/scala/webapp/mods/io.vertx~example-web-app~1.0/mods/io.vertx~mod-mongo-persistor~2.0.0-CR1/lib/mongo-java-driver-2.11.1.jar -------------------------------------------------------------------------------- /src/modules/scala/webapp/mods/io.vertx~example-web-app~1.0/mods/io.vertx~mod-mongo-persistor~2.0.0-CR1/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "org.vertx.mods.MongoPersistor", 3 | "worker": true, 4 | "multi-threaded": true, 5 | 6 | "description":"MongoDB persistor module for Vert.x", 7 | "licenses": ["The Apache Software License Version 2.0"], 8 | "author": "purplefox", 9 | "keywords": ["mongo", "mongodb", "database", "databases", "persistence", "json", "nosql"], 10 | "homepage": "https://github.com/vert-x/mod-mongo-persistor" 11 | } -------------------------------------------------------------------------------- /src/modules/scala/webapp/mods/io.vertx~example-web-app~1.0/mods/io.vertx~mod-web-server~2.0.0-CR1/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "org.vertx.mods.web.WebServer", 3 | "preserve-cwd": true, 4 | 5 | "description":"Simple web server module for Vert.x", 6 | "licenses": ["The Apache Software License Version 2.0"], 7 | "author": "purplefox", 8 | "keywords": ["webserver", "web", "serve", "html", "http", "web-server", "sockjs", "bridge", "sockjs-bridge", "js"], 9 | "homepage": "https://github.com/vert-x/mod-web-server" 10 | } -------------------------------------------------------------------------------- /src/modules/scala/webapp/mods/io.vertx~example-web-app~1.0/mods/io.vertx~mod-web-server~2.0.0-CR2-SNAPSHOT/mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "org.vertx.mods.web.WebServer", 3 | "preserve-cwd": true, 4 | 5 | "description":"Simple web server module for Vert.x", 6 | "licenses": ["The Apache Software License Version 2.0"], 7 | "author": "purplefox", 8 | "keywords": ["webserver", "web", "serve", "html", "http", "web-server", "sockjs", "bridge", "sockjs-bridge", "js"], 9 | "homepage": "https://github.com/vert-x/mod-web-server" 10 | } -------------------------------------------------------------------------------- /src/modules/scala/webapp/mods/io.vertx~example-web-app~1.0/server-keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/modules/scala/webapp/mods/io.vertx~example-web-app~1.0/server-keystore.jks -------------------------------------------------------------------------------- /src/modules/scala/webapp/mods/io.vertx~example-web-app~1.0/web/css/README: -------------------------------------------------------------------------------- 1 | css (less) stuff used by Twitter bootstrap 2 | 3 | Vert.x doesn't require anything here, it's just because we have chosen to build the front end app using Bootstrap but you could use whatever toolset you are more comfortable with. -------------------------------------------------------------------------------- /src/modules/scala/webapp/mods/io.vertx~example-web-app~1.0/web/css/bootstrap.less: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap @VERSION 3 | * 4 | * Copyright 2011 Twitter, Inc 5 | * Licensed under the Apache License v2.0 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Designed and built with all the love in the world @twitter by @mdo and @fat. 9 | * Date: @DATE 10 | */ 11 | 12 | // CSS Reset 13 | @import "reset"; 14 | 15 | // Core variables and mixins 16 | @import "variables"; // Modify this for custom colors, font-sizes, etc 17 | @import "mixins"; 18 | 19 | // Grid system and page structure 20 | @import "scaffolding"; 21 | 22 | // Styled patterns and elements 23 | @import "type"; 24 | @import "forms"; 25 | @import "tables"; 26 | @import "patterns"; -------------------------------------------------------------------------------- /src/modules/scala/webapp/mods/io.vertx~example-web-app~1.0/web/js3rdparty/README: -------------------------------------------------------------------------------- 1 | This is the 3rd party JS libs used by the front-end JS app. 2 | 3 | The only thing that vert.x actually needs here is SockJS. 4 | 5 | The rest is just because we decided to make the fron end app using knockout.js and Twitter bootstrap, but you could use whatever front-end JS toolkit you are most comfortable with. -------------------------------------------------------------------------------- /src/raw/README.md: -------------------------------------------------------------------------------- 1 | # Raw Verticle Examples 2 | 3 | Subdirectories of this directory contain examples of using Vert.x in the form of *raw verticles*. 4 | 5 | Raw verticles are basic verticles which are run directly at the command line using `vertx run`. 6 | 7 | This is really useful for prototyping and demonstrating the Vert.x API, but for real Vert.x applications it's always 8 | recommended to package your application as a module (or a set of modules). 9 | 10 | For more information on this please consult the main manual and the modules manual on the Vert.x web-site. -------------------------------------------------------------------------------- /src/raw/ceylon/asyncstart/Starter.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import ceylon.promise { 6 | Promise 7 | } 8 | import io.vertx.ceylon.core { 9 | Vertx 10 | } 11 | 12 | shared class Starter() extends Verticle() { 13 | 14 | shared actual Promise asyncStart(Vertx vertx, Container container) { 15 | return container.deployVerticle("foo.js"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/raw/ceylon/echo/EchoClient.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.net { 9 | NetSocket 10 | } 11 | import org.vertx.java.core.buffer { 12 | Buffer 13 | } 14 | shared class EchoClient() extends Verticle() { 15 | 16 | shared actual void start(Vertx vertx, Container container) { 17 | vertx.createNetClient().connect(1234, "localhost").onComplete( 18 | void(NetSocket sock) { 19 | sock.readStream.dataHandler(void(Buffer buffer) { 20 | print("Net client receiving: ``buffer``"); 21 | }); 22 | for (i in 0..10) { 23 | value str = "hello``i``\n"; 24 | print("Net client sending: ``str``"); 25 | sock.write(Buffer(str)); 26 | } 27 | }, 28 | void(Throwable t) { 29 | t.printStackTrace(); 30 | } 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/raw/ceylon/echo/EchoServer.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.net { 9 | NetSocket 10 | } 11 | import io.vertx.ceylon.core.stream { 12 | Pump 13 | } 14 | 15 | shared class EchoServer() extends Verticle() { 16 | 17 | shared actual void start(Vertx vertx, Container container) { 18 | vertx.createNetServer().connectHandler(void(NetSocket sock) { 19 | Pump(sock.readStream, sock.writeStream).start(); 20 | }).listen(1234); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/raw/ceylon/eventbus_pointtopoint/Receiver.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.eventbus { 9 | Message 10 | } 11 | shared class Receiver() extends Verticle() { 12 | 13 | shared actual void start(Vertx vertx, Container container) { 14 | vertx.eventBus.registerHandler { 15 | address = "ping-address"; 16 | void onMessage(Message msg) { 17 | print("Received message: ``msg.body``"); 18 | msg.reply("pong!"); 19 | } 20 | }; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/raw/ceylon/eventbus_pointtopoint/Sender.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.eventbus { 9 | Message 10 | } 11 | shared class Sender() extends Verticle() { 12 | 13 | shared actual void start(Vertx vertx, Container container) { 14 | 15 | vertx.setPeriodic { 16 | delay = 1000; 17 | void handle(Integer timerId) { 18 | vertx.eventBus.send("ping-address", "ping!").onComplete((Message msg) => print("Received reply: ``msg.body``")); 19 | } 20 | }; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/raw/ceylon/eventbus_pubsub/Receiver.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.eventbus { 9 | Message 10 | } 11 | shared class Receiver() extends Verticle() { 12 | 13 | shared actual void start(Vertx vertx, Container container) { 14 | vertx.eventBus.registerHandler { 15 | address = "news-feed"; 16 | void onMessage(Message msg) { 17 | print("Received news: ``msg.body``"); 18 | } 19 | }; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/raw/ceylon/eventbus_pubsub/Sender.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | shared class Sender() extends Verticle() { 9 | 10 | shared actual void start(Vertx vertx, Container container) { 11 | 12 | vertx.setPeriodic { 13 | delay = 1000; 14 | void handle(Integer timerId) { 15 | vertx.eventBus.publish("news-feed", "more news!"); 16 | } 17 | }; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/raw/ceylon/fanout/FanoutServer.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.net { 9 | NetSocket 10 | } 11 | import org.vertx.java.core.buffer { 12 | Buffer 13 | } 14 | 15 | shared class FanoutServer() extends Verticle() { 16 | 17 | shared actual void start(Vertx vertx, Container container) { 18 | value connections = vertx.sharedData.getSet("conns"); 19 | vertx.createNetServer().connectHandler(void(NetSocket sock) { 20 | connections.add(sock.writeHandlerID); 21 | sock.readStream.dataHandler(void(Buffer buffer) { 22 | for (actorID in connections) { 23 | vertx.eventBus.publish(actorID, buffer); 24 | } 25 | }); 26 | sock.closeHandler().onComplete((Anything anything) => connections.remove(sock.writeHandlerID)); 27 | }).listen(1234); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/raw/ceylon/http/ClientExample.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.http { 9 | HttpClientResponse, 10 | textBody 11 | } 12 | shared class ClientExample() extends Verticle() { 13 | 14 | shared actual void start(Vertx vertx, Container container) { 15 | vertx.createHttpClient { 16 | port = 8080; 17 | host = "localhost"; 18 | }.get("/").end().response.compose((HttpClientResponse resp) => resp.parseBody(textBody)).onComplete(print); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/raw/ceylon/http/ServerExample.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.http { 9 | HttpServerRequest 10 | } 11 | shared class ServerExample() extends Verticle() { 12 | 13 | shared actual void start(Vertx vertx, Container container) { 14 | vertx.createHttpServer().requestHandler { 15 | void onRequest(HttpServerRequest req) { 16 | print("Got request ``req.uri``"); 17 | print("Headers are: "); 18 | for (header in req.headers) { 19 | print("``header.key``:``header.item``"); 20 | } 21 | req.response.headers { 22 | "Content-Type"->"text/html; charset=UTF-8" 23 | }; 24 | req.response.end("

Hello from vert.x!

"); 25 | } 26 | }.listen(8080); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/raw/ceylon/httphelloworld/HelloWorldServer.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.http { 9 | HttpServerRequest 10 | } 11 | shared class HelloWorldServer() extends Verticle() { 12 | 13 | shared actual void start(Vertx vertx, Container container) { 14 | vertx.createHttpServer().requestHandler(void(HttpServerRequest req) { 15 | req.response.headers { "Content-Type"->"text/plain" }; 16 | req.response.end("Hello World"); 17 | }).listen(8080); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/raw/ceylon/https/ClientExample.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.http { 9 | HttpClientResponse 10 | } 11 | 12 | shared class ClientExample() extends Verticle() { 13 | 14 | shared actual void start(Vertx vertx, Container container) { 15 | value client = vertx.createHttpClient(); 16 | client.ssl = true; 17 | client.trustAll = true; 18 | client.port = 4443; 19 | client.host = "localhost"; 20 | value resp = client.get("/").end().response; 21 | resp.onComplete((HttpClientResponse resp) => 22 | resp.stream.dataHandler(print) 23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/raw/ceylon/https/ServerExample.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.http { 9 | HttpServerRequest 10 | } 11 | shared class ServerExample() extends Verticle() { 12 | 13 | shared actual void start(Vertx vertx, Container container) { 14 | value server = vertx.createHttpServer().requestHandler(void(HttpServerRequest req) { 15 | print("Got request: ``req.uri``"); 16 | print("Headers are: "); 17 | for (header in req.headers) { 18 | print("``header.key``:``header.item``"); 19 | } 20 | req.response.headers { "Content-Type"->"text/html; charset=UTF-8" }; 21 | req.response.chunked = true; 22 | req.response.write(["

Hello from vert.x!

", "UTF-8"]).end(); 23 | }); 24 | server.ssl = true; 25 | server.keyStorePath = "server-keystore.jks"; 26 | server.keyStorePassword = "wibble"; 27 | server.listen(4443); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/raw/ceylon/proxyserver/Client.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.http { 9 | HttpClientResponse 10 | } 11 | import org.vertx.java.core.buffer { 12 | Buffer 13 | } 14 | shared class Client() extends Verticle() { 15 | 16 | shared actual void start(Vertx vertx, Container container) { 17 | 18 | value req = vertx.createHttpClient { 19 | port = 8080; 20 | host = "localhost"; 21 | }.put("/some-url"); 22 | req.response.onComplete(void(HttpClientResponse resp) { 23 | resp.stream.dataHandler(void(Buffer buffer) { 24 | print("Got response data:``buffer``"); 25 | }); 26 | }); 27 | //Write a few chunks 28 | req.chunked = true; 29 | for (i in 0..10) { 30 | req.write("client-data-chunk-``i``"); 31 | } 32 | req.end(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/raw/ceylon/proxyserver/Server.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.http { 9 | HttpServerRequest 10 | } 11 | import org.vertx.java.core.buffer { 12 | Buffer 13 | } 14 | shared class Server() extends Verticle() { 15 | 16 | shared actual void start(Vertx vertx, Container container) { 17 | 18 | vertx.createHttpServer().requestHandler(void(HttpServerRequest req) { 19 | print("Got request: ``req.uri``"); 20 | print("Headers are: "); 21 | for (header in req.headers) { 22 | print("``header.key``: ``header.item``"); 23 | } 24 | req.stream.dataHandler(void(Buffer buffer) { 25 | print("Got data: ``buffer``"); 26 | }); 27 | req.stream.endHandler(void() { 28 | req.response.chunked = true; 29 | for (i in 0..10) { 30 | req.response.write("server-data-chunk-``i``"); 31 | } 32 | req.response.end(); 33 | }); 34 | }).listen(8282); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/raw/ceylon/sendfile/SendFileExample.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.http { 9 | HttpServerRequest 10 | } 11 | shared class SendFileExample() extends Verticle() { 12 | 13 | String webroot = "sendfile/"; 14 | 15 | shared actual void start(Vertx vertx, Container container) { 16 | vertx.createHttpServer().requestHandler(void(HttpServerRequest req) { 17 | if (req.uri == "/") { 18 | req.response.sendFile("``webroot``index.html"); 19 | } else { 20 | //Clearly in a real server you would check the path for better security!! 21 | req.response.sendFile(webroot + req.path); 22 | } 23 | }).listen(8080); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/raw/ceylon/sendfile/index.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | vert.x static web server 20 | 21 | 22 |

This is the vert.x static web server. Click on some links below

23 | 24 |
25 |
26 | Page 1 27 | Page 2 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/raw/ceylon/sendfile/page1.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

Welcome to page1!

23 | 24 | -------------------------------------------------------------------------------- /src/raw/ceylon/sendfile/page2.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

Welcome to page2!

23 | 24 | -------------------------------------------------------------------------------- /src/raw/ceylon/server-keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/raw/ceylon/server-keystore.jks -------------------------------------------------------------------------------- /src/raw/ceylon/simpleform/SimpleFormServer.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.http { 9 | HttpServerRequest 10 | } 11 | shared class SimpleFormServer() extends Verticle() { 12 | 13 | shared actual void start(Vertx vertx, Container container) { 14 | 15 | vertx.createHttpServer().requestHandler(void(HttpServerRequest req) { 16 | 17 | if (req.uri == "/") { 18 | req.response.sendFile("simpleform/index.html"); 19 | } else if (req.uri.startsWith("/form")) { 20 | req.response.chunked = true; 21 | req.expectMultiPart(true); 22 | req.formAttributes.onComplete(void(Map form) { 23 | for (entry in form) { 24 | req.response.write("Got attr ``entry.key`` : ``entry.item``\n"); 25 | } 26 | req.response.end(); 27 | }, (Throwable t) => t.printStackTrace()); 28 | } else { 29 | req.response.status(404); 30 | req.response.end(); 31 | } 32 | }).listen(8080); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/raw/ceylon/simpleform/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | foo:
11 | bar:
12 | quux:
13 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/raw/ceylon/simpleformupload/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | choose a file to upload:
11 | 12 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/raw/ceylon/sockjs/SockJSExample.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.http { 9 | HttpServerRequest 10 | } 11 | import io.vertx.ceylon.core.sockjs { 12 | SockJSSocket 13 | } 14 | import ceylon.json { 15 | Object 16 | } 17 | 18 | shared class SockJSExample() extends Verticle() { 19 | 20 | shared actual void start(Vertx vertx, Container container) { 21 | 22 | value server = vertx.createHttpServer(); 23 | 24 | server.requestHandler(void(HttpServerRequest req) { 25 | if (req.path == "/") { 26 | req.response.sendFile("sockjs/index.html"); // Serve the html 27 | } 28 | }); 29 | 30 | value sockServer = vertx.createSockJSServer(server); 31 | 32 | sockServer.installApp(Object { "prefix"->"/testapp" }, void(SockJSSocket sock) { 33 | sock.readStream.dataHandler(sock.writeStream.write); // Echo it back 34 | }); 35 | 36 | server.listen(8080); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/raw/ceylon/ssl/SSLClient.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.net { 9 | NetSocket 10 | } 11 | import org.vertx.java.core.buffer { 12 | Buffer 13 | } 14 | 15 | shared class SSLClient() extends Verticle() { 16 | 17 | shared actual void start(Vertx vertx, Container container) { 18 | value client = vertx.createNetClient(); 19 | client.ssl = true; 20 | client.trustAll = true; 21 | client.connect(1234).onComplete(void(NetSocket sock) { 22 | sock.readStream.dataHandler(void(Buffer buffer) { print("Net client receiving: ``buffer``"); }); 23 | for (i in 0..10) { 24 | value str = "hello``i``\n"; 25 | print("Net client sending: ``str``"); 26 | sock.write(Buffer(str)); 27 | } 28 | }); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/raw/ceylon/ssl/SSLServer.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.net { 9 | NetSocket 10 | } 11 | shared class SSLServer() extends Verticle() { 12 | 13 | shared actual void start(Vertx vertx, Container container) { 14 | value server = vertx.createNetServer().connectHandler(void(NetSocket sock) { 15 | sock.readStream.dataHandler(sock.write); 16 | }); 17 | server.ssl = true; 18 | server.keyStorePath = "server-keystore.jks"; 19 | server.keyStorePassword = "wibble"; 20 | server.listen(1234); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/raw/ceylon/upload/upload.txt: -------------------------------------------------------------------------------- 1 | some-data 2 | -------------------------------------------------------------------------------- /src/raw/ceylon/websockets/WebsocketsClient.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.http { 9 | WebSocket 10 | } 11 | import org.vertx.java.core.buffer { 12 | Buffer 13 | } 14 | shared class WebsocketsClient() extends Verticle() { 15 | 16 | shared actual void start(Vertx vertx, Container container) { 17 | vertx.createHttpClient(8080, "localhost").connectWebsocket("/myapp").onComplete( 18 | void(WebSocket websocket) { 19 | websocket.readStream.dataHandler( 20 | (Buffer data) => print("Received data " + data.string)); 21 | //Send some data 22 | websocket.writeTextFrame("hello world"); 23 | } 24 | ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/raw/ceylon/websockets/WebsocketsExample.ceylon: -------------------------------------------------------------------------------- 1 | import io.vertx.ceylon.platform { 2 | Verticle, 3 | Container 4 | } 5 | import io.vertx.ceylon.core { 6 | Vertx 7 | } 8 | import io.vertx.ceylon.core.http { 9 | ServerWebSocket, 10 | HttpServerRequest 11 | } 12 | import org.vertx.java.core.buffer { 13 | Buffer 14 | } 15 | shared class WebsocketsExample() extends Verticle() { 16 | 17 | shared actual void start(Vertx vertx, Container container) { 18 | vertx.createHttpServer().websocketHandler(void(ServerWebSocket websocket) { 19 | if (websocket.path == "/myapp") { 20 | websocket.readStream.dataHandler( 21 | (Buffer buffer) => websocket.writeTextFrame(buffer.string)); // Echo it back 22 | } else { 23 | websocket.reject(); 24 | } 25 | }).requestHandler(void(HttpServerRequest req) { 26 | if (req.path == "/") { 27 | req.response.sendFile("websockets/ws.html"); // Serve the html 28 | } 29 | }).listen(8080); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/raw/clojure/async/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | pom.xml 6 | pom.xml.asc 7 | *.jar 8 | *.class 9 | .lein-deps-sum 10 | .lein-failures 11 | .lein-plugins 12 | .lein-repl-history 13 | -------------------------------------------------------------------------------- /src/raw/clojure/async/README.md: -------------------------------------------------------------------------------- 1 | # Clojure core.async in Vert.x 2 | 3 | Demonstrates using Clojure's core.async in Vert.x. See 4 | `src/async/core.clj`, and run with `lein run`. 5 | -------------------------------------------------------------------------------- /src/raw/clojure/async/project.clj: -------------------------------------------------------------------------------- 1 | (defproject async "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.6.0"] 7 | [io.vertx/clojure-api "1.0.2"] 8 | [org.clojure/core.async "0.1.301.0-deb34a-alpha"]] 9 | :main async.core) 10 | -------------------------------------------------------------------------------- /src/raw/clojure/echo/echo-server.clj: -------------------------------------------------------------------------------- 1 | ;; Copyright 2013 the original author or authors. 2 | ;; 3 | ;; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ;; you may not use this file except in compliance with the License. 5 | ;; You may obtain a copy of the License at 6 | ;; 7 | ;; http://www.apache.org/licenses/LICENSE-2.0 8 | ;; 9 | ;; Unless required by applicable law or agreed to in writing, software 10 | ;; distributed under the License is distributed on an "AS IS" BASIS, 11 | ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ;; See the License for the specific language governing permissions and 13 | ;; limitations under the License. 14 | 15 | (ns example.echo.echo-server 16 | (:require [vertx.net :as net] 17 | [vertx.stream :as stream])) 18 | 19 | (-> (net/server) 20 | (net/on-connect #(stream/pump % %)) 21 | (net/listen 1234 "localhost" 22 | (fn [ex _] 23 | (if ex 24 | (println ex) 25 | (println "Started Net echo server on localhost:1234"))))) 26 | -------------------------------------------------------------------------------- /src/raw/clojure/embedded/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /lib 3 | /classes 4 | /checkouts 5 | pom.xml 6 | pom.xml.asc 7 | *.jar 8 | *.class 9 | .lein-deps-sum 10 | .lein-failures 11 | .lein-plugins 12 | .lein-repl-history 13 | -------------------------------------------------------------------------------- /src/raw/clojure/embedded/README.md: -------------------------------------------------------------------------------- 1 | # Embedded Vert.x Example 2 | 3 | Demonstrates using an embedded Vertx instance from Clojure. See 4 | `src/embedded/core.clj`, and run with `lein run`. 5 | -------------------------------------------------------------------------------- /src/raw/clojure/embedded/project.clj: -------------------------------------------------------------------------------- 1 | (defproject embedded "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.6.0"] 7 | [io.vertx/clojure-api "1.0.2"]] 8 | :main embedded.core) 9 | -------------------------------------------------------------------------------- /src/raw/clojure/embedded/src/embedded/core.clj: -------------------------------------------------------------------------------- 1 | (ns embedded.core 2 | (:require [vertx.embed :as vertx] 3 | [vertx.eventbus :as eb]) 4 | (:import java.util.concurrent.CountDownLatch)) 5 | 6 | (defn -main 7 | [& args] 8 | (vertx/set-vertx! (vertx/vertx)) 9 | (let [latch (CountDownLatch. 1)] 10 | (eb/on-message "embed.example" 11 | (fn [m] 12 | (println "RCVD:" m) 13 | (.countDown latch))) 14 | (eb/send "embed.example" "This works!") 15 | (.await latch))) 16 | -------------------------------------------------------------------------------- /src/raw/clojure/eventbus_pointtopoint/receiver.clj: -------------------------------------------------------------------------------- 1 | ;; Copyright 2013 the original author or authors. 2 | ;; 3 | ;; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ;; you may not use this file except in compliance with the License. 5 | ;; You may obtain a copy of the License at 6 | ;; 7 | ;; http://www.apache.org/licenses/LICENSE-2.0 8 | ;; 9 | ;; Unless required by applicable law or agreed to in writing, software 10 | ;; distributed under the License is distributed on an "AS IS" BASIS, 11 | ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ;; See the License for the specific language governing permissions and 13 | ;; limitations under the License. 14 | 15 | (ns example.receiver 16 | (:require [vertx.eventbus :as eb])) 17 | 18 | (def address "example.address") 19 | 20 | (eb/on-message 21 | address 22 | (fn [msg] 23 | (println "Received message" msg) 24 | (eb/reply msg (str "pong:" msg)))) 25 | -------------------------------------------------------------------------------- /src/raw/clojure/eventbus_pointtopoint/sender.clj: -------------------------------------------------------------------------------- 1 | ;; Copyright 2013 the original author or authors. 2 | ;; 3 | ;; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ;; you may not use this file except in compliance with the License. 5 | ;; You may obtain a copy of the License at 6 | ;; 7 | ;; http://www.apache.org/licenses/LICENSE-2.0 8 | ;; 9 | ;; Unless required by applicable law or agreed to in writing, software 10 | ;; distributed under the License is distributed on an "AS IS" BASIS, 11 | ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ;; See the License for the specific language governing permissions and 13 | ;; limitations under the License. 14 | 15 | (ns example.sender 16 | (:require [vertx.core :as vertx] 17 | [vertx.eventbus :as eb])) 18 | 19 | (def address "example.address") 20 | (def msg-count (atom 0)) 21 | 22 | (vertx/periodic 23 | 1000 24 | (let [msg (str "some-message-" (swap! msg-count inc))] 25 | (eb/send address msg 26 | (fn [reply] 27 | (println "received:" reply))) 28 | (println "sent message" msg))) 29 | -------------------------------------------------------------------------------- /src/raw/clojure/eventbus_pubsub/receiver.clj: -------------------------------------------------------------------------------- 1 | ;; Copyright 2013 the original author or authors. 2 | ;; 3 | ;; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ;; you may not use this file except in compliance with the License. 5 | ;; You may obtain a copy of the License at 6 | ;; 7 | ;; http://www.apache.org/licenses/LICENSE-2.0 8 | ;; 9 | ;; Unless required by applicable law or agreed to in writing, software 10 | ;; distributed under the License is distributed on an "AS IS" BASIS, 11 | ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ;; See the License for the specific language governing permissions and 13 | ;; limitations under the License. 14 | 15 | (ns example.eventbus-pubsub.receiver 16 | (:require [vertx.core :as vertx] 17 | [vertx.eventbus :as eb])) 18 | 19 | (eb/on-message "news-feed" 20 | #(println "received:" %)) 21 | -------------------------------------------------------------------------------- /src/raw/clojure/eventbus_pubsub/sender.clj: -------------------------------------------------------------------------------- 1 | ;; Copyright 2013 the original author or authors. 2 | ;; 3 | ;; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ;; you may not use this file except in compliance with the License. 5 | ;; You may obtain a copy of the License at 6 | ;; 7 | ;; http://www.apache.org/licenses/LICENSE-2.0 8 | ;; 9 | ;; Unless required by applicable law or agreed to in writing, software 10 | ;; distributed under the License is distributed on an "AS IS" BASIS, 11 | ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ;; See the License for the specific language governing permissions and 13 | ;; limitations under the License. 14 | 15 | (ns example.eventbus-pubsub.sender 16 | (:require [vertx.core :as vertx] 17 | [vertx.eventbus :as eb])) 18 | 19 | (vertx/periodic 1000 20 | (eb/publish "news-feed" "some news") 21 | (println "published message some news")) 22 | -------------------------------------------------------------------------------- /src/raw/clojure/eventbusbridge-cljs/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-port 10 | -------------------------------------------------------------------------------- /src/raw/clojure/eventbusbridge-cljs/README.md: -------------------------------------------------------------------------------- 1 | # eventbusbridge-cljs 2 | 3 | An example of using the ClojureScript eventbus. 4 | 5 | ## Usage 6 | 7 | First, compile the ClojureScript client: 8 | 9 | lein cljsbuild once 10 | 11 | Then run the server: 12 | 13 | vertx run bridge-server.clj 14 | 15 | And connect to http://localhost:8080/ 16 | 17 | See the implementation for the 18 | [client](src/eventbusbridge_cljs/client.cljs) and the 19 | [`vertx.client.eventbus`](https://github.com/vert-x/mod-lang-clojure/blob/master/api/src/main/clojure/vertx/client/eventbus.cljs). 20 | -------------------------------------------------------------------------------- /src/raw/clojure/eventbusbridge-cljs/project.clj: -------------------------------------------------------------------------------- 1 | (defproject eventbusbridge-cljs "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.6.0"] 7 | [org.clojure/clojurescript "0.0-1885"] 8 | [io.vertx/clojure-api "1.0.2"] 9 | [enfocus "2.0.0-beta1"]] 10 | :plugins [[lein-cljsbuild "0.3.2"]] 11 | :cljsbuild {:builds [{:source-paths ["src"] 12 | :compiler {:output-to "target/client.js"}}]}) 13 | -------------------------------------------------------------------------------- /src/raw/clojure/http/client.clj: -------------------------------------------------------------------------------- 1 | ;; Copyright 2013 the original author or authors. 2 | ;; 3 | ;; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ;; you may not use this file except in compliance with the License. 5 | ;; You may obtain a copy of the License at 6 | ;; 7 | ;; http://www.apache.org/licenses/LICENSE-2.0 8 | ;; 9 | ;; Unless required by applicable law or agreed to in writing, software 10 | ;; distributed under the License is distributed on an "AS IS" BASIS, 11 | ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ;; See the License for the specific language governing permissions and 13 | ;; limitations under the License. 14 | 15 | (ns example.http.client 16 | (:require [vertx.http :as http])) 17 | 18 | (-> (http/client {:port 8080 :host "localhost"}) 19 | (http/get-now "/" #(http/on-body % println))) 20 | -------------------------------------------------------------------------------- /src/raw/clojure/https/client.clj: -------------------------------------------------------------------------------- 1 | ;; Copyright 2013 the original author or authors. 2 | ;; 3 | ;; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ;; you may not use this file except in compliance with the License. 5 | ;; You may obtain a copy of the License at 6 | ;; 7 | ;; http://www.apache.org/licenses/LICENSE-2.0 8 | ;; 9 | ;; Unless required by applicable law or agreed to in writing, software 10 | ;; distributed under the License is distributed on an "AS IS" BASIS, 11 | ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ;; See the License for the specific language governing permissions and 13 | ;; limitations under the License. 14 | 15 | (ns example.https.client 16 | (:require [vertx.http :as http])) 17 | 18 | (-> (http/client {:SSL true :trust-all true :port 4443 :host "localhost"}) 19 | (http/get-now "/" #(http/on-body % println))) 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/raw/clojure/repl/server.clj: -------------------------------------------------------------------------------- 1 | (ns examples.repl.server 2 | (:require [vertx.repl :as repl] 3 | [vertx.core :as core] 4 | [vertx.http :as http])) 5 | 6 | (def repl-server-id (atom nil)) 7 | 8 | (defn- req-handler [req] 9 | (println "Got request:" (.uri req)) 10 | (println "Headers are:" (pr-str (http/headers req))) 11 | (-> (http/server-response req) 12 | (http/add-header "Content-Type" "text/html; charset=UTF-8") 13 | (http/end "

Hello from vert.x!

"))) 14 | 15 | (defn start-http-server [] 16 | (-> (http/server) 17 | (http/on-request req-handler) 18 | (http/listen 8080 "localhost"))) 19 | 20 | (defn stop-repl-server [] (repl/stop @repl-server-id)) 21 | 22 | (reset! repl-server-id (repl/start)) 23 | 24 | ;;after startup repl server, you could get connection with nrepl based on terminal 25 | ;;then could invoke start-http-server to startup a httpserver 26 | ;;or shutdown the server with fn stop-repl-server 27 | -------------------------------------------------------------------------------- /src/raw/clojure/route_match/index.html: -------------------------------------------------------------------------------- 1 | 2 | Route Matcher example 3 | 4 | 5 | Click on these links:

6 | 7 | Joe
8 | Bob
9 | Jeff
10 | Jane
11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/raw/clojure/sendfile/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | vert.x static web server 4 | 5 | 6 |

This is the vert.x static web server. Click on some links below

7 | 8 |
9 |
10 | Page 1 11 | Page 2 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/raw/clojure/sendfile/page1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Welcome to page1!

7 | 8 | 9 | -------------------------------------------------------------------------------- /src/raw/clojure/sendfile/page2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Welcome to page2!

7 | 8 | 9 | -------------------------------------------------------------------------------- /src/raw/clojure/server-keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/raw/clojure/server-keystore.jks -------------------------------------------------------------------------------- /src/raw/clojure/udp/udp-group-sender.clj: -------------------------------------------------------------------------------- 1 | ;; Copyright 2013 the original author or authors. 2 | ;; 3 | ;; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ;; you may not use this file except in compliance with the License. 5 | ;; You may obtain a copy of the License at 6 | ;; 7 | ;; http://www.apache.org/licenses/LICENSE-2.0 8 | ;; 9 | ;; Unless required by applicable law or agreed to in writing, software 10 | ;; distributed under the License is distributed on an "AS IS" BASIS, 11 | ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ;; See the License for the specific language governing permissions and 13 | ;; limitations under the License. 14 | 15 | (ns example.udp.udp-group-sender 16 | (:require [vertx.core :as vertx] 17 | [vertx.datagram :as udp])) 18 | 19 | (let [peer (udp/socket)] 20 | (doseq [i (range 10)] 21 | (let [data (format "hello %s" i)] 22 | (udp/send peer data "230.0.0.1" 1234 23 | (fn [err _] 24 | (if (nil? err) 25 | (println "sent group packet:" data) 26 | (println (:message err)))))))) 27 | -------------------------------------------------------------------------------- /src/raw/clojure/udp/udp-listener.clj: -------------------------------------------------------------------------------- 1 | ;; Copyright 2013 the original author or authors. 2 | ;; 3 | ;; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ;; you may not use this file except in compliance with the License. 5 | ;; You may obtain a copy of the License at 6 | ;; 7 | ;; http://www.apache.org/licenses/LICENSE-2.0 8 | ;; 9 | ;; Unless required by applicable law or agreed to in writing, software 10 | ;; distributed under the License is distributed on an "AS IS" BASIS, 11 | ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ;; See the License for the specific language governing permissions and 13 | ;; limitations under the License. 14 | 15 | (ns example.udp.udp-listener 16 | (:require [vertx.core :as vertx] 17 | [vertx.datagram :as udp])) 18 | 19 | (-> (udp/socket) 20 | (udp/on-data 21 | (fn [packet] 22 | (println (format "Received packet '%s' from host: %s port: %s" 23 | (:data packet) 24 | (-> packet :sender :host) 25 | (-> packet :sender :port))))) 26 | (udp/listen 1234)) 27 | -------------------------------------------------------------------------------- /src/raw/clojure/udp/udp-sender.clj: -------------------------------------------------------------------------------- 1 | ;; Copyright 2013 the original author or authors. 2 | ;; 3 | ;; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ;; you may not use this file except in compliance with the License. 5 | ;; You may obtain a copy of the License at 6 | ;; 7 | ;; http://www.apache.org/licenses/LICENSE-2.0 8 | ;; 9 | ;; Unless required by applicable law or agreed to in writing, software 10 | ;; distributed under the License is distributed on an "AS IS" BASIS, 11 | ;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ;; See the License for the specific language governing permissions and 13 | ;; limitations under the License. 14 | 15 | (ns example.udp.udp-sender 16 | (:require [vertx.core :as vertx] 17 | [vertx.datagram :as udp])) 18 | 19 | (let [peer (udp/socket)] 20 | (doseq [i (range 10)] 21 | (let [data (format "hello %s" i)] 22 | (udp/send peer data "127.0.0.1" 1234 23 | (fn [err _] 24 | (if (nil? err) 25 | (println "sent packet:" data) 26 | (println (:message err)))))))) 27 | -------------------------------------------------------------------------------- /src/raw/clojure/upload/upload.txt: -------------------------------------------------------------------------------- 1 | some-data 2 | -------------------------------------------------------------------------------- /src/raw/coffeescript/commonjs/handler.coffee: -------------------------------------------------------------------------------- 1 | class Handler 2 | constructor: (req) -> 3 | req.response.end "

Hello from vert.x using Coffeescript with CommonJS!

" 4 | 5 | module.exports = Handler -------------------------------------------------------------------------------- /src/raw/coffeescript/commonjs/main.coffee: -------------------------------------------------------------------------------- 1 | Server = require("./server.coffee") 2 | handler = require("./handler.coffee") 3 | 4 | server = new Server(8080, "localhost") 5 | 6 | server.use handler 7 | server.start() -------------------------------------------------------------------------------- /src/raw/coffeescript/commonjs/server.coffee: -------------------------------------------------------------------------------- 1 | vertx = require("vertx") 2 | 3 | class Server 4 | constructor: (@port, @host) -> 5 | @server = vertx.createHttpServer() 6 | 7 | use: (handler) -> 8 | @server.requestHandler handler 9 | 10 | start: -> 11 | @server.listen @port, @host 12 | 13 | module.exports = Server -------------------------------------------------------------------------------- /src/raw/coffeescript/echo/echo_client.coffee: -------------------------------------------------------------------------------- 1 | vertx = require "vertx" 2 | console = require "vertx/console" 3 | 4 | client = vertx.createNetClient() 5 | client.connect 1234, (err, sock) -> 6 | 7 | sock.dataHandler (buffer) -> 8 | console.log "client receiving " + buffer.toString() 9 | 10 | i = 0 11 | 12 | while i < 10 13 | str = "hello" + i + "\n" 14 | console.log "Net client sending: " + str 15 | sock.write new vertx.Buffer(str) 16 | i++ -------------------------------------------------------------------------------- /src/raw/coffeescript/echo/echo_server.coffee: -------------------------------------------------------------------------------- 1 | vertx = require "vertx" 2 | 3 | vertx.createNetServer().connectHandler((sock) -> 4 | new vertx.Pump(sock, sock).start() 5 | ).listen 1234 -------------------------------------------------------------------------------- /src/raw/coffeescript/http/http_server.coffee: -------------------------------------------------------------------------------- 1 | vertx = require "vertx" 2 | 3 | vertx.createHttpServer().requestHandler((req) -> 4 | req.response.end('

Hello from vert.x!

') 5 | ).listen 8080, 'localhost' -------------------------------------------------------------------------------- /src/raw/coffeescript/load/brew.coffee: -------------------------------------------------------------------------------- 1 | console = require "vertx/console" 2 | 3 | load "load/flat_white.coffee" 4 | 5 | soy() 6 | 7 | console.log "All brewed!" 8 | 9 | -------------------------------------------------------------------------------- /src/raw/coffeescript/load/flat_white.coffee: -------------------------------------------------------------------------------- 1 | console = require "vertx/console" 2 | 3 | console.log "Flat white with one sugar." 4 | 5 | this.soy = -> 6 | console.log "Make that a soy" 7 | 8 | -------------------------------------------------------------------------------- /src/raw/groovy/echo/EchoServer.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import static org.vertx.groovy.core.streams.Pump.createPump 18 | 19 | vertx.createNetServer().connectHandler { socket -> 20 | createPump(socket, socket).start() 21 | }.listen(1234) 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/raw/groovy/eventbus_pointtopoint/Receiver.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | def eb = vertx.eventBus 18 | 19 | eb.registerHandler("ping-address", { message -> 20 | println "Received message: ${message.body()}" 21 | // Now send back reply 22 | message.reply("pong!") 23 | }) 24 | -------------------------------------------------------------------------------- /src/raw/groovy/eventbus_pointtopoint/Sender.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | def eb = vertx.eventBus 18 | 19 | // Send a message every second 20 | 21 | vertx.setPeriodic(1000) { 22 | eb.send("ping-address", "ping!", { reply -> 23 | println "Received reply ${reply.body()}" 24 | }) 25 | } 26 | -------------------------------------------------------------------------------- /src/raw/groovy/eventbus_pubsub/Receiver.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | def eb = vertx.eventBus 18 | 19 | eb.registerHandler("news-feed", { message -> 20 | println "Received news: ${message.body()}" 21 | }) 22 | -------------------------------------------------------------------------------- /src/raw/groovy/eventbus_pubsub/Sender.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | def eb = vertx.eventBus 18 | 19 | // Send a message every second 20 | 21 | vertx.setPeriodic(1000) { 22 | eb.publish("news-feed", "Some news!") 23 | } 24 | -------------------------------------------------------------------------------- /src/raw/groovy/eventbusbridge/BridgeServer.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | def server = vertx.createHttpServer() 18 | 19 | // Serve the static resources 20 | server.requestHandler { req -> 21 | if (req.uri == '/') req.response.sendFile('eventbusbridge/index.html') 22 | if (req.uri == '/vertxbus.js') req.response.sendFile('eventbusbridge/vertxbus.js') 23 | } 24 | 25 | vertx.createSockJSServer(server).bridge(prefix: '/eventbus', [[:]], [[:]]) 26 | 27 | server.listen(8080) 28 | -------------------------------------------------------------------------------- /src/raw/groovy/fanout/FanoutServer.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | def conns = vertx.sharedData.getSet('conns') 18 | 19 | def eb = vertx.eventBus 20 | 21 | server = vertx.createNetServer().connectHandler { socket -> 22 | conns << socket.writeHandlerID 23 | socket.dataHandler { data -> 24 | for (id in conns) { eb.send(id, data) } 25 | } 26 | socket.closeHandler { conns.remove(socket.writeHandlerID) } 27 | }.listen(1234) 28 | -------------------------------------------------------------------------------- /src/raw/groovy/http/Client.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package http 18 | 19 | vertx.createHttpClient(port: 8080).getNow('/') { resp -> 20 | println "Got response ${resp.statusCode}" 21 | resp.bodyHandler { body -> println "Got data ${body}" } 22 | } 23 | -------------------------------------------------------------------------------- /src/raw/groovy/http/Server.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package http 17 | 18 | vertx.createHttpServer().requestHandler { req -> 19 | req.response.end "

Hello from vert.x!

" 20 | }.listen(8080, "localhost") 21 | -------------------------------------------------------------------------------- /src/raw/groovy/https/Client.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package https 17 | 18 | vertx.createHttpClient(port: 4443, SSL: true, trustAll: true).getNow('/') { resp -> 19 | println "Got response ${resp.statusCode}" 20 | resp.bodyHandler { body -> println "Got data ${body}" } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /src/raw/groovy/https/Server.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package https 17 | 18 | def server = 19 | vertx.createHttpServer(SSL: true, keyStorePath: 'server-keystore.jks', keyStorePassword: 'wibble') 20 | 21 | server.requestHandler { req -> 22 | req.response.end "

Hello from vert.x!

" 23 | }.listen(4443, "localhost") 24 | -------------------------------------------------------------------------------- /src/raw/groovy/proxy/Client.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package proxy 17 | 18 | def request = vertx.createHttpClient(port: 8080).put('/') { resp -> 19 | println "Got response ${resp.statusCode}" 20 | resp.bodyHandler { body -> println "Got data ${body}" } 21 | } 22 | 23 | request.chunked = true 24 | 25 | 10.times { request << "client-chunk-$it" } 26 | 27 | request.end() 28 | -------------------------------------------------------------------------------- /src/raw/groovy/route_match/index.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | Route Matcher example 19 | 20 | 21 | Click on these links:

22 | 23 | Joe
24 | Bob
25 | Jeff
26 | Jane
27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/raw/groovy/sendfile/SendFile.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | vertx.createHttpServer().requestHandler { req -> 18 | def filename = "sendfile/" + (req.uri == "/" ? "index.html" : "." + req.uri) 19 | req.response.sendFile filename 20 | }.listen(8080) 21 | 22 | -------------------------------------------------------------------------------- /src/raw/groovy/sendfile/index.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | vert.x static web server 20 | 21 | 22 |

This is the vert.x static web server. Click on some links below

23 | 24 |
25 |
26 | Page 1 27 | Page 2 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/raw/groovy/sendfile/page1.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

Welcome to page1!

23 | 24 | -------------------------------------------------------------------------------- /src/raw/groovy/sendfile/page2.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

Welcome to page2!

23 | 24 | -------------------------------------------------------------------------------- /src/raw/groovy/server-keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/raw/groovy/server-keystore.jks -------------------------------------------------------------------------------- /src/raw/groovy/simpleform/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | foo:
11 | bar:
12 | quux:
13 | name:
14 | 15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /src/raw/groovy/simpleformupload/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | choose a file to upload:
11 | 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /src/raw/groovy/sockjs/SockJSExample.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | def server = vertx.createHttpServer() 18 | 19 | // Serve the index page 20 | server.requestHandler { req -> 21 | if (req.uri == "/") req.response.sendFile 'sockjs/index.html' 22 | } 23 | 24 | // The handler for the SockJS app - we just echo data back 25 | vertx.createSockJSServer(server).installApp(prefix: '/testapp') { sock -> 26 | sock.dataHandler { buff -> 27 | sock << buff 28 | } 29 | } 30 | 31 | server.listen(8080) 32 | 33 | -------------------------------------------------------------------------------- /src/raw/groovy/ssl/Client.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ssl 18 | 19 | vertx.createNetClient(SSL: true, trustAll: true).connect(1234) { asyncResult -> 20 | if (asyncResult.succeeded) { 21 | sock = asyncResult.result 22 | sock.dataHandler { buff -> println "client receiving ${buff}" } 23 | 24 | // Now send some data 25 | 10.times { 26 | def str = "hello $it\n" 27 | println "Net client sending: $str" 28 | sock << str 29 | } 30 | } else { 31 | println "Failed to connect ${asyncResult.cause}" 32 | } 33 | } -------------------------------------------------------------------------------- /src/raw/groovy/ssl/Server.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ssl 18 | 19 | import static org.vertx.groovy.core.streams.Pump.createPump 20 | 21 | def server = vertx.createNetServer(SSL: true, keyStorePath: 'server-keystore.jks', keyStorePassword: 'wibble') 22 | 23 | server.connectHandler { sock -> 24 | createPump(sock, sock).start() 25 | }.listen(1234, "localhost") 26 | -------------------------------------------------------------------------------- /src/raw/groovy/upload/upload.txt: -------------------------------------------------------------------------------- 1 | some-data 2 | -------------------------------------------------------------------------------- /src/raw/groovy/websockets/WebSocketsClient.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package websockets 18 | 19 | def client = vertx.createHttpClient().setPort(8080) 20 | 21 | client.connectWebsocket('/some-uri') { websocket -> 22 | websocket.dataHandler { data -> 23 | println "Received data $data" 24 | client.close() 25 | } 26 | websocket << 'Hello world' 27 | } 28 | -------------------------------------------------------------------------------- /src/raw/groovy/websockets/WebSocketsServer.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package websockets 18 | 19 | vertx.createHttpServer().websocketHandler { ws -> 20 | ws.dataHandler { data -> ws.writeTextFrame(data.toString()) } 21 | }.requestHandler { req -> 22 | if (req.uri == "/") req.response.sendFile "websockets/ws.html" 23 | }.listen(8080) 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/raw/java/httpperf/foo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Some page 4 | 5 | 6 |

Foo!

7 | 8 | -------------------------------------------------------------------------------- /src/raw/java/httpperf/vertx-server.groovy: -------------------------------------------------------------------------------- 1 | package httpperf 2 | /* 3 | * Copyright 2011-2012 the original author or authors. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | vertx.createHttpServer().requestHandler { req -> 19 | req.response.end() 20 | //req.response.sendFile("httpperf/foo.html") 21 | // vertx.fileSystem.readFile("httpperf/foo.html") { ar -> 22 | // req.response.headers["content-length"] = ar.result.length 23 | // req.response.headers["content-type"] = "text/html" 24 | // req.response.end(ar.result) 25 | // } 26 | }.listen(8080) 27 | 28 | -------------------------------------------------------------------------------- /src/raw/java/httpperf/vertx-server.js: -------------------------------------------------------------------------------- 1 | var vertx = require('vertx') 2 | 3 | vertx.createHttpServer().requestHandler(function(req) { 4 | req.response.end(); 5 | //req.response.sendFile("httpperf/foo.html"); 6 | 7 | // vertx.fileSystem.readFile("httpperf/foo.html", function(err, file) { 8 | // req.response.headers["Content-Length"] = file.length() 9 | // req.response.headers["Content-Type"] = "text/html" 10 | // req.response.end(file) 11 | // }); 12 | }).listen(8080); 13 | 14 | -------------------------------------------------------------------------------- /src/raw/java/httpperf/vertx_server.rb: -------------------------------------------------------------------------------- 1 | require "vertx" 2 | include Vertx 3 | 4 | HttpServer.new.request_handler do |req| 5 | req.response.end 6 | # req.response.send_file("httpperf/foo.html") 7 | #FileSystem.read_file_as_buffer("httpperf/foo.html") { |err, file| 8 | # req.response.headers["Content-Length"] = file.length 9 | # req.response.headers["Content-Type"] = "text/html" 10 | # req.response.write_buffer(file) 11 | # req.response.end 12 | #} 13 | end.listen(8080) 14 | -------------------------------------------------------------------------------- /src/raw/java/resourceload/Quux.java: -------------------------------------------------------------------------------- 1 | package resourceload; 2 | 3 | /** 4 | * 5 | * This gets built into its own jar which is loaded in the example 6 | * 7 | * @author Tim Fox 8 | */ 9 | public class Quux { 10 | public int wibble() { 11 | return 23; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/raw/java/resourceload/bar.txt: -------------------------------------------------------------------------------- 1 | bar bar black sheep -------------------------------------------------------------------------------- /src/raw/java/resourceload/foo.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/raw/java/route_match/index.html: -------------------------------------------------------------------------------- 1 | 2 | Route Matcher example 3 | 4 | 5 | Click on these links:

6 | 7 | Joe
8 | Bob
9 | Jeff
10 | Jane
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/raw/java/sendfile/index.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | vert.x static web server 20 | 21 | 22 |

This is the vert.x static web server. Click on some links below

23 | 24 |
25 |
26 | Page 1 27 | Page 2 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/raw/java/sendfile/page1.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

Welcome to page1!

23 | 24 | -------------------------------------------------------------------------------- /src/raw/java/sendfile/page2.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

Welcome to page2!

23 | 24 | -------------------------------------------------------------------------------- /src/raw/java/server-keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/raw/java/server-keystore.jks -------------------------------------------------------------------------------- /src/raw/java/simpleform/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | foo:
11 | bar:
12 | quux:
13 | 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /src/raw/java/simpleformupload/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | choose a file to upload:
11 | 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /src/raw/java/upload/upload.txt: -------------------------------------------------------------------------------- 1 | some-data 2 | -------------------------------------------------------------------------------- /src/raw/java/wsperf/vertx-server.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | var vertx = require('vertx') 18 | var console = require('console') 19 | 20 | var connCount = 0 21 | vertx.createHttpServer().websocketHandler(function(ws) { 22 | console.log("Connection count: " + ++connCount); 23 | new vertx.Pump(ws, ws).start(); 24 | }).listen(8080); 25 | 26 | -------------------------------------------------------------------------------- /src/raw/javascript/commonjs/handler.js: -------------------------------------------------------------------------------- 1 | module.exports = function(req) { 2 | req.response.end("

Hello from vert.x using CommonJS!

"); 3 | }; -------------------------------------------------------------------------------- /src/raw/javascript/commonjs/main.js: -------------------------------------------------------------------------------- 1 | var Server, handler; 2 | 3 | Server = require('./server'); 4 | handler = require('./handler'); 5 | 6 | server = new Server(8080, 'localhost'); 7 | server.use(handler); 8 | server.start(); -------------------------------------------------------------------------------- /src/raw/javascript/commonjs/server.js: -------------------------------------------------------------------------------- 1 | vertx = require('vertx'); 2 | 3 | module.exports = function(port, host){ 4 | var server = vertx.createHttpServer(); 5 | 6 | this.use = function(handler){ 7 | server.requestHandler(handler); 8 | }; 9 | 10 | this.start = function() { 11 | server.listen(port, host); 12 | }; 13 | }; -------------------------------------------------------------------------------- /src/raw/javascript/config/conf.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tim", 3 | "age": 123123, 4 | "male": true, 5 | "pi": 3.14159, 6 | "normal": false, 7 | "null-value": null, 8 | "nested": { 9 | "blah": "wibble" 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /src/raw/javascript/config/configured.js: -------------------------------------------------------------------------------- 1 | var container = require('vertx/container') 2 | var console = require('vertx/console') 3 | 4 | console.log('Config is ' + JSON.stringify(container.config)); 5 | -------------------------------------------------------------------------------- /src/raw/javascript/conn_perf/conn_server.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | var vertx = require('vertx') 18 | var console = require('vertx/console') 19 | 20 | // We set the buffer sizes small so we don't run out of RAM - each connection 21 | // will have its own buffer 22 | 23 | var server = vertx.createNetServer().sendBufferSize(2048).receiveBufferSize(2048); 24 | 25 | var count = 0; 26 | 27 | server.connectHandler(function(sock) { 28 | new vertx.Pump(sock, sock).start(); 29 | console.log("Connection " + count++); 30 | }) 31 | 32 | server.listen(1234); 33 | -------------------------------------------------------------------------------- /src/raw/javascript/deploy/child.js: -------------------------------------------------------------------------------- 1 | var container = require('vertx/container') 2 | 3 | var log = container.logger; 4 | 5 | log.info("in child.js, config is " + container.config); 6 | 7 | log.info(JSON.stringify(container.config)); 8 | -------------------------------------------------------------------------------- /src/raw/javascript/deploy/deployer.js: -------------------------------------------------------------------------------- 1 | var container = require('vertx/container') 2 | 3 | var config = {name: 'tim', age: 823823}; 4 | 5 | var id = container.deployVerticle('deploy/child.js', config, 1); 6 | -------------------------------------------------------------------------------- /src/raw/javascript/deploy_many/child.js: -------------------------------------------------------------------------------- 1 | var console = require('vertx/console') 2 | 3 | console.log("in child") 4 | 5 | function vertxStop() { 6 | console.log("child stopped") 7 | } 8 | -------------------------------------------------------------------------------- /src/raw/javascript/deploy_many/mem.js: -------------------------------------------------------------------------------- 1 | var container = require('vertx/container'); 2 | var console = require('vertx/console'); 3 | 4 | function deploy_it(count) { 5 | container.deployVerticle('child.js', function(deploy_id) { 6 | console.log("deployed " + count); 7 | undeploy_it(deploy_id, count); 8 | }); 9 | } 10 | 11 | function undeploy_it(deploy_id, count) { 12 | container.undeployVerticle(deploy_id, function() { 13 | count++; 14 | if (count < 10) { 15 | deploy_it(count); 16 | } else { 17 | console.log("done!"); 18 | } 19 | }); 20 | } 21 | 22 | deploy_it(0) ; 23 | -------------------------------------------------------------------------------- /src/raw/javascript/eb_perf/handler.js: -------------------------------------------------------------------------------- 1 | var vertx = require('vertx') 2 | var console = require('vertx/console') 3 | 4 | var eb = vertx.eventBus; 5 | 6 | var address = 'example.address' 7 | var creditsAddress = 'example.credits' 8 | 9 | var batchSize = 10000; 10 | 11 | var received = 0 12 | var count = 0 13 | 14 | var start = null; 15 | 16 | // Start the handler first, then the sender 17 | 18 | var handler = function(message) { 19 | received++; 20 | if (received == batchSize) { 21 | eb.send(creditsAddress, null); 22 | received = 0; 23 | } 24 | count++; 25 | if (count % batchSize == 0) { 26 | console.log("Received " + count); 27 | if (start == null) { 28 | start = new Date(); 29 | } else { 30 | var now = new Date(); 31 | var elapsed = now.getTime() - start.getTime(); 32 | var rate = 1000 * (count + 0.0) / (elapsed); 33 | console.log("rate: " + rate + " msgs/sec"); 34 | } 35 | } 36 | } 37 | 38 | eb.registerHandler(address, handler); 39 | 40 | eb.send(creditsAddress, null); 41 | 42 | function vertxStop() { 43 | eb.unregisterHandler(address, handler); 44 | } 45 | 46 | console.log("Started"); 47 | 48 | -------------------------------------------------------------------------------- /src/raw/javascript/eb_perf/sender.js: -------------------------------------------------------------------------------- 1 | var vertx = require('vertx') 2 | var console = require('vertx/console') 3 | 4 | var eb = vertx.eventBus; 5 | 6 | var address = 'example.address' 7 | var creditsAddress = 'example.credits' 8 | 9 | var batchSize = 10000; 10 | 11 | var handler = function() { 12 | credits += batchSize; 13 | sendMessage(); 14 | } 15 | 16 | eb.registerHandler(creditsAddress, handler); 17 | 18 | var credits = 0; 19 | var count = 0 20 | 21 | function sendMessage() { 22 | for (var i = 0; i < batchSize / 2; i++) { 23 | if (credits > 0) { 24 | credits--; 25 | eb.send(address, "some-message"); 26 | count++; 27 | } 28 | else { 29 | return; 30 | } 31 | } 32 | vertx.runOnContext(sendMessage); 33 | } 34 | 35 | function vertxStop() { 36 | eb.unregisterHandler(creditsAddress, handler); 37 | } 38 | 39 | console.log("Started"); 40 | -------------------------------------------------------------------------------- /src/raw/javascript/echo/echo_client.js: -------------------------------------------------------------------------------- 1 | var vertx = require('vertx') 2 | var console = require('vertx/console') 3 | 4 | var client = vertx.createNetClient(); 5 | 6 | client.connect(1234, function(err, sock) { 7 | 8 | sock.dataHandler(function(buffer) { 9 | console.log("client receiving " + buffer.toString()); 10 | }); 11 | 12 | // Now send some data 13 | for (var i = 0; i < 10; i++) { 14 | var str = "hello" + i + "\n"; 15 | console.log("Net client sending: " + str); 16 | sock.write(new vertx.Buffer(str)); 17 | } 18 | }); 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/raw/javascript/echo/echo_server.js: -------------------------------------------------------------------------------- 1 | var vertx = require('vertx') 2 | 3 | vertx.createNetServer().connectHandler(function(sock) { 4 | new vertx.Pump(sock, sock).start(); 5 | }).listen(1234); 6 | -------------------------------------------------------------------------------- /src/raw/javascript/eventbus_pointtopoint/receiver.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | var eb = require("vertx/event_bus"); 18 | var console = require("vertx/console"); 19 | 20 | eb.registerHandler("ping-address", function(message, replier) { 21 | console.log('Received message ' + message); 22 | // Now reply to it 23 | replier('pong!'); 24 | }); 25 | -------------------------------------------------------------------------------- /src/raw/javascript/eventbus_pointtopoint/sender.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | var eb = require("vertx/event_bus"); 18 | var console = require("vertx/console"); 19 | var vertx = require("vertx") 20 | 21 | vertx.setPeriodic(1000, function sendMessage() { 22 | eb.send('ping-address', 'ping!', function(reply) { 23 | console.log("Received reply: " + reply); 24 | }); 25 | }) 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/raw/javascript/eventbus_pubsub/receiver.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | var eb = require("vertx/event_bus"); 18 | var console = require("vertx/console"); 19 | 20 | eb.registerHandler("news-feed", function(message) { 21 | console.log('Received news ' + message); 22 | }); 23 | -------------------------------------------------------------------------------- /src/raw/javascript/eventbus_pubsub/sender.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | var eb = require("vertx/event_bus"); 18 | var console = require("vertx/console"); 19 | var vertx = require("vertx") 20 | 21 | vertx.setPeriodic(1000, function sendMessage() { 22 | eb.publish('news-feed', 'some news!'); 23 | }) 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/raw/javascript/eventbusbridge/bridge_server.js: -------------------------------------------------------------------------------- 1 | var vertx = require('vertx') 2 | 3 | var server = vertx.createHttpServer() 4 | 5 | // Serve the static resources 6 | server.requestHandler(function(req) { 7 | if (req.uri() == "/") req.response.sendFile("eventbusbridge/index.html") 8 | if (req.uri() == "/vertxbus.js") req.response.sendFile("eventbusbridge/vertxbus.js") 9 | }) 10 | 11 | // Create a SockJS bridge which lets everything through (be careful!) 12 | vertx.createSockJSServer(server).bridge({prefix: "/eventbus"}, [{}], [{}]); 13 | 14 | server.listen(8080); -------------------------------------------------------------------------------- /src/raw/javascript/http/http_client.js: -------------------------------------------------------------------------------- 1 | var vertx = require('vertx') 2 | var console = require('vertx/console') 3 | 4 | vertx.createHttpClient().port(8080).getNow('/', function(resp) { 5 | console.log("Got response " + resp.statusCode()); 6 | resp.bodyHandler(function(body) { 7 | console.log("Got data " + body); 8 | }) 9 | }); 10 | -------------------------------------------------------------------------------- /src/raw/javascript/http/http_server.js: -------------------------------------------------------------------------------- 1 | var vertx = require('vertx') 2 | 3 | vertx.createHttpServer().requestHandler(function(req) { 4 | req.response.end("

Hello from vert.x!

"); 5 | }).listen(8080); 6 | 7 | -------------------------------------------------------------------------------- /src/raw/javascript/httphelloworld/http_server.js: -------------------------------------------------------------------------------- 1 | var vertx = require('vertx') 2 | 3 | vertx.createHttpServer().requestHandler(function(req) { 4 | req.response.headers['Content-Type'] = "text/plain"; 5 | req.response.end("Hello World"); 6 | }).listen(8080); 7 | 8 | -------------------------------------------------------------------------------- /src/raw/javascript/https/https_client.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | var vertx = require('vertx') 18 | var console = require('vertx/console') 19 | 20 | var client = vertx.createHttpClient().port(4443).ssl(true).trustAll(true); 21 | 22 | client.getNow('/', function(resp) { 23 | console.log("Got response " + resp.statusCode()); 24 | resp.bodyHandler(function(body) { 25 | console.log("Got data " + body); 26 | }) 27 | }); 28 | -------------------------------------------------------------------------------- /src/raw/javascript/https/https_server.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | var vertx = require('vertx') 18 | 19 | var server = vertx.createHttpServer().ssl(true). 20 | keyStorePath('server-keystore.jks'). 21 | keyStorePassword('wibble'); 22 | 23 | server.requestHandler(function(req) { 24 | req.response.end("

Hello from vert.x!

"); 25 | }).listen(4443, 'localhost'); 26 | 27 | -------------------------------------------------------------------------------- /src/raw/javascript/proxy/http_client.js: -------------------------------------------------------------------------------- 1 | var vertx = require('vertx') 2 | var console = require('vertx/console') 3 | 4 | var client = vertx.createHttpClient().port(8080); 5 | var request = client.put('/', function(resp) { 6 | console.log("Got response " + resp.statusCode()); 7 | resp.bodyHandler(function(body) { 8 | console.log("Got data " + body); 9 | }) 10 | }); 11 | 12 | request.chunked(true) 13 | 14 | for (var i = 0; i < 10; i++) { 15 | request.write("client-chunk-" + i); 16 | } 17 | request.end(); 18 | -------------------------------------------------------------------------------- /src/raw/javascript/proxy/http_server.js: -------------------------------------------------------------------------------- 1 | var vertx = require('vertx') 2 | var console = require('vertx/console') 3 | 4 | vertx.createHttpServer().requestHandler(function(req) { 5 | console.log("Got request " + req.uri()); 6 | 7 | var hdrs = req.headers(); 8 | hdrs.forEach(function(k, v) { 9 | console.log(k + ":" + v) 10 | }); 11 | 12 | req.dataHandler(function(data) { console.log("Got data " + data) }); 13 | 14 | req.endHandler(function() { 15 | // Now send back a response 16 | req.response.chunked(true) 17 | 18 | for (var i = 0; i < 10; i++) { 19 | req.response.write("server-data-chunk-" + i); 20 | } 21 | 22 | req.response.end(); 23 | }); 24 | }).listen(8282) 25 | -------------------------------------------------------------------------------- /src/raw/javascript/route_match/index.html: -------------------------------------------------------------------------------- 1 | 2 | Route Matcher example 3 | 4 | 5 | Click on these links:

6 | 7 | Joe
8 | Bob
9 | Jeff
10 | Jane
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/raw/javascript/route_match/route_match_example.js: -------------------------------------------------------------------------------- 1 | 2 | var vertx = require('vertx'); 3 | 4 | // Inspired from Sinatra / Express 5 | var rm = new vertx.RouteMatcher(); 6 | 7 | // Extract the params from the uri 8 | rm.get('/details/:user/:id', function(req) { 9 | req.response.end("User: " + req.params().get('user') + " ID: " + req.params().get('id')) 10 | }); 11 | 12 | // Catch all - serve the index page 13 | rm.getWithRegEx('.*', function(req) { 14 | req.response.sendFile("route_match/index.html"); 15 | }); 16 | 17 | vertx.createHttpServer().requestHandler(rm).listen(8080); 18 | -------------------------------------------------------------------------------- /src/raw/javascript/sendfile/index.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | vert.x static web server 20 | 21 | 22 |

This is the vert.x static web server. Click on some links below

23 | 24 |
25 |
26 | Page 1 27 | Page 2 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/raw/javascript/sendfile/page1.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

Welcome to page1!

23 | 24 | -------------------------------------------------------------------------------- /src/raw/javascript/sendfile/page2.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

Welcome to page2!

23 | 24 | -------------------------------------------------------------------------------- /src/raw/javascript/sendfile/sendfile.js: -------------------------------------------------------------------------------- 1 | var vertx = require('vertx') 2 | 3 | vertx.createHttpServer().requestHandler(function(req) { 4 | var filename = "sendfile/" + (req.uri() == "/" ? "index.html" : "." + req.uri()); 5 | req.response.sendFile(filename) 6 | }).listen(8080) -------------------------------------------------------------------------------- /src/raw/javascript/server-keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/raw/javascript/server-keystore.jks -------------------------------------------------------------------------------- /src/raw/javascript/sockjs/sockjs.js: -------------------------------------------------------------------------------- 1 | var vertx = require('vertx') 2 | var console = require('vertx/console') 3 | 4 | var server = vertx.createHttpServer() 5 | 6 | // Serve the index page 7 | server.requestHandler(function(req) { 8 | if (req.uri() == "/") req.response.sendFile("sockjs/index.html") 9 | }); 10 | 11 | var sjsServer = new vertx.createSockJSServer(server) 12 | 13 | // The handler for the SockJS app - we just echo data back 14 | sjsServer.installApp({prefix: "/testapp"}, function(sock) { 15 | sock.dataHandler(function(buff) { 16 | sock.write(buff) 17 | }) 18 | }); 19 | 20 | server.listen(8080) 21 | -------------------------------------------------------------------------------- /src/raw/javascript/ssl/ssl_server.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2012 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | var vertx = require('vertx') 18 | 19 | var server = vertx.createNetServer().ssl(true) 20 | .keyStorePath('server-keystore.jks') 21 | .keyStorePassword('wibble'); 22 | 23 | server.connectHandler(function(sock) { 24 | new vertx.Pump(sock, sock).start(); 25 | }).listen(1234, 'localhost'); 26 | -------------------------------------------------------------------------------- /src/raw/javascript/upload/upload.txt: -------------------------------------------------------------------------------- 1 | some data 2 | -------------------------------------------------------------------------------- /src/raw/javascript/websockets/ws_client.js: -------------------------------------------------------------------------------- 1 | var vertx = require('vertx') 2 | var console = require('vertx/console') 3 | 4 | var client = vertx.createHttpClient().port(8080); 5 | 6 | client.connectWebsocket('/some-uri', function(websocket) { 7 | websocket.dataHandler(function(data) { 8 | console.log('Received data ' + data); 9 | client.close(); 10 | }); 11 | websocket.writeTextFrame('Hello world'); 12 | }); 13 | -------------------------------------------------------------------------------- /src/raw/javascript/websockets/ws_server.js: -------------------------------------------------------------------------------- 1 | var vertx = require('vertx') 2 | 3 | vertx.createHttpServer().websocketHandler(function(ws) { 4 | ws.dataHandler( function(buffer) { ws.writeTextFrame(buffer.toString()) }); 5 | }).requestHandler(function(req) { 6 | if (req.uri() == "/") req.response.sendFile("websockets/ws.html") 7 | }).listen(8080) 8 | 9 | -------------------------------------------------------------------------------- /src/raw/python/deploy_many/child.py: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | print "in child" 16 | 17 | def vertx_stop(): 18 | print "in stop" -------------------------------------------------------------------------------- /src/raw/python/echo/echo_server.py: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import vertx 16 | from core.streams import Pump 17 | 18 | server = vertx.create_net_server() 19 | 20 | @server.connect_handler 21 | def connect_handler(socket): 22 | Pump(socket, socket).start() 23 | 24 | server.listen(1234) -------------------------------------------------------------------------------- /src/raw/python/eventbus_pointtopoint/receiver.py: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import vertx 16 | from core.event_bus import EventBus 17 | 18 | def handler(msg): 19 | print 'Received message %s' % msg.body 20 | # Now reply to it 21 | msg.reply('Pong!') 22 | EventBus.register_handler('ping-address', handler=handler) -------------------------------------------------------------------------------- /src/raw/python/eventbus_pointtopoint/sender.py: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import vertx 16 | from core.event_bus import EventBus 17 | 18 | def reply_handler(msg): 19 | print 'Received reply %s' % msg.body 20 | 21 | def timer_handler(timer_id): 22 | EventBus.send('ping-address', 'ping!', reply_handler) 23 | 24 | vertx.set_periodic(1000, timer_handler) 25 | 26 | -------------------------------------------------------------------------------- /src/raw/python/eventbus_pubsub/receiver.py: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import vertx 16 | from core.event_bus import EventBus 17 | 18 | def handler(msg): 19 | print 'Received news %s' % msg.body 20 | EventBus.register_handler('news-feed', handler=handler) -------------------------------------------------------------------------------- /src/raw/python/eventbus_pubsub/sender.py: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import vertx 16 | from core.event_bus import EventBus 17 | 18 | def timer_handler(timer_id): 19 | EventBus.publish('news-feed', 'Some News!') 20 | 21 | vertx.set_periodic(1000, timer_handler) 22 | 23 | -------------------------------------------------------------------------------- /src/raw/python/http/http_client.py: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import vertx 16 | 17 | client = vertx.create_http_client(port=8080, host="localhost") 18 | 19 | def handle_body(body): 20 | print "Got data %s"% body 21 | 22 | def handle_response(resp): 23 | print "Got response %s\n" % resp.status_code 24 | resp.body_handler(handle_body) 25 | 26 | client.get_now("/", handle_response) 27 | -------------------------------------------------------------------------------- /src/raw/python/http/http_server.py: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import vertx 16 | 17 | server = vertx.create_http_server() 18 | 19 | @server.request_handler 20 | def handle(req): 21 | req.response.end("

Hello from vert.x!

") 22 | 23 | server.listen(8080) -------------------------------------------------------------------------------- /src/raw/python/https/https_client.py: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import vertx 16 | 17 | client = vertx.create_http_client(port=4443, host="localhost", ssl=True, trust_all=True) 18 | 19 | def handle_body(body): 20 | print "Got data %s"% body 21 | 22 | def handle_response(resp): 23 | print "Got response %s\n" % resp.status_code 24 | resp.body_handler(handle_body) 25 | 26 | client.get_now("/", handle_response) 27 | -------------------------------------------------------------------------------- /src/raw/python/https/https_server.py: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import vertx 16 | 17 | server = vertx.create_http_server(ssl=True) 18 | server.key_store_path = "server-keystore.jks" 19 | server.key_store_password = "wibble" 20 | 21 | @server.request_handler 22 | def handle(req): 23 | req.response.end("

Hello from vert.x over HTTPS!

") 24 | 25 | server.listen(4443) -------------------------------------------------------------------------------- /src/raw/python/proxy/http_client.py: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import vertx 16 | 17 | client = vertx.create_http_client() 18 | client.port = 8080 19 | client.host = "localhost" 20 | 21 | def handle_body(body): 22 | print "Got data %s"% body 23 | 24 | def handle_response(resp): 25 | print "Got response %s" % resp.status_code 26 | resp.body_handler(handle_body) 27 | 28 | req = client.put("/someurl", handle_response) 29 | req.chunked = True 30 | 31 | for i in range(9): 32 | req.write_str("client-data-chunk-%d"% i) 33 | req.end() -------------------------------------------------------------------------------- /src/raw/python/route_match/index.html: -------------------------------------------------------------------------------- 1 | 2 | Route Matcher example 3 | 4 | 5 | Click on these links:

6 | 7 | Joe
8 | Bob
9 | Jeff
10 | Jane
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/raw/python/sendfile/index.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | vert.x static web server 20 | 21 | 22 |

This is the vert.x static web server. Click on some links below

23 | 24 |
25 |
26 | Page 1 27 | Page 2 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/raw/python/sendfile/page1.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

Welcome to page1!

23 | 24 | -------------------------------------------------------------------------------- /src/raw/python/sendfile/page2.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

Welcome to page2!

23 | 24 | -------------------------------------------------------------------------------- /src/raw/python/sendfile/sendfile.py: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import vertx 16 | 17 | server = vertx.create_http_server() 18 | 19 | @server.request_handler 20 | def handle(req): 21 | if(req.uri == "/"): 22 | filename = "sendfile/index.html" 23 | else: 24 | filename = "sendfile/%s"% (req.uri) 25 | req.response.send_file(filename) 26 | server.listen(8080) 27 | -------------------------------------------------------------------------------- /src/raw/python/server-keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/raw/python/server-keystore.jks -------------------------------------------------------------------------------- /src/raw/python/ssl/ssl_server.py: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import vertx 16 | 17 | server = vertx.create_net_server() 18 | server.ssl = True 19 | server.key_store_path="server-keystore.jks" 20 | server.key_store_password="wibble" 21 | 22 | @server.connect_handler 23 | def connect_handler(socket): 24 | def data_handler(data): 25 | socket.write(data) 26 | socket.data_handler(data_handler) 27 | 28 | server.listen(1234) -------------------------------------------------------------------------------- /src/raw/python/upload/upload.txt: -------------------------------------------------------------------------------- 1 | some-data 2 | -------------------------------------------------------------------------------- /src/raw/python/websockets/websockets.py: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import vertx 16 | 17 | server = vertx.create_http_server() 18 | 19 | @server.websocket_handler 20 | def websocket_handler(ws): 21 | def data_handler(buffer): 22 | ws.write_text_frame(buffer.to_string()) 23 | ws.data_handler(data_handler) 24 | 25 | @server.request_handler 26 | def request_handler(req): 27 | if req.uri == "/": 28 | req.response.send_file("websockets/ws.html") 29 | 30 | server.listen(8080) 31 | -------------------------------------------------------------------------------- /src/raw/ruby/deploy_many/child.rb: -------------------------------------------------------------------------------- 1 | require "vertx" 2 | 3 | #puts "in child" 4 | 5 | def vertx_stop 6 | #puts "in stop" 7 | end -------------------------------------------------------------------------------- /src/raw/ruby/deploy_many/mem.rb: -------------------------------------------------------------------------------- 1 | require "vertx" 2 | 3 | def deploy_it(count) 4 | Vertx::deploy_verticle("child.rb") do |err, deploy_id| 5 | if err 6 | puts "Failed to deploy #{err}" 7 | else 8 | puts "deployed #{count}" 9 | undeploy_it(deploy_id, count) 10 | end 11 | end 12 | end 13 | 14 | def undeploy_it(deploy_id, count) 15 | #puts "undeploying #{deploy_id}" 16 | Vertx::undeploy_verticle(deploy_id) do 17 | # puts "undeployed" 18 | count = count + 1 19 | if count < 10000 20 | deploy_it(count) 21 | else 22 | puts "done!" 23 | end 24 | end 25 | end 26 | 27 | deploy_it(0) 28 | -------------------------------------------------------------------------------- /src/raw/ruby/echo/echo_client.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | NetClient.new.connect(1234, "localhost") do |err, socket| 19 | if err 20 | puts "Failed to connect #{err}" 21 | else 22 | socket.data_handler { |data| puts "Echo client received #{data.to_s}" } 23 | (1..10).each do |i| 24 | str = "hello #{i}\n" 25 | puts "Echo client sending #{str}" 26 | socket.write(Buffer.create_from_str(str)) 27 | end 28 | end 29 | end 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/raw/ruby/echo/echo_server.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | NetServer.new.connect_handler do |socket| 19 | Pump.new(socket, socket).start 20 | end.listen(1234) 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/raw/ruby/eventbus_pointtopoint/receiver.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | EventBus.register_handler('ping-address') do |msg| 19 | puts "Received message: #{msg.body}" 20 | # Now reply to it 21 | msg.reply('pong!') 22 | end 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/raw/ruby/eventbus_pointtopoint/sender.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | Vertx::set_periodic(1000) do 19 | EventBus.send('ping-address', 'ping') do |reply| 20 | puts "Received reply: #{reply.body}" 21 | end 22 | end 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/raw/ruby/eventbus_pubsub/receiver.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | EventBus.register_handler('news-feed') do |msg| 19 | puts "Received news: #{msg.body}" 20 | end 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/raw/ruby/eventbus_pubsub/sender.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | Vertx::set_periodic(1000) do 19 | EventBus.publish('news-feed', 'Some news!') 20 | end 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/raw/ruby/eventbusbridge/bridge_server.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | server = HttpServer.new 19 | 20 | # Serve the static resources 21 | server.request_handler do |req| 22 | req.response.send_file("eventbusbridge/index.html") if req.uri == "/" 23 | req.response.send_file("eventbusbridge/vertxbus.js") if req.uri == "/vertxbus.js" 24 | end 25 | 26 | # Create a bridge that lets everything through (be careful!) 27 | SockJSServer.new(server).bridge({"prefix" => "/eventbus"}, [{}], [{}]) 28 | 29 | server.listen(8080) 30 | -------------------------------------------------------------------------------- /src/raw/ruby/fanout/fanout_server.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | conns = SharedData::get_set("conns") 19 | 20 | NetServer.new.connect_handler do |socket| 21 | conns.add(socket.write_handler_id) 22 | socket.data_handler do |data| 23 | conns.each { |address| EventBus::send(address, data) } 24 | end 25 | socket.close_handler { conns.delete(socket.write_handler_id) } 26 | end.listen(1234) 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/raw/ruby/http/http_client.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | client = HttpClient.new 19 | client.port = 8080 20 | client.host = "localhost" 21 | client.get_now("/") do |resp| 22 | puts "Got response #{resp.status_code}" 23 | resp.body_handler do |buffer| 24 | puts "Got data #{buffer}" 25 | end 26 | end -------------------------------------------------------------------------------- /src/raw/ruby/http/http_server.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | HttpServer.new.request_handler do |req| 19 | req.response.end("

Hello from vert.x!

") 20 | end.listen(8080) -------------------------------------------------------------------------------- /src/raw/ruby/https/https_client.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | client = HttpClient.new 19 | client.ssl = true 20 | client.port = 4443 21 | client.host = "localhost" 22 | client.trust_all = true 23 | client.get_now("/") do |resp| 24 | puts "Got response #{resp.status_code}" 25 | resp.data_handler { |buffer| puts "Got data #{buffer}" } 26 | end -------------------------------------------------------------------------------- /src/raw/ruby/https/https_server.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | server = HttpServer.new 19 | server.ssl = true 20 | server.key_store_path = "server-keystore.jks" 21 | server.key_store_password = "wibble" 22 | server.request_handler do |req| 23 | req.response.end("

Hello from vert.x over HTTPS!

") 24 | end.listen(4443) -------------------------------------------------------------------------------- /src/raw/ruby/proxy/http_client.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | client = HttpClient.new 19 | client.port = 8080 20 | client.host = "localhost" 21 | req = client.put("/someurl") do |resp| 22 | puts "Got response #{resp.status_code}" 23 | resp.body_handler { |buffer| puts "Got data #{buffer}" } 24 | end 25 | req.chunked = true 26 | for i in 0..9 27 | req.write_str("client-data-chunk-#{i}") 28 | end 29 | req.end -------------------------------------------------------------------------------- /src/raw/ruby/proxy/http_server.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | require "set" 17 | include Vertx 18 | 19 | HttpServer.new.request_handler do |req| 20 | puts "Got request #{req.uri}" 21 | 22 | req.headers.each { |k, v| puts "#{k} : #{v}" } 23 | 24 | req.data_handler { |data| puts "Got data #{data}" } 25 | 26 | req.end_handler do 27 | # Now send back a response 28 | req.response.chunked = true 29 | 30 | for i in 0..9 31 | req.response.write_str("server-data-chunk-#{i}") 32 | end 33 | 34 | req.response.end 35 | end 36 | end.listen(8282) -------------------------------------------------------------------------------- /src/raw/ruby/route_match/index.html: -------------------------------------------------------------------------------- 1 | 2 | Route Matcher example 3 | 4 | 5 | Click on these links:

6 | 7 | Joe
8 | Bob
9 | Jeff
10 | Jane
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/raw/ruby/route_match/route_match_example.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | # Inspired from Sinatra / Express 19 | rm = RouteMatcher.new 20 | 21 | # Extract the params from the uri 22 | rm.get('/details/:user/:id') { |req| req.response.end("User: #{req.params['user']} ID: #{req.params['id']}") } 23 | 24 | # Catch all - serve the index page 25 | rm.get_re('.*') { |req| req.response.send_file("route_match/index.html")} 26 | 27 | HttpServer.new.request_handler(rm).listen(8080) -------------------------------------------------------------------------------- /src/raw/ruby/sendfile/index.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | vert.x static web server 20 | 21 | 22 |

This is the vert.x static web server. Click on some links below

23 | 24 |
25 |
26 | Page 1 27 | Page 2 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/raw/ruby/sendfile/page1.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

Welcome to page1!

23 | 24 | -------------------------------------------------------------------------------- /src/raw/ruby/sendfile/page2.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

Welcome to page2!

23 | 24 | -------------------------------------------------------------------------------- /src/raw/ruby/sendfile/sendfile.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | HttpServer.new.request_handler do |req| 19 | filename = "sendfile/" << (req.uri == "/" ? "index.html" : "." << req.uri) 20 | req.response.send_file(filename) 21 | end.listen(8080) -------------------------------------------------------------------------------- /src/raw/ruby/server-keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/raw/ruby/server-keystore.jks -------------------------------------------------------------------------------- /src/raw/ruby/sockjs/sockjs.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | server = HttpServer.new 19 | 20 | # Serve the index page 21 | server.request_handler { |req| req.response.send_file("sockjs/index.html") if req.uri == "/"} 22 | 23 | sjs_server = SockJSServer.new(server) 24 | 25 | # The handler for the SockJS app - we just echo data back 26 | sjs_server.install_app({"prefix" => "/testapp"}) { |sock| sock.data_handler{ |buff| sock.write(buff) } } 27 | 28 | server.listen(8080) -------------------------------------------------------------------------------- /src/raw/ruby/ssl/ssl_client.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | client = NetClient.new 19 | client.ssl = true 20 | client.trust_all = true 21 | client.connect(1234, "localhost") do |err, socket| 22 | if err 23 | puts "Failed to connect #{err}" 24 | else 25 | socket.data_handler { |data| puts "Echo client received #{data.to_s}" } 26 | (1..10).each do |i| 27 | str = "hello #{i}\n" 28 | puts "Echo client sending #{str}" 29 | socket.write(Buffer.create_from_str(str)) 30 | end 31 | end 32 | end 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/raw/ruby/ssl/ssl_server.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | server = NetServer.new 19 | server.ssl = true 20 | server.key_store_path="server-keystore.jks" 21 | server.key_store_password="wibble" 22 | server.connect_handler { |socket| socket.data_handler { |data| socket.write(data) } } 23 | server.listen(1234) 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/raw/ruby/upload/upload.txt: -------------------------------------------------------------------------------- 1 | some-data 2 | -------------------------------------------------------------------------------- /src/raw/ruby/upload/upload_client.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | client = HttpClient.new 19 | client.port = 8080 20 | client.host = "localhost" 21 | req = client.put("/someurl") { |resp| puts "Response #{resp.status_code}" } 22 | filename = "upload/upload.txt" 23 | FileSystem::props(filename) do |err, props| 24 | size = props.size 25 | req.put_header("Content-Length", size) 26 | FileSystem::open(filename) do |err, file| 27 | pump = Pump.new(file, req) 28 | file.end_handler { req.end } 29 | pump.start 30 | end 31 | end -------------------------------------------------------------------------------- /src/raw/ruby/websockets/websockets.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2011 the original author or authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | require "vertx" 16 | include Vertx 17 | 18 | HttpServer.new.websocket_handler do |ws| 19 | ws.data_handler { |buffer| ws.write_text_frame(buffer.to_s) } 20 | end.request_handler do |req| 21 | req.response.send_file("websockets/ws.html") if req.uri == "/" 22 | end.listen(8080) -------------------------------------------------------------------------------- /src/raw/scala/echo/EchoServer.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | vertx.createNetServer.connectHandler({ socket: NetSocket => 18 | Pump.createPump(socket, socket).start() 19 | }).listen(8080) -------------------------------------------------------------------------------- /src/raw/scala/eventbus_pointtopoint/Receiver.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | vertx.eventBus.registerHandler("ping-address", { message: Message[String] => 18 | // Reply to it 19 | container.logger.info("Received message: " + message.body()) 20 | message.reply("pong!") 21 | }) 22 | -------------------------------------------------------------------------------- /src/raw/scala/eventbus_pointtopoint/Sender.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | vertx.setPeriodic(1000, { timerID: Long => 18 | vertx.eventBus.send("ping-address", "ping!", { reply: Message[String] => 19 | container.logger.info("Received reply: " + reply.body()) 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /src/raw/scala/eventbus_pubsub/Receiver.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | vertx.eventBus.registerHandler("news-feed", { message: Message[String] => 18 | container.logger.info("Received news: " + message.body()) 19 | }) -------------------------------------------------------------------------------- /src/raw/scala/eventbus_pubsub/Sender.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | vertx.setPeriodic(1000, { timerID: Long => 18 | vertx.eventBus.publish("news-feed", "more news!") 19 | }) 20 | -------------------------------------------------------------------------------- /src/raw/scala/fanout/FanoutServer.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | val connections = vertx.sharedData.getSet[String]("conns") 18 | 19 | vertx.createNetServer.connectHandler({ socket: NetSocket => 20 | connections.add(socket.writeHandlerID) 21 | 22 | socket.dataHandler({ buffer: Buffer => 23 | for (actorID <- connections) { 24 | vertx.eventBus.publish(actorID, buffer) 25 | } 26 | }) 27 | 28 | socket.closeHandler({ 29 | connections.remove(socket.writeHandlerID()) 30 | }) 31 | }).listen(8080) -------------------------------------------------------------------------------- /src/raw/scala/http/Client.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | vertx.createHttpClient.setPort(8080).setHost("localhost").getNow("/", { response: HttpClientResponse => 18 | response.bodyHandler({ data: Buffer => 19 | container.logger.info(data) 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /src/raw/scala/http/Server.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | vertx.createHttpServer.requestHandler { req: HttpServerRequest => 18 | req.response.end("This is a Verticle script") 19 | }.listen(8080) -------------------------------------------------------------------------------- /src/raw/scala/https/ClientExample.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | vertx.createHttpClient.setSSL(true).setTrustAll(true).setPort(8080).setHost("localhost").getNow("/", { response: HttpClientResponse => 18 | response.dataHandler({ data: Buffer => 19 | container.logger.info(data) 20 | }) 21 | }) 22 | -------------------------------------------------------------------------------- /src/raw/scala/proxy/Client.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | val req = vertx.createHttpClient.setPort(8080).setHost("localhost").put("/some-url", { response: HttpClientResponse => 18 | response.dataHandler({ data: Buffer => 19 | container.logger.info("Got response data:" + data) 20 | }) 21 | }) 22 | //Write a few chunks 23 | req.setChunked(true) 24 | for (i <- 0 until 10) { 25 | req.write("client-data-chunk-" + i) 26 | } 27 | req.end() 28 | -------------------------------------------------------------------------------- /src/raw/scala/resourceload/ResourceLoadExample.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | val urlBar = getClass().getClassLoader().getResource("bar.txt") 18 | println("bar url is: " + urlBar) 19 | val urlFoo = getClass().getClassLoader().getResource("foo.xml") 20 | println("foo url is: " + urlFoo) -------------------------------------------------------------------------------- /src/raw/scala/resourceload/bar.txt: -------------------------------------------------------------------------------- 1 | bar bar black sheep -------------------------------------------------------------------------------- /src/raw/scala/resourceload/foo.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/raw/scala/route_match/RouteMatchExample.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | val rm = RouteMatcher() 18 | 19 | rm.get("/details/:user/:id", { req: HttpServerRequest => 20 | req.response().end("User: " + req.params().get("user") + " ID: " + req.params().get("id")) 21 | }) 22 | 23 | // Catch all - serve the index page 24 | rm.getWithRegEx(".*", { req: HttpServerRequest => 25 | req.response().sendFile("route_match/index.html") 26 | }) 27 | 28 | vertx.createHttpServer().requestHandler(rm).listen(8080) -------------------------------------------------------------------------------- /src/raw/scala/route_match/index.html: -------------------------------------------------------------------------------- 1 | 2 | Route Matcher example 3 | 4 | 5 | Click on these links:

6 | 7 | Joe
8 | Bob
9 | Jeff
10 | Jane
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/raw/scala/sendfile/SendFileExample.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | val webroot = "sendfile/" 18 | 19 | vertx.createHttpServer().requestHandler({ req: HttpServerRequest => 20 | if (req.path().equals("/")) { 21 | req.response().sendFile(webroot + "index.html") 22 | } else { 23 | //Clearly in a real server you would check the path for better security!! 24 | req.response().sendFile(webroot + req.path()) 25 | } 26 | }).listen(8080) -------------------------------------------------------------------------------- /src/raw/scala/sendfile/index.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | vert.x static web server 20 | 21 | 22 |

This is the vert.x static web server. Click on some links below

23 | 24 |
25 |
26 | Page 1 27 | Page 2 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/raw/scala/sendfile/page1.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

Welcome to page1!

23 | 24 | -------------------------------------------------------------------------------- /src/raw/scala/sendfile/page2.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |

Welcome to page2!

23 | 24 | -------------------------------------------------------------------------------- /src/raw/scala/server-keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vert-x/vertx-examples/2ca9b21a3add80ef804b3cd95cd85b7de32ce1f7/src/raw/scala/server-keystore.jks -------------------------------------------------------------------------------- /src/raw/scala/simpleform/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | foo:
11 | bar:
12 | quux:
13 | 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /src/raw/scala/simpleformupload/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | choose a file to upload:
11 | 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /src/raw/scala/ssl/SSLClient.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | vertx.createNetClient.setSSL(true).setTrustAll(true).connect(8080, "localhost", { asyncResult: AsyncResult[NetSocket] => 18 | val socket = asyncResult.result() 19 | socket.dataHandler({ buffer: Buffer => 20 | container.logger.info("Net client receiving: " + buffer.toString("UTF-8")) 21 | }) 22 | //Now send some dataHandler 23 | for (i <- 0 until 10) { 24 | val str = "hello" + i + "\n" 25 | container.logger.info("Net client sending: " + str) 26 | socket.write(Buffer(str)) 27 | } 28 | }) -------------------------------------------------------------------------------- /src/raw/scala/ssl/SSLServer.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | vertx.createNetServer().connectHandler({ socket: NetSocket => 18 | socket.dataHandler({ buffer: Buffer => 19 | socket.write(buffer) 20 | }) 21 | }).setSSL(true).setKeyStorePath("server-keystore.jks").setKeyStorePassword("wibble").listen(8080) -------------------------------------------------------------------------------- /src/raw/scala/upload/upload.txt: -------------------------------------------------------------------------------- 1 | some-data 2 | -------------------------------------------------------------------------------- /src/raw/scala/websockets/WebsocketsClient.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | vertx.createHttpClient().setHost("localhost").setPort(8080).connectWebsocket("/myapp", { websocket: WebSocket => 18 | websocket.dataHandler({ data: Buffer => 19 | container.logger.info("Received " + data) 20 | }) 21 | //Send some data 22 | websocket.writeTextFrame("hello world") 23 | }) -------------------------------------------------------------------------------- /src/raw/scala/websockets/WebsocketsExample.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | vertx.createHttpServer().websocketHandler({ ws: ServerWebSocket => 18 | if (ws.path().equals("/myapp")) { 19 | ws.dataHandler({ data: Buffer => 20 | ws.writeTextFrame(data.toString()) // Echo it back 21 | }) 22 | } else { 23 | ws.reject() 24 | } 25 | }).requestHandler({ req: HttpServerRequest => 26 | if (req.path().equals("/")) req.response().sendFile("websockets/ws.html") // Serve the html 27 | }).listen(8080) -------------------------------------------------------------------------------- /src/raw/scala/wsperf/ConnectClient.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | private val CONNS = 1000 18 | var connectCount = 0 19 | 20 | val client = vertx.createHttpClient.setPort(8080).setHost("localhost").setMaxPoolSize(CONNS) 21 | 22 | for (i <- 0 until CONNS) { 23 | client.connectWebsocket("/someuri", { ws: WebSocket => 24 | connectCount += 1 25 | container.logger.info("ws connected: " + connectCount) 26 | }) 27 | } 28 | -------------------------------------------------------------------------------- /src/raw/scala/wsperf/ConnectServer.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | val BUFF_SIZE = 32 * 1024 18 | var count = 0 19 | 20 | vertx.createHttpServer.setReceiveBufferSize(BUFF_SIZE).setSendBufferSize(BUFF_SIZE). 21 | websocketHandler({ ws: ServerWebSocket => 22 | count += 1 23 | container.logger.info("connected " + count) 24 | }).listen(8080, "localhost") -------------------------------------------------------------------------------- /src/raw/scala/wsperf/PerfServer.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | val BUFF_SIZE = 32 * 1024 18 | 19 | vertx.createHttpServer().setReceiveBufferSize(BUFF_SIZE).setSendBufferSize(BUFF_SIZE).setAcceptBacklog(32000). 20 | websocketHandler({ ws: ServerWebSocket => 21 | Pump.createPump(ws, ws, BUFF_SIZE).start() 22 | }).listen(8080, "localhost") -------------------------------------------------------------------------------- /src/raw/scala/wsperf/vertx-server.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | var vertx = require('vertx'); 18 | var console = require('console'); 19 | 20 | var connCount = 0; 21 | vertx.createHttpServer().websocketHandler(function(ws) { 22 | console.log("Connection count: " + ++connCount); 23 | new vertx.Pump(ws, ws).start(); 24 | }).listen(8080); --------------------------------------------------------------------------------