You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2012/12/12 22:08:13 UTC
svn commit: r1420971 - in /tomcat/trunk/java/org/apache/tomcat/websocket:
WsProtocolHandler.java WsRemoteEndpoint.java WsSession.java
Author: markt
Date: Wed Dec 12 21:08:11 2012
New Revision: 1420971
URL: http://svn.apache.org/viewvc?rev=1420971&view=rev
Log:
WebSocket 1.0 implementation part 14 of many
Add a RemoteEndpoint implementation (just stubs)
Add the plumbing between the WsProtocolHandler and the RemoteEndpoint implementation.
Added:
tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpoint.java (with props)
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/WsProtocolHandler.java
tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsProtocolHandler.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsProtocolHandler.java?rev=1420971&r1=1420970&r2=1420971&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsProtocolHandler.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsProtocolHandler.java Wed Dec 12 21:08:11 2012
@@ -64,7 +64,9 @@ public class WsProtocolHandler implement
}
WsFrame wsFrame = new WsFrame(sis, wsSession);
sis.setReadListener(new WsReadListener(this, wsFrame));
- sos.setWriteListener(new WsWriteListener(this));
+ WsRemoteEndpoint wsRemoteEndpoint = new WsRemoteEndpoint(sos);
+ wsSession.setRemote(wsRemoteEndpoint);
+ sos.setWriteListener(new WsWriteListener(this, wsRemoteEndpoint));
}
@@ -119,16 +121,18 @@ public class WsProtocolHandler implement
private static class WsWriteListener implements WriteListener {
private final WsProtocolHandler wsProtocolHandler;
+ private final WsRemoteEndpoint wsRemoteEndpoint;
-
- private WsWriteListener(WsProtocolHandler wsProtocolHandler) {
+ private WsWriteListener(WsProtocolHandler wsProtocolHandler,
+ WsRemoteEndpoint wsRemoteEndpoint) {
this.wsProtocolHandler = wsProtocolHandler;
+ this.wsRemoteEndpoint = wsRemoteEndpoint;
}
@Override
public void onWritePossible() {
- // TODO Auto-generated method stub
+ wsRemoteEndpoint.onWritePossible();
}
Added: tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpoint.java?rev=1420971&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpoint.java (added)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpoint.java Wed Dec 12 21:08:11 2012
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.websocket;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.nio.ByteBuffer;
+import java.util.concurrent.Future;
+
+import javax.servlet.ServletOutputStream;
+import javax.websocket.EncodeException;
+import javax.websocket.RemoteEndpoint;
+import javax.websocket.SendHandler;
+import javax.websocket.SendResult;
+
+public class WsRemoteEndpoint implements RemoteEndpoint {
+
+ private final ServletOutputStream sos;
+
+ public WsRemoteEndpoint(ServletOutputStream sos) {
+ this.sos = sos;
+ }
+
+ public void onWritePossible() {
+ // TODO
+ }
+
+ @Override
+ public void sendString(String text) throws IOException {
+ // TODO Auto-generated method stub
+ }
+
+
+ @Override
+ public void sendBytes(ByteBuffer data) throws IOException {
+ // TODO Auto-generated method stub
+ }
+
+
+ @Override
+ public void sendPartialString(String fragment, boolean isLast)
+ throws IOException {
+ // TODO Auto-generated method stub
+ }
+
+
+ @Override
+ public void sendPartialBytes(ByteBuffer partialByte, boolean isLast)
+ throws IOException {
+ // TODO Auto-generated method stub
+ }
+
+
+ @Override
+ public OutputStream getSendStream() throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ @Override
+ public Writer getSendWriter() throws IOException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ @Override
+ public void sendObject(Object o) throws IOException, EncodeException {
+ // TODO Auto-generated method stub
+ }
+
+
+ @Override
+ public void sendStringByCompletion(String text, SendHandler completion) {
+ // TODO Auto-generated method stub
+ }
+
+
+ @Override
+ public Future<SendResult> sendStringByFuture(String text) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ @Override
+ public Future<SendResult> sendBytesByFuture(ByteBuffer data) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ @Override
+ public void sendBytesByCompletion(ByteBuffer data, SendHandler completion) {
+ // TODO Auto-generated method stub
+ }
+
+
+ @Override
+ public Future<SendResult> sendObjectByFuture(Object obj) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ @Override
+ public void sendObjectByCompletion(Object obj, SendHandler completion) {
+ // TODO Auto-generated method stub
+ }
+
+
+ @Override
+ public void sendPing(ByteBuffer applicationData) {
+ // TODO Auto-generated method stub
+ }
+
+
+ @Override
+ public void sendPong(ByteBuffer applicationData) {
+ // TODO Auto-generated method stub
+ }
+}
Propchange: tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpoint.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java?rev=1420971&r1=1420970&r2=1420971&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java Wed Dec 12 21:08:11 2012
@@ -37,12 +37,12 @@ import javax.websocket.Session;
public class WsSession implements Session {
+ private final Endpoint localEndpoint;
+ private RemoteEndpoint remoteEndpoint;
private MessageHandler textMessageHandler = null;
private MessageHandler binaryMessageHandler = null;
- private MessageHandler.Basic<PongMessage> pongMessageHandler = new DefaultPingMessageHandler(
- this);
- private final Endpoint localEndpoint;
-
+ private MessageHandler.Basic<PongMessage> pongMessageHandler =
+ new DefaultPingMessageHandler(this);
public WsSession(Endpoint localEndpoint) {
this.localEndpoint = localEndpoint;
@@ -196,8 +196,7 @@ public class WsSession implements Sessio
@Override
public RemoteEndpoint getRemote() {
- // TODO Auto-generated method stub
- return null;
+ return remoteEndpoint;
}
@@ -249,6 +248,11 @@ public class WsSession implements Sessio
}
+ public void setRemote(WsRemoteEndpoint remoteEndpoint) {
+ this.remoteEndpoint = remoteEndpoint;
+ }
+
+
public MessageHandler getTextMessageHandler() {
return textMessageHandler;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org