Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
6397111c
Commit
6397111c
authored
Dec 04, 2015
by
Björn Richerzhagen
Browse files
Corrected behavior of PortListener (not critical)
parent
bbc87f64
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/transport/modular/ModularTransLayer.java
View file @
6397111c
...
...
@@ -240,6 +240,8 @@ public class ModularTransLayer implements SimHostComponent, TransportComponent,
private
final
int
localPort
;
private
final
ITransProtocol
transport
;
private
TransMessageListener
listener
;
public
ProtocolAdapter
(
NetID
localAddress
,
int
localPort
,
ITransProtocol
transport
)
{
...
...
@@ -250,6 +252,7 @@ public class ModularTransLayer implements SimHostComponent, TransportComponent,
@Override
public
void
setTransportMessageListener
(
TransMessageListener
listener
)
{
this
.
listener
=
listener
;
addTransMsgListener
(
listener
,
localPort
);
}
...
...
@@ -257,7 +260,9 @@ public class ModularTransLayer implements SimHostComponent, TransportComponent,
* FIXME add @Override lateron, as soon as the API is updated globally.
*/
public
void
removeTransportMessageListener
()
{
removeTransMsgListener
(
localPort
);
assert
listener
!=
null
;
removeTransMsgListener
(
listener
,
localPort
);
listener
=
null
;
}
@Override
...
...
@@ -403,9 +408,12 @@ public class ModularTransLayer implements SimHostComponent, TransportComponent,
pl
.
addListener
(
receiver
);
}
protected
void
removeTransMsgListener
(
int
port
)
{
// assuming there is only one
portListeners
.
remove
(
port
);
protected
void
removeTransMsgListener
(
TransMessageListener
listener
,
int
port
)
{
PortListener
pl
=
portListeners
.
get
(
port
);
pl
.
removeListener
(
listener
);
if
(
pl
.
isEmpty
())
{
portListeners
.
remove
(
port
);
}
}
@Override
...
...
@@ -527,9 +535,8 @@ public class ModularTransLayer implements SimHostComponent, TransportComponent,
}
/**
* A very simple data structure to allow multiple Listeners on one port
*
* FIXME why would we need to support more than one listener per port?
* A very simple data structure to allow multiple Listeners on one port (e.g., if TCP and UDP are
* both instantiated on the same port)
*
* @author Bjoern Richerzhagen
* @version 1.0, 07.05.2012
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment