Skip to main content

Posts

Showing posts from 2012

WebSocket with Grizzly, OSGi and iPOJO

Setup In this project we use the Grizzly http-service bundle version 2.2.18 which supports websocket and iPOJO . org.glassfish.grizzly.osgi grizzly-httpservice-bundle 2.2.18 org.apache.felix org.apache.felix.ipojo.annotations 1.6.4 We have to activate the websockets support by settings the following framework properties:  org.osgi.service.http.port=8080 org.glassfish.grizzly.websocketsSupport=true A simple 'echo' WebSocketApplication The following class implements a simple echo websocket app, such as describe here . import org.glassfish.grizzly.websockets.WebSocket; import org.glassfish.grizzly.websockets.WebSocketApplication; package org.barjo.websocket.test; public class MyEchoWebSocketApp extends WebSocketApplication { @Override public boolean isApplicationRequest(HttpRequestPacket request) { return true; } @Override public void onMessage(WebSocket socket,String text) { socket.send(text); /