summaryrefslogtreecommitdiff
path: root/src/main/java/com/lumaserv/bgp/BGPSession.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/lumaserv/bgp/BGPSession.java')
-rw-r--r--src/main/java/com/lumaserv/bgp/BGPSession.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main/java/com/lumaserv/bgp/BGPSession.java b/src/main/java/com/lumaserv/bgp/BGPSession.java
index 3ffadd8..f693f11 100644
--- a/src/main/java/com/lumaserv/bgp/BGPSession.java
+++ b/src/main/java/com/lumaserv/bgp/BGPSession.java
@@ -27,7 +27,7 @@ public class BGPSession implements Runnable {
public void keepAlive() {
try {
- outputStream.write(new BGPPacket().setType(BGPPacket.Type.KEEPALIVE).setMessage(new byte[0]).build());
+ outputStream.write(new BGPPacket().setType(BGPPacket.Type.KEEPALIVE).build());
} catch (IOException e) {
e.printStackTrace();
}
@@ -43,12 +43,21 @@ public class BGPSession implements Runnable {
keepAlive();
break;
case UPDATE: {
- configuration.getListener().onUpdate(this, new BGPUpdate(packet.getMessage()));
+ configuration.getListener().onUpdate(this, (BGPUpdate)packet.getMessage());
break;
}
}
}
+ public void send(BGPPacket packet) {
+ try {
+ outputStream.write(packet.build());
+ } catch (IOException ex) {
+ closed = true;
+ configuration.getListener().onClose(this);
+ }
+ }
+
public void run() {
try {
while (!closed) {