395344 Move JSR-356 (Java WebSocket API) work off to Jetty 9.1.x
This commit is contained in:
parent
0805f131a8
commit
11cbe274af
|
@ -258,11 +258,6 @@
|
|||
<version>${project.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.drafts</groupId>
|
||||
<artifactId>javax.websocket-api</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.spdy</groupId>
|
||||
|
@ -401,4 +396,4 @@
|
|||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -86,7 +86,6 @@ public class TestJettyOSGiBootCore extends AbstractTestOSGi {
|
|||
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-security" ).versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-servlets" ).versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty" ).artifactId( "jetty-client" ).versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty.drafts" ).artifactId( "javax.websocket-api" ).versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty.websocket" ).artifactId( "websocket-api" ).versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty.websocket" ).artifactId( "websocket-common" ).versionAsInProject().noStart());
|
||||
res.add(mavenBundle().groupId( "org.eclipse.jetty.websocket" ).artifactId( "websocket-servlet" ).versionAsInProject().noStart());
|
||||
|
@ -120,4 +119,4 @@ public class TestJettyOSGiBootCore extends AbstractTestOSGi {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,6 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.drafts</groupId>
|
||||
<artifactId>javax.websocket-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.websocket.api;
|
||||
|
||||
public class CloseStatus
|
||||
{
|
||||
private static final int MAX_CONTROL_PAYLOAD = 125;
|
||||
private static final int MAX_REASON_PHRASE = MAX_CONTROL_PAYLOAD - 2;
|
||||
private int code;
|
||||
private String phrase;
|
||||
|
||||
/**
|
||||
* Creates a reason for closing a web socket connection with the given code and reason phrase.
|
||||
*
|
||||
* @param closeCode
|
||||
* the close code
|
||||
* @param reasonPhrase
|
||||
* the reason phrase
|
||||
* @see StatusCode
|
||||
*/
|
||||
public CloseStatus(int closeCode, String reasonPhrase)
|
||||
{
|
||||
this.code = closeCode;
|
||||
this.phrase = reasonPhrase;
|
||||
if (reasonPhrase.length() > MAX_REASON_PHRASE)
|
||||
{
|
||||
throw new IllegalArgumentException("Phrase exceeds maximum length of " + MAX_REASON_PHRASE);
|
||||
}
|
||||
}
|
||||
|
||||
public int getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getPhrase()
|
||||
{
|
||||
return phrase;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.websocket.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public interface RemoteEndpoint
|
||||
{
|
||||
/**
|
||||
* Send a binary message, returning when all of the message has been transmitted.
|
||||
*
|
||||
* @param data
|
||||
* the message to be sent
|
||||
*/
|
||||
void sendBytes(ByteBuffer data) throws IOException;
|
||||
|
||||
/**
|
||||
* Initiates the asynchronous transmission of a binary message. This method returns before the message is transmitted. Developers may provide a callback to
|
||||
* be notified when the message has been transmitted, or may use the returned Future object to track progress of the transmission. Errors in transmission
|
||||
* are given to the developer in the WriteResult object in either case.
|
||||
*
|
||||
* @param data
|
||||
* the data being sent
|
||||
* @param completion
|
||||
* handler that will be notified of progress
|
||||
* @return the Future object representing the send operation.
|
||||
*/
|
||||
Future<WriteResult> sendBytesByFuture(ByteBuffer data);
|
||||
|
||||
/**
|
||||
* Send a binary message in pieces, blocking until all of the message has been transmitted. The runtime reads the message in order. Non-final pieces are
|
||||
* sent with isLast set to false. The final piece must be sent with isLast set to true.
|
||||
*
|
||||
* @param fragment
|
||||
* the piece of the message being sent
|
||||
*/
|
||||
void sendPartialBytes(ByteBuffer fragment, boolean isLast) throws IOException;
|
||||
|
||||
/**
|
||||
* Send a text message in pieces, blocking until all of the message has been transmitted. The runtime reads the message in order. Non-final pieces are sent
|
||||
* with isLast set to false. The final piece must be sent with isLast set to true.
|
||||
*
|
||||
* @param fragment
|
||||
* the piece of the message being sent
|
||||
*/
|
||||
void sendPartialString(String fragment, boolean isLast) throws IOException;
|
||||
|
||||
/**
|
||||
* Send a Ping message containing the given application data to the remote endpoint. The corresponding Pong message may be picked up using the
|
||||
* MessageHandler.Pong handler.
|
||||
*
|
||||
* @param applicationData
|
||||
* the data to be carried in the ping request
|
||||
*/
|
||||
void sendPing(ByteBuffer applicationData);
|
||||
|
||||
/**
|
||||
* Allows the developer to send an unsolicited Pong message containing the given application data in order to serve as a unidirectional heartbeat for the
|
||||
* session.
|
||||
*
|
||||
* @param applicationData
|
||||
* the application data to be carried in the pong response.
|
||||
*/
|
||||
void sendPong(ByteBuffer applicationData);
|
||||
|
||||
/**
|
||||
* Send a text message, blocking until all of the message has been transmitted.
|
||||
*
|
||||
* @param text
|
||||
* the message to be sent
|
||||
*/
|
||||
void sendString(String text) throws IOException;
|
||||
|
||||
/**
|
||||
* Initiates the asynchronous transmission of a text message. This method returns before the message is transmitted. Developers may provide a callback to be
|
||||
* notified when the message has been transmitted, or may use the returned Future object to track progress of the transmission. Errors in transmission are
|
||||
* given to the developer in the WriteResult object in either case.
|
||||
*
|
||||
* @param text
|
||||
* the text being sent
|
||||
* @param completion
|
||||
* the handler which will be notified of progress
|
||||
* @return the Future object representing the send operation.
|
||||
*/
|
||||
Future<WriteResult> sendStringByFuture(String text);
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.websocket.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
public interface Session
|
||||
{
|
||||
/**
|
||||
* Close the current conversation with a normal status code and no reason phrase.
|
||||
*/
|
||||
void close() throws IOException;
|
||||
|
||||
/**
|
||||
* Close the current conversation, giving a reason for the closure. Note the websocket spec defines the acceptable uses of status codes and reason phrases.
|
||||
*
|
||||
* @param closeStatus
|
||||
* the reason for the closure
|
||||
*/
|
||||
void close(CloseStatus closeStatus) throws IOException;
|
||||
|
||||
/**
|
||||
* The maximum total length of messages, text or binary, that this Session can handle.
|
||||
*
|
||||
* @return the message size
|
||||
*/
|
||||
long getMaximumMessageSize();
|
||||
|
||||
/**
|
||||
* Return the list of extensions currently in use for this conversation.
|
||||
*
|
||||
* @return the negotiated extensions
|
||||
*/
|
||||
List<String> getNegotiatedExtensions();
|
||||
|
||||
/**
|
||||
* Return the sub protocol agreed during the websocket handshake for this conversation.
|
||||
*
|
||||
* @return the negotiated subprotocol
|
||||
*/
|
||||
String getNegotiatedSubprotocol();
|
||||
|
||||
/**
|
||||
* Returns the version of the websocket protocol currently being used. This is taken as the value of the Sec-WebSocket-Version header used in the opening
|
||||
* handshake. i.e. "13".
|
||||
*
|
||||
* @return the protocol version
|
||||
*/
|
||||
String getProtocolVersion();
|
||||
|
||||
/**
|
||||
* Return the query string associated with the request this session was opened under.
|
||||
*/
|
||||
String getQueryString();
|
||||
|
||||
/**
|
||||
* Return a reference to the RemoteEndpoint object representing the other end of this conversation.
|
||||
*
|
||||
* @return the remote endpoint
|
||||
*/
|
||||
RemoteEndpoint getRemote();
|
||||
|
||||
/**
|
||||
* Return the URI that this session was opened under.
|
||||
* <p>
|
||||
* Note, this is different than the servlet-api getRequestURI, as this will return the query portion as well.
|
||||
*
|
||||
* @return the request URI.
|
||||
*/
|
||||
URI getRequestURI();
|
||||
|
||||
/**
|
||||
* Return the number of milliseconds before this conversation will be closed by the container if it is inactive, ie no messages are either sent or received
|
||||
* in that time.
|
||||
*
|
||||
* @return the timeout in milliseconds.
|
||||
*/
|
||||
long getTimeout();
|
||||
|
||||
/**
|
||||
* Return true if and only if the underlying socket is open.
|
||||
*
|
||||
* @return whether the session is active
|
||||
*/
|
||||
abstract boolean isActive();
|
||||
|
||||
/**
|
||||
* Return true if and only if the underlying socket is using a secure transport.
|
||||
*
|
||||
* @return whether its using a secure transport
|
||||
*/
|
||||
boolean isSecure();
|
||||
|
||||
/**
|
||||
* Sets the maximum total length of messages, text or binary, that this Session can handle.
|
||||
*/
|
||||
void setMaximumMessageSize(long length);
|
||||
|
||||
/**
|
||||
* Set the number of milliseconds before this conversation will be closed by the container if it is inactive, ie no messages are either sent or received.
|
||||
*
|
||||
* @param ms
|
||||
* the number of milliseconds.
|
||||
*/
|
||||
void setTimeout(long ms);
|
||||
}
|
|
@ -20,18 +20,15 @@ package org.eclipse.jetty.websocket.api;
|
|||
|
||||
import java.net.HttpCookie;
|
||||
import java.net.URI;
|
||||
import java.security.Principal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.net.websocket.HandshakeRequest;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.api.util.QuoteUtil;
|
||||
|
||||
public class UpgradeRequest implements HandshakeRequest
|
||||
public class UpgradeRequest
|
||||
{
|
||||
private URI requestURI;
|
||||
private List<String> subProtocols = new ArrayList<>();
|
||||
|
@ -39,7 +36,6 @@ public class UpgradeRequest implements HandshakeRequest
|
|||
private List<HttpCookie> cookies = new ArrayList<>();
|
||||
private Map<String, List<String>> headers = new HashMap<>();
|
||||
private Object session;
|
||||
private Principal userPrincipal;
|
||||
private String httpVersion;
|
||||
private String method;
|
||||
private String host;
|
||||
|
@ -142,7 +138,6 @@ public class UpgradeRequest implements HandshakeRequest
|
|||
throw new NumberFormatException("Cannot convert multi-value header into int");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getHeaders()
|
||||
{
|
||||
return headers;
|
||||
|
@ -173,26 +168,22 @@ public class UpgradeRequest implements HandshakeRequest
|
|||
return getHeader("Origin");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getParameterMap()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQueryString()
|
||||
{
|
||||
return requestURI.getQuery();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getRequestURI()
|
||||
{
|
||||
return requestURI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSession()
|
||||
{
|
||||
return session;
|
||||
|
@ -203,12 +194,6 @@ public class UpgradeRequest implements HandshakeRequest
|
|||
return subProtocols;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Principal getUserPrincipal()
|
||||
{
|
||||
return userPrincipal;
|
||||
}
|
||||
|
||||
public boolean hasSubProtocol(String test)
|
||||
{
|
||||
for (String protocol : subProtocols)
|
||||
|
@ -226,12 +211,6 @@ public class UpgradeRequest implements HandshakeRequest
|
|||
return test.equalsIgnoreCase(getOrigin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUserInRole(String role)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setCookies(List<HttpCookie> cookies)
|
||||
{
|
||||
this.cookies = cookies;
|
||||
|
@ -294,9 +273,4 @@ public class UpgradeRequest implements HandshakeRequest
|
|||
this.subProtocols.add(protocol);
|
||||
}
|
||||
}
|
||||
|
||||
public void setUserPrincipal(Principal userPrincipal)
|
||||
{
|
||||
this.userPrincipal = userPrincipal;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,12 +25,10 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.net.websocket.HandshakeResponse;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.api.util.QuoteUtil;
|
||||
|
||||
public class UpgradeResponse implements HandshakeResponse
|
||||
public class UpgradeResponse
|
||||
{
|
||||
public static final String SEC_WEBSOCKET_PROTOCOL = "Sec-WebSocket-Protocol";
|
||||
private int statusCode;
|
||||
|
@ -110,7 +108,6 @@ public class UpgradeResponse implements HandshakeResponse
|
|||
return headers.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getHeaders()
|
||||
{
|
||||
return headers;
|
||||
|
@ -149,7 +146,7 @@ public class UpgradeResponse implements HandshakeResponse
|
|||
*/
|
||||
public void sendForbidden(String message) throws IOException
|
||||
{
|
||||
|
||||
throw new UnsupportedOperationException("Not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,8 +24,6 @@ import java.net.URI;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
/**
|
||||
* Connection interface for WebSocket protocol <a href="https://tools.ietf.org/html/rfc6455">RFC-6455</a>.
|
||||
*/
|
||||
|
@ -116,24 +114,17 @@ public interface WebSocketConnection
|
|||
SuspendToken suspend();
|
||||
|
||||
/**
|
||||
* Send a a binary message.
|
||||
* <p>
|
||||
* NIO style with callbacks, allows for concurrent results of the write operation.
|
||||
* Send an async binary message.
|
||||
*/
|
||||
Future<SendResult> write(byte buf[], int offset, int len) throws IOException;
|
||||
Future<WriteResult> write(byte buf[], int offset, int len) throws IOException;
|
||||
|
||||
/**
|
||||
* Send a a binary message.
|
||||
* <p>
|
||||
* NIO style with callbacks, allows for concurrent results of the write operation.
|
||||
* Send an async binary message.
|
||||
*/
|
||||
Future<SendResult> write(ByteBuffer buffer) throws IOException;
|
||||
Future<WriteResult> write(ByteBuffer buffer) throws IOException;
|
||||
|
||||
/**
|
||||
* Send a series of text messages.
|
||||
* <p>
|
||||
* NIO style with callbacks, allows for concurrent results of the entire write operation. (Callback is only called once at the end of processing all of the
|
||||
* messages)
|
||||
* Send an async text messages.
|
||||
*/
|
||||
Future<SendResult> write(String message) throws IOException;
|
||||
Future<WriteResult> write(String message) throws IOException;
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.websocket.api;
|
||||
|
||||
/**
|
||||
* The result of asynchronously sending a web socket message. A WriteResult is either OK indicating there was no problem, or is not OK in which case there was a
|
||||
* problem and it carries an exception to indicate what the problem was.
|
||||
*/
|
||||
public class WriteResult
|
||||
{
|
||||
private Throwable exception;
|
||||
|
||||
/**
|
||||
* Construct a WriteResult signifying a successful send carrying an no exception.
|
||||
*/
|
||||
public WriteResult()
|
||||
{
|
||||
this(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a WriteResult carrying an exception.
|
||||
*
|
||||
* @param exception
|
||||
* the exception causing a send failure.
|
||||
*/
|
||||
public WriteResult(Throwable exception)
|
||||
{
|
||||
this.exception = exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* The problem sending the message.
|
||||
*
|
||||
* @return the problem.
|
||||
*/
|
||||
public Throwable getException()
|
||||
{
|
||||
return this.exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if this result is ok or not.
|
||||
*
|
||||
* @return whether the send was successful or not.
|
||||
*/
|
||||
public boolean isOK()
|
||||
{
|
||||
return (exception == null);
|
||||
}
|
||||
}
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.api.extensions;
|
||||
|
||||
import javax.net.websocket.extensions.FrameHandler;
|
||||
|
||||
/**
|
||||
* Interface for WebSocket Extensions.
|
||||
* <p>
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.nio.ByteBuffer;
|
|||
/**
|
||||
* An immutable websocket frame.
|
||||
*/
|
||||
public interface Frame extends javax.net.websocket.extensions.Frame
|
||||
public interface Frame
|
||||
{
|
||||
public static enum Type
|
||||
{
|
||||
|
@ -108,9 +108,5 @@ public interface Frame extends javax.net.websocket.extensions.Frame
|
|||
|
||||
public boolean isRsv3();
|
||||
|
||||
public void notifySendFailed(Throwable t);
|
||||
|
||||
public void notifySendSuccess();
|
||||
|
||||
public int remaining();
|
||||
}
|
||||
|
|
|
@ -21,12 +21,12 @@ package org.eclipse.jetty.websocket.api.extensions;
|
|||
import java.io.IOException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
|
||||
/**
|
||||
* Interface for dealing with frames outgoing to the network (eventually)
|
||||
*/
|
||||
public interface OutgoingFrames
|
||||
{
|
||||
Future<SendResult> outgoingFrame(Frame frame) throws IOException;
|
||||
Future<WriteResult> outgoingFrame(Frame frame) throws IOException;
|
||||
}
|
||||
|
|
|
@ -22,10 +22,9 @@ import java.io.IOException;
|
|||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.WebSocketConnection;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
|
||||
/**
|
||||
* For working with the {@link WebSocketConnection} in a blocking technique.
|
||||
|
@ -50,8 +49,8 @@ public class WebSocketBlockingConnection
|
|||
{
|
||||
try
|
||||
{
|
||||
Future<SendResult> blocker = conn.write(data,offset,length);
|
||||
SendResult result = blocker.get(); // block till finished
|
||||
Future<WriteResult> blocker = conn.write(data,offset,length);
|
||||
WriteResult result = blocker.get(); // block till finished
|
||||
if (result.getException() != null)
|
||||
{
|
||||
throw new WebSocketException(result.getException());
|
||||
|
@ -76,8 +75,8 @@ public class WebSocketBlockingConnection
|
|||
{
|
||||
try
|
||||
{
|
||||
Future<SendResult> blocker = conn.write(message);
|
||||
SendResult result = blocker.get(); // block till finished
|
||||
Future<WriteResult> blocker = conn.write(message);
|
||||
WriteResult result = blocker.get(); // block till finished
|
||||
if (result.getException() != null)
|
||||
{
|
||||
throw new WebSocketException(result.getException());
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.websocket.client;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.net.websocket.ClientContainer;
|
||||
import javax.net.websocket.ClientEndpointConfiguration;
|
||||
import javax.net.websocket.DeploymentException;
|
||||
import javax.net.websocket.Endpoint;
|
||||
import javax.net.websocket.Session;
|
||||
|
||||
public class JettyClientContainer implements ClientContainer
|
||||
{
|
||||
@Override
|
||||
public void connectToServer(Endpoint endpoint, ClientEndpointConfiguration olc) throws DeploymentException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Session> getActiveSessions()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getInstalledExtensions()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxBinaryMessageBufferSize()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxSessionIdleTimeout()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxTextMessageBufferSize()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxBinaryMessageBufferSize(long max)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxSessionIdleTimeout(long timeout)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxTextMessageBufferSize(long max)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
|
@ -23,9 +23,8 @@ import java.net.InetSocketAddress;
|
|||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
|
||||
import org.eclipse.jetty.websocket.client.WebSocketClientFactory;
|
||||
|
@ -89,7 +88,7 @@ public class WebSocketClientConnection extends AbstractWebSocketConnection
|
|||
};
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
if (frame instanceof WebSocketFrame)
|
||||
{
|
||||
|
|
|
@ -41,8 +41,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
|
@ -51,6 +49,7 @@ import org.eclipse.jetty.util.log.Log;
|
|||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Extension;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
|
@ -211,7 +210,7 @@ public class BlockheadServer
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
ByteBuffer buf = generator.generate(frame);
|
||||
if (LOG.isDebugEnabled())
|
||||
|
|
|
@ -23,10 +23,9 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.StatusCode;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketConnection;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
|
||||
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect;
|
||||
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
|
||||
|
@ -71,7 +70,7 @@ public class SimpleEchoClient
|
|||
this.conn = conn;
|
||||
try
|
||||
{
|
||||
Future<SendResult> fut;
|
||||
Future<WriteResult> fut;
|
||||
fut = conn.write("Hello");
|
||||
fut.get(2,TimeUnit.SECONDS); // wait for send to complete.
|
||||
|
||||
|
|
|
@ -15,10 +15,6 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.drafts</groupId>
|
||||
<artifactId>javax.websocket-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-api</artifactId>
|
||||
|
|
|
@ -22,37 +22,29 @@ import java.util.concurrent.Callable;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import javax.net.websocket.SendHandler;
|
||||
import javax.net.websocket.SendResult;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
|
||||
public class FailedFuture extends FutureTask<SendResult> implements Future<SendResult>
|
||||
public class FailedFuture extends FutureTask<WriteResult> implements Future<WriteResult>
|
||||
{
|
||||
private static class FailedRunner implements Callable<SendResult>
|
||||
private static class FailedRunner implements Callable<WriteResult>
|
||||
{
|
||||
private SendHandler completion;
|
||||
private Throwable error;
|
||||
|
||||
public FailedRunner(SendHandler completion, Throwable error)
|
||||
public FailedRunner(Throwable error)
|
||||
{
|
||||
this.completion = completion;
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendResult call() throws Exception
|
||||
public WriteResult call() throws Exception
|
||||
{
|
||||
SendResult result = new SendResult(this.error);
|
||||
if (completion != null)
|
||||
{
|
||||
completion.setResult(result);
|
||||
}
|
||||
return result;
|
||||
return new WriteResult(this.error);
|
||||
}
|
||||
}
|
||||
|
||||
public FailedFuture(SendHandler completion, Throwable error)
|
||||
public FailedFuture(Throwable error)
|
||||
{
|
||||
super(new FailedRunner(completion,error));
|
||||
super(new FailedRunner(error));
|
||||
run();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,9 +20,6 @@ package org.eclipse.jetty.websocket.common;
|
|||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import javax.net.websocket.SendHandler;
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.websocket.api.ProtocolException;
|
||||
|
@ -107,14 +104,6 @@ public class WebSocketFrame implements Frame
|
|||
private Type type;
|
||||
private boolean continuation = false;
|
||||
private int continuationIndex = 0;
|
||||
/**
|
||||
* Optional operation.
|
||||
* <p>
|
||||
* Hack, should not really be in the WebSocketFrame, send results back to this handler when frame was successfully sent (or not).
|
||||
* <p>
|
||||
* Kept in WebSocketFrame as a result of the [006EDR] of JavaWebSocket API lacking the ability to track this SendHandler through Extensions.
|
||||
*/
|
||||
private SendHandler sendHandler;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
|
@ -278,6 +267,7 @@ public class WebSocketFrame implements Frame
|
|||
return mask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final byte getOpCode()
|
||||
{
|
||||
return opcode;
|
||||
|
@ -333,11 +323,6 @@ public class WebSocketFrame implements Frame
|
|||
return payloadStart;
|
||||
}
|
||||
|
||||
public SendHandler getSendHandler()
|
||||
{
|
||||
return sendHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType()
|
||||
{
|
||||
|
@ -407,26 +392,6 @@ public class WebSocketFrame implements Frame
|
|||
return rsv3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifySendFailed(Throwable t)
|
||||
{
|
||||
if (sendHandler == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
sendHandler.setResult(new SendResult(t));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifySendSuccess()
|
||||
{
|
||||
if (sendHandler == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
sendHandler.setResult(new SendResult(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the position currently within the payload data.
|
||||
* <p>
|
||||
|
@ -633,11 +598,6 @@ public class WebSocketFrame implements Frame
|
|||
return this;
|
||||
}
|
||||
|
||||
public void setSendHandler(SendHandler handler)
|
||||
{
|
||||
this.sendHandler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
@ -655,10 +615,6 @@ public class WebSocketFrame implements Frame
|
|||
b.append(",payloadStart=").append(getPayloadStart());
|
||||
b.append(",remaining=").append(remaining());
|
||||
b.append(",position=").append(position());
|
||||
if (sendHandler != null)
|
||||
{
|
||||
b.append(",sendHandler=").append(sendHandler);
|
||||
}
|
||||
b.append(']');
|
||||
return b.toString();
|
||||
}
|
||||
|
|
|
@ -19,35 +19,26 @@
|
|||
package org.eclipse.jetty.websocket.common;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.EncodeException;
|
||||
import javax.net.websocket.RemoteEndpoint;
|
||||
import javax.net.websocket.SendHandler;
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.api.RemoteEndpoint;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
|
||||
import org.eclipse.jetty.websocket.common.message.MessageOutputStream;
|
||||
import org.eclipse.jetty.websocket.common.message.MessageWriter;
|
||||
|
||||
/**
|
||||
* Endpoint for Writing messages to the Remote websocket.
|
||||
*/
|
||||
public class WebSocketRemoteEndpoint implements RemoteEndpoint<Object>
|
||||
public class WebSocketRemoteEndpoint implements RemoteEndpoint
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(WebSocketRemoteEndpoint.class);
|
||||
public final LogicalConnection connection;
|
||||
public final OutgoingFrames outgoing;
|
||||
public MessageOutputStream stream;
|
||||
public MessageWriter writer;
|
||||
|
||||
public WebSocketRemoteEndpoint(LogicalConnection connection, OutgoingFrames outgoing)
|
||||
{
|
||||
|
@ -64,70 +55,13 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint<Object>
|
|||
return connection.getRemoteAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getSendStream() throws IOException
|
||||
{
|
||||
if (isWriterActive())
|
||||
{
|
||||
throw new IOException("Cannot get OutputStream while Writer is open");
|
||||
}
|
||||
|
||||
if (isStreamActive())
|
||||
{
|
||||
LOG.debug("getSendStream() -> (existing) {}",stream);
|
||||
return stream;
|
||||
}
|
||||
|
||||
stream = new MessageOutputStream(connection,outgoing);
|
||||
LOG.debug("getSendStream() -> (new) {}",stream);
|
||||
return stream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Writer getSendWriter() throws IOException
|
||||
{
|
||||
if (isStreamActive())
|
||||
{
|
||||
throw new IOException("Cannot get Writer while OutputStream is open");
|
||||
}
|
||||
|
||||
if (isWriterActive())
|
||||
{
|
||||
LOG.debug("getSendWriter() -> (existing) {}",writer);
|
||||
return writer;
|
||||
}
|
||||
|
||||
writer = new MessageWriter(connection,outgoing);
|
||||
LOG.debug("getSendWriter() -> (new) {}",writer);
|
||||
return writer;
|
||||
}
|
||||
|
||||
private boolean isStreamActive()
|
||||
{
|
||||
if (stream == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return !stream.isClosed();
|
||||
}
|
||||
|
||||
private boolean isWriterActive()
|
||||
{
|
||||
if (writer == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return !writer.isClosed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal
|
||||
*
|
||||
* @param frame
|
||||
* @return
|
||||
*/
|
||||
private Future<SendResult> sendAsyncFrame(WebSocketFrame frame)
|
||||
private Future<WriteResult> sendAsyncFrame(WebSocketFrame frame)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -136,8 +70,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint<Object>
|
|||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
SendHandler handler = frame.getSendHandler();
|
||||
return new FailedFuture(handler, e);
|
||||
return new FailedFuture(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,19 +82,18 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint<Object>
|
|||
{
|
||||
LOG.debug("sendBytes({})",BufferUtil.toDetailString(data));
|
||||
}
|
||||
Frame frame = WebSocketFrame.binary().setPayload(data);
|
||||
WebSocketFrame frame = WebSocketFrame.binary().setPayload(data);
|
||||
outgoing.outgoingFrame(frame);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> sendBytes(ByteBuffer data, SendHandler completion)
|
||||
public Future<WriteResult> sendBytesByFuture(ByteBuffer data)
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("sendBytes({}, {})",BufferUtil.toDetailString(data),completion);
|
||||
LOG.debug("sendBytesByFuture({})",BufferUtil.toDetailString(data));
|
||||
}
|
||||
WebSocketFrame frame = WebSocketFrame.binary().setPayload(data);
|
||||
frame.setSendHandler(completion);
|
||||
return sendAsyncFrame(frame);
|
||||
}
|
||||
|
||||
|
@ -178,28 +110,23 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint<Object>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendObject(Object o) throws IOException, EncodeException
|
||||
public void sendPartialBytes(ByteBuffer fragment, boolean isLast) throws IOException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> sendObject(Object o, SendHandler handler)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPartialBytes(ByteBuffer partialByte, boolean isLast) throws IOException
|
||||
{
|
||||
Frame frame = WebSocketFrame.binary().setPayload(partialByte).setFin(isLast);
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("sendPartialBytes({}, {})",BufferUtil.toDetailString(fragment),isLast);
|
||||
}
|
||||
Frame frame = WebSocketFrame.binary().setPayload(fragment).setFin(isLast);
|
||||
outgoing.outgoingFrame(frame);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPartialString(String fragment, boolean isLast) throws IOException
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("sendPartialString({}, {})",fragment,isLast);
|
||||
}
|
||||
Frame frame = WebSocketFrame.text(fragment).setFin(isLast);
|
||||
outgoing.outgoingFrame(frame);
|
||||
}
|
||||
|
@ -234,10 +161,9 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint<Object>
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> sendString(String text, SendHandler completion)
|
||||
public Future<WriteResult> sendStringByFuture(String text)
|
||||
{
|
||||
WebSocketFrame frame = WebSocketFrame.text(text);
|
||||
frame.setSendHandler(completion);
|
||||
return sendAsyncFrame(frame);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,23 +23,11 @@ import java.net.InetSocketAddress;
|
|||
import java.net.URI;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.ClientContainer;
|
||||
import javax.net.websocket.CloseReason;
|
||||
import javax.net.websocket.ContainerProvider;
|
||||
import javax.net.websocket.Encoder;
|
||||
import javax.net.websocket.MessageHandler;
|
||||
import javax.net.websocket.RemoteEndpoint;
|
||||
import javax.net.websocket.SendResult;
|
||||
import javax.net.websocket.Session;
|
||||
|
||||
import org.eclipse.jetty.util.MultiMap;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.UrlEncoded;
|
||||
|
@ -49,10 +37,14 @@ import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
|||
import org.eclipse.jetty.util.component.Dumpable;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.api.CloseStatus;
|
||||
import org.eclipse.jetty.websocket.api.RemoteEndpoint;
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
import org.eclipse.jetty.websocket.api.SuspendToken;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketConnection;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionFactory;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
|
||||
|
@ -60,14 +52,12 @@ import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
|
|||
import org.eclipse.jetty.websocket.common.events.EventDriver;
|
||||
|
||||
@ManagedObject
|
||||
public class WebSocketSession extends ContainerLifeCycle implements Session<Object>, WebSocketConnection, IncomingFrames
|
||||
public class WebSocketSession extends ContainerLifeCycle implements Session, WebSocketConnection, IncomingFrames
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(WebSocketSession.class);
|
||||
private final URI requestURI;
|
||||
private final EventDriver websocket;
|
||||
private final LogicalConnection connection;
|
||||
private Set<MessageHandler> messageHandlers = new HashSet<>();
|
||||
private List<Encoder> encoders = new ArrayList<>();
|
||||
private ExtensionFactory extensionFactory;
|
||||
private boolean active = false;
|
||||
private long maximumMessageSize;
|
||||
|
@ -112,12 +102,6 @@ public class WebSocketSession extends ContainerLifeCycle implements Session<Obje
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessageHandler(MessageHandler listener)
|
||||
{
|
||||
messageHandlers.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException
|
||||
{
|
||||
|
@ -125,9 +109,9 @@ public class WebSocketSession extends ContainerLifeCycle implements Session<Obje
|
|||
}
|
||||
|
||||
@Override
|
||||
public void close(CloseReason closeStatus) throws IOException
|
||||
public void close(CloseStatus closeStatus) throws IOException
|
||||
{
|
||||
connection.close(closeStatus.getCloseCode().getCode(),closeStatus.getReasonPhrase());
|
||||
connection.close(closeStatus.getCode(),closeStatus.getPhrase());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -166,23 +150,11 @@ public class WebSocketSession extends ContainerLifeCycle implements Session<Obje
|
|||
return connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientContainer getContainer()
|
||||
{
|
||||
return ContainerProvider.getClientContainer();
|
||||
}
|
||||
|
||||
public ExtensionFactory getExtensionFactory()
|
||||
{
|
||||
return extensionFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getInactiveTime()
|
||||
{
|
||||
return inactiveTime;
|
||||
}
|
||||
|
||||
@ManagedAttribute(readonly = true)
|
||||
public IncomingFrames getIncomingHandler()
|
||||
{
|
||||
|
@ -201,12 +173,6 @@ public class WebSocketSession extends ContainerLifeCycle implements Session<Obje
|
|||
return maximumMessageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<MessageHandler> getMessageHandlers()
|
||||
{
|
||||
return Collections.unmodifiableSet(messageHandlers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNegotiatedExtensions()
|
||||
{
|
||||
|
@ -225,12 +191,6 @@ public class WebSocketSession extends ContainerLifeCycle implements Session<Obje
|
|||
return outgoingHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String[]> getParameterMap()
|
||||
{
|
||||
return parameterMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebSocketPolicy getPolicy()
|
||||
{
|
||||
|
@ -250,7 +210,7 @@ public class WebSocketSession extends ContainerLifeCycle implements Session<Obje
|
|||
}
|
||||
|
||||
@Override
|
||||
public RemoteEndpoint<Object> getRemote()
|
||||
public RemoteEndpoint getRemote()
|
||||
{
|
||||
if (!isOpen())
|
||||
{
|
||||
|
@ -259,13 +219,6 @@ public class WebSocketSession extends ContainerLifeCycle implements Session<Obje
|
|||
return remote;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoteEndpoint<Object> getRemote(Class<Object> c)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getRemoteAddress()
|
||||
{
|
||||
|
@ -374,27 +327,11 @@ public class WebSocketSession extends ContainerLifeCycle implements Session<Obje
|
|||
remote.sendPing(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMessageHandler(MessageHandler listener)
|
||||
{
|
||||
messageHandlers.remove(listener);
|
||||
}
|
||||
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEncoders(List<Encoder> encoders)
|
||||
{
|
||||
this.encoders.clear();
|
||||
if (encoders != null)
|
||||
{
|
||||
encoders.addAll(encoders);
|
||||
}
|
||||
}
|
||||
|
||||
public void setExtensionFactory(ExtensionFactory extensionFactory)
|
||||
{
|
||||
this.extensionFactory = extensionFactory;
|
||||
|
@ -458,20 +395,20 @@ public class WebSocketSession extends ContainerLifeCycle implements Session<Obje
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> write(byte[] buf, int offset, int len) throws IOException
|
||||
public Future<WriteResult> write(byte[] buf, int offset, int len) throws IOException
|
||||
{
|
||||
return remote.sendBytes(ByteBuffer.wrap(buf,offset,len),null);
|
||||
return remote.sendBytesByFuture(ByteBuffer.wrap(buf,offset,len));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> write(ByteBuffer buffer) throws IOException
|
||||
public Future<WriteResult> write(ByteBuffer buffer) throws IOException
|
||||
{
|
||||
return remote.sendBytes(buffer,null);
|
||||
return remote.sendBytesByFuture(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> write(String message) throws IOException
|
||||
public Future<WriteResult> write(String message) throws IOException
|
||||
{
|
||||
return remote.sendString(message,null);
|
||||
return remote.sendStringByFuture(message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,6 @@ package org.eclipse.jetty.websocket.common.extensions;
|
|||
import java.io.IOException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
|
@ -31,6 +29,7 @@ import org.eclipse.jetty.util.log.Log;
|
|||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Extension;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
|
@ -182,7 +181,7 @@ public abstract class AbstractExtension extends ContainerLifeCycle implements Ex
|
|||
this.nextIncoming.incomingFrame(frame);
|
||||
}
|
||||
|
||||
protected Future<SendResult> nextOutgoingFrame(Frame frame) throws IOException
|
||||
protected Future<WriteResult> nextOutgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
log.debug("nextOutgoingFrame({})",frame);
|
||||
return this.nextOutgoing.outgoingFrame(frame);
|
||||
|
|
|
@ -24,14 +24,13 @@ import java.util.List;
|
|||
import java.util.ListIterator;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.util.annotation.ManagedAttribute;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.component.ContainerLifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Extension;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionFactory;
|
||||
|
@ -223,7 +222,7 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
return nextOutgoing.outgoingFrame(frame);
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@ import java.io.IOException;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.common.WebSocketFrame;
|
||||
|
@ -95,7 +94,7 @@ public class FrameCompressionExtension extends AbstractExtension
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
if (frame.getType().isControl())
|
||||
{
|
||||
|
@ -103,7 +102,7 @@ public class FrameCompressionExtension extends AbstractExtension
|
|||
return nextOutgoingFrame(frame);
|
||||
}
|
||||
|
||||
Future<SendResult> future = null;
|
||||
Future<WriteResult> future = null;
|
||||
|
||||
ByteBuffer data = frame.getPayload();
|
||||
try
|
||||
|
|
|
@ -23,10 +23,9 @@ import java.io.IOException;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.common.WebSocketFrame;
|
||||
|
@ -103,7 +102,7 @@ public class MessageCompressionExtension extends AbstractExtension
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
if (frame.getType().isControl())
|
||||
{
|
||||
|
@ -111,7 +110,7 @@ public class MessageCompressionExtension extends AbstractExtension
|
|||
return nextOutgoingFrame(frame);
|
||||
}
|
||||
|
||||
Future<SendResult> future = null;
|
||||
Future<WriteResult> future = null;
|
||||
|
||||
ByteBuffer data = frame.getPayload();
|
||||
try
|
||||
|
|
|
@ -23,9 +23,8 @@ import java.io.IOException;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.common.OpCode;
|
||||
|
@ -54,7 +53,7 @@ public class FragmentExtension extends AbstractExtension
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
if (frame.getType().isControl())
|
||||
{
|
||||
|
|
|
@ -21,11 +21,10 @@ package org.eclipse.jetty.websocket.common.extensions.identity;
|
|||
import java.io.IOException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.util.QuotedStringTokenizer;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.common.extensions.AbstractExtension;
|
||||
|
@ -55,7 +54,7 @@ public class IdentityExtension extends AbstractExtension
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
// pass through
|
||||
return nextOutgoingFrame(frame);
|
||||
|
|
|
@ -21,8 +21,7 @@ package org.eclipse.jetty.websocket.common.extensions.mux;
|
|||
import java.io.IOException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.common.LogicalConnection;
|
||||
import org.eclipse.jetty.websocket.common.extensions.AbstractExtension;
|
||||
|
@ -50,7 +49,7 @@ public abstract class AbstractMuxExtension extends AbstractExtension
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
/* do nothing */
|
||||
return null;
|
||||
|
|
|
@ -25,8 +25,6 @@ import java.nio.ByteBuffer;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.api.StatusCode;
|
||||
|
@ -34,6 +32,7 @@ import org.eclipse.jetty.websocket.api.SuspendToken;
|
|||
import org.eclipse.jetty.websocket.api.WebSocketConnection;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
|
||||
import org.eclipse.jetty.websocket.common.CloseInfo;
|
||||
|
@ -256,7 +255,7 @@ public class MuxChannel implements WebSocketConnection, LogicalConnection, Incom
|
|||
* Frames destined for the Muxer
|
||||
*/
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
return muxer.output(channelId,frame);
|
||||
}
|
||||
|
@ -309,7 +308,7 @@ public class MuxChannel implements WebSocketConnection, LogicalConnection, Incom
|
|||
* Generate a binary message, destined for Muxer
|
||||
*/
|
||||
@Override
|
||||
public Future<SendResult> write(byte[] buf, int offset, int len) throws IOException
|
||||
public Future<WriteResult> write(byte[] buf, int offset, int len) throws IOException
|
||||
{
|
||||
return outgoingFrame(WebSocketFrame.binary().setPayload(buf,offset,len));
|
||||
}
|
||||
|
@ -318,7 +317,7 @@ public class MuxChannel implements WebSocketConnection, LogicalConnection, Incom
|
|||
* Generate a binary message, destined for Muxer
|
||||
*/
|
||||
@Override
|
||||
public Future<SendResult> write(ByteBuffer buffer) throws IOException
|
||||
public Future<WriteResult> write(ByteBuffer buffer) throws IOException
|
||||
{
|
||||
return outgoingFrame(WebSocketFrame.binary().setPayload(buffer));
|
||||
}
|
||||
|
@ -327,7 +326,7 @@ public class MuxChannel implements WebSocketConnection, LogicalConnection, Incom
|
|||
* Generate a text message, destined for Muxer
|
||||
*/
|
||||
@Override
|
||||
public Future<SendResult> write(String message) throws IOException
|
||||
public Future<WriteResult> write(String message) throws IOException
|
||||
{
|
||||
return outgoingFrame(WebSocketFrame.text(message));
|
||||
}
|
||||
|
|
|
@ -22,11 +22,10 @@ import java.io.IOException;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.io.ArrayByteBufferPool;
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
|
||||
import org.eclipse.jetty.websocket.common.WebSocketFrame;
|
||||
|
@ -57,7 +56,7 @@ public class MuxGenerator
|
|||
this.bufferPool = bufferPool;
|
||||
}
|
||||
|
||||
public Future<SendResult> generate(long channelId, Frame frame) throws IOException
|
||||
public Future<WriteResult> generate(long channelId, Frame frame) throws IOException
|
||||
{
|
||||
ByteBuffer muxPayload = bufferPool.acquire(frame.getPayloadLength() + DATA_FRAME_OVERHEAD,false);
|
||||
BufferUtil.flipToFill(muxPayload);
|
||||
|
|
|
@ -25,8 +25,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
@ -36,6 +34,7 @@ import org.eclipse.jetty.websocket.api.UpgradeResponse;
|
|||
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
|
||||
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
|
||||
|
@ -385,7 +384,7 @@ public class Muxer implements IncomingFrames, MuxParser.Listener
|
|||
/**
|
||||
* Outgoing frame, without mux encapsulated payload.
|
||||
*/
|
||||
public Future<SendResult> output(long channelId, Frame frame) throws IOException
|
||||
public Future<WriteResult> output(long channelId, Frame frame) throws IOException
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
|
|
|
@ -28,8 +28,6 @@ import java.util.concurrent.Future;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.io.AbstractConnection;
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.Connection;
|
||||
|
@ -43,6 +41,7 @@ import org.eclipse.jetty.websocket.api.StatusCode;
|
|||
import org.eclipse.jetty.websocket.api.SuspendToken;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketConnection;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.common.CloseInfo;
|
||||
|
@ -393,14 +392,14 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("outgoingFrame({})",frame);
|
||||
}
|
||||
|
||||
Future<SendResult> future = null;
|
||||
Future<WriteResult> future = null;
|
||||
|
||||
synchronized (queue)
|
||||
{
|
||||
|
@ -415,7 +414,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
bytes = new DataFrameBytes(this,frame);
|
||||
}
|
||||
|
||||
future = new JavaxWebsocketFuture(bytes);
|
||||
future = new WriteResultFuture(bytes);
|
||||
|
||||
scheduleTimeout(bytes);
|
||||
|
||||
|
|
|
@ -51,19 +51,6 @@ public abstract class FrameBytes extends FutureCallback implements Runnable
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
{
|
||||
super.succeeded();
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("completed() - {}",this.getClass().getName());
|
||||
}
|
||||
cancelTask();
|
||||
connection.complete(this);
|
||||
frame.notifySendSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable x)
|
||||
{
|
||||
|
@ -78,7 +65,6 @@ public abstract class FrameBytes extends FutureCallback implements Runnable
|
|||
LOG.warn("failed()",x);
|
||||
}
|
||||
cancelTask();
|
||||
frame.notifySendFailed(x);
|
||||
}
|
||||
|
||||
public abstract ByteBuffer getByteBuffer();
|
||||
|
@ -91,6 +77,18 @@ public abstract class FrameBytes extends FutureCallback implements Runnable
|
|||
failed(new InterruptedByTimeoutException());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeeded()
|
||||
{
|
||||
super.succeeded();
|
||||
if (LOG.isDebugEnabled())
|
||||
{
|
||||
LOG.debug("completed() - {}",this.getClass().getName());
|
||||
}
|
||||
cancelTask();
|
||||
connection.complete(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
|
|
@ -21,11 +21,10 @@ package org.eclipse.jetty.websocket.common.io;
|
|||
import java.io.IOException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
|
||||
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
|
||||
|
@ -72,7 +71,7 @@ public class FramePipes
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
this.incoming.incomingFrame(frame);
|
||||
|
||||
|
|
|
@ -23,13 +23,13 @@ import java.util.concurrent.Future;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
|
||||
public class JavaxWebsocketFuture implements Future<SendResult>
|
||||
public class WriteResultFuture implements Future<WriteResult>
|
||||
{
|
||||
private final FrameBytes bytes;
|
||||
|
||||
public JavaxWebsocketFuture(FrameBytes bytes)
|
||||
public WriteResultFuture(FrameBytes bytes)
|
||||
{
|
||||
this.bytes = bytes;
|
||||
}
|
||||
|
@ -41,30 +41,30 @@ public class JavaxWebsocketFuture implements Future<SendResult>
|
|||
}
|
||||
|
||||
@Override
|
||||
public SendResult get() throws InterruptedException, ExecutionException
|
||||
public WriteResult get() throws InterruptedException, ExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
bytes.get();
|
||||
return new SendResult();
|
||||
return new WriteResult();
|
||||
}
|
||||
catch (ExecutionException e)
|
||||
{
|
||||
return new SendResult(e.getCause());
|
||||
return new WriteResult(e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SendResult get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
|
||||
public WriteResult get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
try
|
||||
{
|
||||
bytes.get(timeout,unit);
|
||||
return new SendResult();
|
||||
return new WriteResult();
|
||||
}
|
||||
catch (ExecutionException e)
|
||||
{
|
||||
return new SendResult(e.getCause());
|
||||
return new WriteResult(e.getCause());
|
||||
}
|
||||
}
|
||||
|
|
@ -23,11 +23,10 @@ import java.util.concurrent.Future;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.WebSocketConnection;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketListener;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
|
||||
/**
|
||||
* Example EchoSocket using Listener.
|
||||
|
@ -72,7 +71,7 @@ public class ListenerEchoSocket implements WebSocketListener
|
|||
try
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
Future<SendResult> future = outbound.write(message);
|
||||
Future<WriteResult> future = outbound.write(message);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
|
|
@ -22,20 +22,20 @@ import java.util.concurrent.Callable;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
|
||||
public class FinishedFuture extends FutureTask<SendResult> implements Future<SendResult>
|
||||
public class FinishedFuture extends FutureTask<WriteResult> implements Future<WriteResult>
|
||||
{
|
||||
public static Future<SendResult> INSTANCE;
|
||||
public static Future<WriteResult> INSTANCE;
|
||||
|
||||
static
|
||||
{
|
||||
Callable<SendResult> callable = new Callable<SendResult>()
|
||||
Callable<WriteResult> callable = new Callable<WriteResult>()
|
||||
{
|
||||
@Override
|
||||
public SendResult call() throws Exception
|
||||
public WriteResult call() throws Exception
|
||||
{
|
||||
return new SendResult();
|
||||
return new WriteResult();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class FinishedFuture extends FutureTask<SendResult> implements Future<Sen
|
|||
INSTANCE = fut;
|
||||
}
|
||||
|
||||
public FinishedFuture(Callable<SendResult> callable)
|
||||
public FinishedFuture(Callable<WriteResult> callable)
|
||||
{
|
||||
super(callable);
|
||||
}
|
||||
|
|
|
@ -23,9 +23,8 @@ import static org.hamcrest.Matchers.*;
|
|||
import java.util.LinkedList;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
|
||||
import org.junit.Assert;
|
||||
|
@ -84,7 +83,7 @@ public class OutgoingFramesCapture implements OutgoingFrames
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame)
|
||||
public Future<WriteResult> outgoingFrame(Frame frame)
|
||||
{
|
||||
WebSocketFrame copy = new WebSocketFrame(frame);
|
||||
frames.add(copy);
|
||||
|
|
|
@ -27,10 +27,9 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
|
||||
import org.junit.Assert;
|
||||
|
@ -63,7 +62,7 @@ public class OutgoingNetworkBytesCapture implements OutgoingFrames
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
ByteBuffer buf = generator.generate(frame);
|
||||
captured.add(buf.slice());
|
||||
|
|
|
@ -21,10 +21,9 @@ package org.eclipse.jetty.websocket.common.extensions;
|
|||
import java.io.IOException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
|
||||
import org.eclipse.jetty.websocket.common.FinishedFuture;
|
||||
|
@ -43,7 +42,7 @@ public class DummyOutgoingFrames implements OutgoingFrames
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
LOG.debug("outgoingFrame({})",frame);
|
||||
return FinishedFuture.INSTANCE;
|
||||
|
|
|
@ -21,8 +21,7 @@ package org.eclipse.jetty.websocket.common.extensions.mux;
|
|||
import java.io.IOException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
|
||||
|
||||
|
@ -42,7 +41,7 @@ public class MuxDecoder extends MuxEventCapture implements OutgoingFrames
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
parser.parse(frame);
|
||||
return null; // FIXME: should return completed future.
|
||||
|
|
|
@ -24,12 +24,11 @@ import java.net.URI;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.websocket.api.SuspendToken;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketConnection;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
|
||||
import org.eclipse.jetty.websocket.common.CloseInfo;
|
||||
|
@ -181,7 +180,7 @@ public class LocalWebSocketConnection implements WebSocketConnection, LogicalCon
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -225,19 +224,19 @@ public class LocalWebSocketConnection implements WebSocketConnection, LogicalCon
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> write(byte[] buf, int offset, int len) throws IOException
|
||||
public Future<WriteResult> write(byte[] buf, int offset, int len) throws IOException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> write(ByteBuffer buffer) throws IOException
|
||||
public Future<WriteResult> write(ByteBuffer buffer) throws IOException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> write(String message) throws IOException
|
||||
public Future<WriteResult> write(String message) throws IOException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,100 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.websocket.server;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.net.websocket.ClientEndpointConfiguration;
|
||||
import javax.net.websocket.DeploymentException;
|
||||
import javax.net.websocket.Endpoint;
|
||||
import javax.net.websocket.ServerContainer;
|
||||
import javax.net.websocket.ServerEndpointConfiguration;
|
||||
import javax.net.websocket.Session;
|
||||
|
||||
public class JettyServerContainer implements ServerContainer
|
||||
{
|
||||
@Override
|
||||
public void publishServer(Endpoint endpoint, ServerEndpointConfiguration ilc)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectToServer(Endpoint endpoint, ClientEndpointConfiguration olc) throws DeploymentException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Session> getActiveSessions()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getInstalledExtensions()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxBinaryMessageBufferSize()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxSessionIdleTimeout()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxTextMessageBufferSize()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxBinaryMessageBufferSize(long max)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxSessionIdleTimeout(long timeout)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxTextMessageBufferSize(long max)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
|
@ -43,7 +43,6 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.io.ByteBufferPool;
|
||||
import org.eclipse.jetty.io.MappedByteBufferPool;
|
||||
|
@ -55,6 +54,7 @@ import org.eclipse.jetty.util.log.Log;
|
|||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketException;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
|
||||
|
@ -358,7 +358,7 @@ public class BlockheadClient implements IncomingFrames, OutgoingFrames
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
ByteBuffer buf = generator.generate(frame);
|
||||
if (LOG.isDebugEnabled())
|
||||
|
|
|
@ -22,20 +22,20 @@ import java.util.concurrent.Callable;
|
|||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
|
||||
public class FinishedFuture extends FutureTask<SendResult> implements Future<SendResult>
|
||||
public class FinishedFuture extends FutureTask<WriteResult> implements Future<WriteResult>
|
||||
{
|
||||
public static Future<SendResult> INSTANCE;
|
||||
public static Future<WriteResult> INSTANCE;
|
||||
|
||||
static
|
||||
{
|
||||
Callable<SendResult> callable = new Callable<SendResult>()
|
||||
Callable<WriteResult> callable = new Callable<WriteResult>()
|
||||
{
|
||||
@Override
|
||||
public SendResult call() throws Exception
|
||||
public WriteResult call() throws Exception
|
||||
{
|
||||
return new SendResult();
|
||||
return new WriteResult();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class FinishedFuture extends FutureTask<SendResult> implements Future<Sen
|
|||
INSTANCE = fut;
|
||||
}
|
||||
|
||||
public FinishedFuture(Callable<SendResult> callable)
|
||||
public FinishedFuture(Callable<WriteResult> callable)
|
||||
{
|
||||
super(callable);
|
||||
}
|
||||
|
|
|
@ -24,10 +24,9 @@ import java.io.IOException;
|
|||
import java.util.LinkedList;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import javax.net.websocket.SendResult;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.util.Callback;
|
||||
import org.eclipse.jetty.websocket.api.WriteResult;
|
||||
import org.eclipse.jetty.websocket.api.extensions.Frame;
|
||||
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
|
||||
import org.eclipse.jetty.websocket.common.OpCode;
|
||||
|
@ -94,7 +93,7 @@ public class OutgoingFramesCapture implements OutgoingFrames
|
|||
}
|
||||
|
||||
@Override
|
||||
public Future<SendResult> outgoingFrame(Frame frame) throws IOException
|
||||
public Future<WriteResult> outgoingFrame(Frame frame) throws IOException
|
||||
{
|
||||
WebSocketFrame copy = new WebSocketFrame(frame);
|
||||
frames.add(copy);
|
||||
|
|
9
pom.xml
9
pom.xml
|
@ -156,6 +156,8 @@
|
|||
<!-- allowed combinations -->
|
||||
<includes>
|
||||
<include>org.apache.geronimo.specs:geronimo-atinject_1.0_spec:jar:*</include>
|
||||
<include>javax.net.websocket:*:*:*</include>
|
||||
<include>javax.websocket:*:*:*</include>
|
||||
<include>javax.servlet:*:*:*:provided</include>
|
||||
<include>javax.servlet.jsp:*:*:*:provided</include>
|
||||
</includes>
|
||||
|
@ -496,13 +498,6 @@
|
|||
</dependency>
|
||||
-->
|
||||
|
||||
<!-- Draft Deps -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.drafts</groupId>
|
||||
<artifactId>javax.websocket-api</artifactId>
|
||||
<version>0.0.006.draft</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Old Deps -->
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
|
|
Loading…
Reference in New Issue