Package javax.websocket

Examples of javax.websocket.SendResult


        }

        @Override
        public void run() {
            if (t == null) {
                sh.onResult(new SendResult());
            } else {
                sh.onResult(new SendResult(t));
            }
            t = null;
            sh = null;
            // Return the Runnable to the queue when it has been finished with
            // Note if this method takes an age to finish there shouldn't be any
View Full Code Here


            state = State.CLOSED;
        }

        IOException ioe = new IOException(sm.getString("wsSession.messageFailed"));
        SendResult sr = new SendResult(ioe);
        for (FutureToSendHandler f2sh : futures.keySet()) {
            f2sh.onResult(sr);
        }
    }
View Full Code Here

                        } catch (IOException ioe) {
                            // Ignore
                        }
                    }
                }
                completion.onResult(new SendResult());
            } else if (encoder instanceof Encoder.Binary) {
                ByteBuffer msg = ((Encoder.Binary) encoder).encode(obj);
                sendBytesByCompletion(msg, completion);
            } else if (encoder instanceof Encoder.BinaryStream) {
                OutputStream os = null;
                try {
                    os = getSendStream();
                    ((Encoder.BinaryStream) encoder).encode(obj, os);
                } finally {
                    if (os != null) {
                        try {
                            os.close();
                        } catch (IOException ioe) {
                            // Ignore
                        }
                    }
                }
                completion.onResult(new SendResult());
            } else {
                throw new EncodeException(obj, sm.getString(
                        "wsRemoteEndpoint.noEncoder", obj.getClass()));
            }
        } catch (EncodeException e) {
            SendResult sr = new SendResult(e);
            completion.onResult(sr);
        } catch (IOException e) {
            SendResult sr = new SendResult(e);
            completion.onResult(sr);
        }
    }
View Full Code Here

                endpoint.stateMachine.complete(isLast);
                handler.onResult(result);
            } else if(!result.isOK()) {
                handler.onResult(result);
            } else if (closed){
                SendResult sr = new SendResult(new IOException(
                        sm.getString("wsRemoteEndpoint.closedDuringMessage")));
                handler.onResult(sr);
            } else {
                write();
            }
View Full Code Here

            }

            if (flushRequired) {
                outputBuffer.flip();
                if (outputBuffer.remaining() == 0) {
                    handler.onResult(new SendResult());
                } else {
                    endpoint.doWrite(this, outputBuffer);
                }
            } else {
                handler.onResult(new SendResult());
            }
        }
View Full Code Here

        this.handler = handler;
    }

    @Override
    public void onCompletion() {
        handler.onResult(new SendResult());
    }
View Full Code Here

        handler.onResult(new SendResult());
    }

    @Override
    public void onError(Throwable cause) {
        handler.onResult(new SendResult(cause));
    }
View Full Code Here

TOP

Related Classes of javax.websocket.SendResult

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.