Package org.apache.tuscany.sca.binding.websocket.runtime

Examples of org.apache.tuscany.sca.binding.websocket.runtime.WebsocketStatus


    public void registerForNotifications() {
        new Timer().scheduleAtFixedRate(new TimerTask() {

            @Override
            public void run() {
                WebsocketStatus status = client.sendMessage("Notification @ " + new Date());
                if (status == WebsocketStatus.CLOSED) {
                    this.cancel();
                }
            }
        }, 0L, 1000L);
View Full Code Here


            @Override
            public void run() {
                final Response response = new Response();
                response.setDate(new Date());
                response.setData(Helper.randomInt(90) + "%");
                WebsocketStatus status = callback.sendMessage(response);
                if (status == WebsocketStatus.CLOSED) {
                    System.out.println("Client disconnected from HumidityService.");
                    this.cancel();
                }
            }
View Full Code Here

            public void run() {
                final Response response = new Response();
                response.setDate(new Date());
                final String data = "" + Helper.randomInt(40);
                response.setData(data);
                WebsocketStatus status = callback.sendMessage(response);
                if (status == WebsocketStatus.CLOSED) {
                    System.out.println("Client disconnected from TemperatureService.");
                    this.cancel();
                }
            }
View Full Code Here

                // client has unregistered from this event
                synchronized (eventListeners) {
                    eventListeners.remove(eventName, registrationId);
                }
            } else {
                WebsocketStatus status = client.sendMessage(event);
                if (status == WebsocketStatus.CLOSED) {
                    unregister(registrationId);
                }
            }
        }
View Full Code Here

            @Override
            public void run() {
                Response response = new Response();
                response.setDate(new Date());
                response.setData(Helper.randomInt(100) + "%");
                WebsocketStatus status = client.sendMessage(response);
                if (status == WebsocketStatus.CLOSED) {
                    System.out.println("Client disconnected from PrecipitationService.");
                    this.cancel();
                }
            }
View Full Code Here

    private CopyOnWriteArrayList<WebsocketBindingCallback> clients = new CopyOnWriteArrayList<WebsocketBindingCallback>();

    @Override
    public void postMessage(String user, String message) {
        for (WebsocketBindingCallback callback : new ArrayList<WebsocketBindingCallback>(clients)) {
            WebsocketStatus status = callback.sendMessage(user + ": " + message);
            if (status == WebsocketStatus.CLOSED) {
                clients.remove(callback);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.binding.websocket.runtime.WebsocketStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.