diff options
author | Kevin Smith <git@kismith.co.uk> | 2011-07-01 09:19:49 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2011-07-01 09:19:49 (GMT) |
commit | 2da71a8a85486a494343f1662d64fb5ae5a2a44e (patch) | |
tree | 23992f9f2a00bac23b345e5c2cc9c1194efc25be /src/com/isode/stroke/streamstack/ConnectionLayer.java | |
download | stroke-2da71a8a85486a494343f1662d64fb5ae5a2a44e.zip stroke-2da71a8a85486a494343f1662d64fb5ae5a2a44e.tar.bz2 |
Initial import
Diffstat (limited to 'src/com/isode/stroke/streamstack/ConnectionLayer.java')
-rw-r--r-- | src/com/isode/stroke/streamstack/ConnectionLayer.java | 58 |
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); + } +} |