summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/isode/stroke/streamstack/ConnectionLayer.java')
-rw-r--r--src/com/isode/stroke/streamstack/ConnectionLayer.java58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/com/isode/stroke/streamstack/ConnectionLayer.java b/src/com/isode/stroke/streamstack/ConnectionLayer.java
new file mode 100644
index 0000000..525da50
--- /dev/null
+++ b/src/com/isode/stroke/streamstack/ConnectionLayer.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2010 Remko Tron¨on
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+/*
+ * Copyright (c) 2010, Isode Limited, London, England.
+ * All rights reserved.
+ */
+package com.isode.stroke.streamstack;
+
+import com.isode.stroke.base.ByteArray;
+import com.isode.stroke.network.Connection;
+import com.isode.stroke.signals.Signal1;
+import com.isode.stroke.signals.Slot1;
+
+public class ConnectionLayer implements LowLayer {
+
+ public ConnectionLayer(Connection connection) {
+ this.connection = connection;
+ connection.onDataRead.connect(new Slot1<ByteArray>() {
+
+ public void call(ByteArray p1) {
+ writeDataToParentLayer(p1);
+ }
+ });
+ }
+
+ public void writeData(ByteArray data) {
+ connection.write(data);
+ }
+
+ private Connection connection;
+
+ /* Work around multiple inheritance workaround again */
+ StreamLayer fakeStreamLayer_ = new StreamLayer() {
+
+ public void writeData(ByteArray data) {
+ connection.write(data);
+ }
+
+ public void handleDataRead(ByteArray data) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ };
+
+ public HighLayer getParentLayer() {
+ return fakeStreamLayer_.getParentLayer();
+ }
+
+ public void setParentLayer(HighLayer parentLayer) {
+ fakeStreamLayer_.setParentLayer(parentLayer);
+ }
+
+ public void writeDataToParentLayer(ByteArray data) {
+ fakeStreamLayer_.writeDataToParentLayer(data);
+ }
+}