Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Embed Vert.x in Grails
import org.vertx.groovy.core.Vertx
class BootStrap {
def init = { servletContext ->
def vertx = Vertx.newVertx()
def httpServer = vertx.createHttpServer()
vertx.createSockJSServer(httpServer).installApp(prefix: '/events') { sock ->
sock.dataHandler { buff ->
sock << buff
}
}
httpServer.listen(8585)
}
def destroy = {
}
}
<!doctype html>
<html>
<head>
<title>SockJS Test</title>
<script src="http://cdn.sockjs.org/sockjs-0.2.1.min.js"></script>
</head>
<body>
<script>
var sock = new SockJS('http://localhost:8585/events');
sock.onopen = function() {
console.log('open');
};
sock.onmessage = function(e) {
console.log('message', e.data);
alert('received message echoed from server: ' + e.data);
};
sock.onclose = function() {
console.log('close');
};
function send(message) {
if (sock.readyState == WebSocket.OPEN) {
console.log("sending message")
sock.send(message);
} else {
console.log("The socket is not open.");
}
}
</script>
<form onsubmit="return false;">
<input type="text" name="message" value="Hello, World!"/>
<input type="button" value="Send SockJS data" onclick="send(this.form.message.value)"/>
</form>
</body>
</html>
lib/vert.x-core.jar
lib/vert.x-platform.jar
lib/netty.jar
lib/jackson-core.jar
lib/jackson-mapper.jar
@shyam541

Will this work without violationg cross domain policy? http://grails.1312388.n4.nabble.com/TCP-Socket-Server-td2285321.html

@shyam541

Will this work without violationg cross domain policy? http://grails.1312388.n4.nabble.com/TCP-Socket-Server-td2285321.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.