Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2011-10-24 19:12:00 -0400
committerEugene Tarassov2011-10-24 19:12:00 -0400
commit7f3d8e481000767f8efee8fc150cd4c7c19c7abc (patch)
tree568d1331d819d4015ea0e556d6d9ce6fc17001f9 /plugins/org.eclipse.tm.tcf.core
parent0f74445bccab6162ce52702e6504fa9ca3dd5add (diff)
downloadorg.eclipse.tcf-7f3d8e481000767f8efee8fc150cd4c7c19c7abc.tar.gz
org.eclipse.tcf-7f3d8e481000767f8efee8fc150cd4c7c19c7abc.tar.xz
org.eclipse.tcf-7f3d8e481000767f8efee8fc150cd4c7c19c7abc.zip
TCF Core: fixed: IStreams service proxy calls all listeners on every "created" instead of calling right listener according to the stream type.
Diffstat (limited to 'plugins/org.eclipse.tm.tcf.core')
-rw-r--r--plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/StreamsProxy.java40
1 files changed, 22 insertions, 18 deletions
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/StreamsProxy.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/StreamsProxy.java
index 268cb8ad6..dea9b6f90 100644
--- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/StreamsProxy.java
+++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/StreamsProxy.java
@@ -23,8 +23,8 @@ import org.eclipse.tm.tcf.services.IStreams;
public class StreamsProxy implements IStreams {
private final IChannel channel;
- private final Map<StreamsListener,IChannel.IEventListener> listeners =
- new HashMap<StreamsListener,IChannel.IEventListener>();
+ private final Map<String,IChannel.IEventListener> listeners =
+ new HashMap<String,IChannel.IEventListener>();
public StreamsProxy(IChannel channel) {
this.channel = channel;
@@ -88,7 +88,7 @@ public class StreamsProxy implements IStreams {
}.token;
}
- public IToken subscribe(String stream_type, final StreamsListener listener, final DoneSubscribe done) {
+ public IToken subscribe(final String stream_type, final StreamsListener listener, final DoneSubscribe done) {
return new Command(channel, this, "subscribe", new Object[]{ stream_type }) {
@Override
public void done(Exception error, Object[] args) {
@@ -101,22 +101,25 @@ public class StreamsProxy implements IStreams {
public void event(String name, byte[] data) {
try {
+ assert listeners.get(stream_type) == this;
Object[] args = JSON.parseSequence(data);
- if (name.equals("created")) {
- if (args.length == 3) {
- listener.created((String)args[0], (String)args[1], (String)args[2]);
+ if (stream_type.equals(args[0])) {
+ if (name.equals("created")) {
+ if (args.length == 3) {
+ listener.created((String)args[0], (String)args[1], (String)args[2]);
+ }
+ else {
+ assert args.length == 2;
+ listener.created((String)args[0], (String)args[1], null);
+ }
}
- else {
+ else if (name.equals("disposed")) {
assert args.length == 2;
- listener.created((String)args[0], (String)args[1], null);
+ listener.disposed((String)args[0], (String)args[1]);
+ }
+ else {
+ throw new IOException("Streams service: unknown event: " + name);
}
- }
- else if (name.equals("disposed")) {
- assert args.length == 2;
- listener.disposed((String)args[0], (String)args[1]);
- }
- else {
- throw new IOException("Streams service: unknown event: " + name);
}
}
catch (Throwable x) {
@@ -124,7 +127,8 @@ public class StreamsProxy implements IStreams {
}
}
};
- listeners.put(listener, l);
+ assert listeners.get(stream_type) == null;
+ listeners.put(stream_type, l);
channel.addEventListener(StreamsProxy.this, l);
}
done.doneSubscribe(token, error);
@@ -132,7 +136,7 @@ public class StreamsProxy implements IStreams {
}.token;
}
- public IToken unsubscribe(String stream_type, final StreamsListener listener, final DoneUnsubscribe done) {
+ public IToken unsubscribe(final String stream_type, final StreamsListener listener, final DoneUnsubscribe done) {
return new Command(channel, this, "unsubscribe", new Object[]{ stream_type }) {
@Override
public void done(Exception error, Object[] args) {
@@ -141,7 +145,7 @@ public class StreamsProxy implements IStreams {
error = toError(args[0]);
}
if (error == null) {
- IChannel.IEventListener l = listeners.remove(listener);
+ IChannel.IEventListener l = listeners.remove(stream_type);
if (l != null) channel.removeEventListener(StreamsProxy.this, l);
}
done.doneUnsubscribe(token, error);

Back to the top