-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3383 from eclipse/jetty-10-issue-3379-websocket-s…
…ession-tracking Issue #3379 - Add tracking of WebSocket Sessions to various WebSocket Container APIs
- Loading branch information
Showing
36 changed files
with
2,787 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketSessionListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. | ||
// ------------------------------------------------------------------------ | ||
// All rights reserved. This program and the accompanying materials | ||
// are made available under the terms of the Eclipse Public License v1.0 | ||
// and Apache License v2.0 which accompanies this distribution. | ||
// | ||
// The Eclipse Public License is available at | ||
// http://www.eclipse.org/legal/epl-v10.html | ||
// | ||
// The Apache License v2.0 is available at | ||
// http://www.opensource.org/licenses/apache2.0.php | ||
// | ||
// You may elect to redistribute this code under either of these licenses. | ||
// ======================================================================== | ||
// | ||
|
||
package org.eclipse.jetty.websocket.javax.common; | ||
|
||
public interface JavaxWebSocketSessionListener | ||
{ | ||
void onJavaxWebSocketSessionOpened(JavaxWebSocketSession session); | ||
|
||
void onJavaxWebSocketSessionClosed(JavaxWebSocketSession session); | ||
} |
59 changes: 59 additions & 0 deletions
59
...bsocket-common/src/main/java/org/eclipse/jetty/websocket/javax/common/SessionTracker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. | ||
// ------------------------------------------------------------------------ | ||
// All rights reserved. This program and the accompanying materials | ||
// are made available under the terms of the Eclipse Public License v1.0 | ||
// and Apache License v2.0 which accompanies this distribution. | ||
// | ||
// The Eclipse Public License is available at | ||
// http://www.eclipse.org/legal/epl-v10.html | ||
// | ||
// The Apache License v2.0 is available at | ||
// http://www.opensource.org/licenses/apache2.0.php | ||
// | ||
// You may elect to redistribute this code under either of these licenses. | ||
// ======================================================================== | ||
// | ||
|
||
package org.eclipse.jetty.websocket.javax.common; | ||
|
||
import java.util.Collections; | ||
import java.util.Set; | ||
import java.util.concurrent.CopyOnWriteArraySet; | ||
import javax.websocket.Session; | ||
|
||
import org.eclipse.jetty.util.component.AbstractLifeCycle; | ||
import org.eclipse.jetty.util.component.LifeCycle; | ||
|
||
public class SessionTracker extends AbstractLifeCycle implements JavaxWebSocketSessionListener | ||
{ | ||
private CopyOnWriteArraySet<JavaxWebSocketSession> sessions = new CopyOnWriteArraySet<>(); | ||
|
||
public Set<Session> getSessions() | ||
{ | ||
return Collections.unmodifiableSet(sessions); | ||
} | ||
|
||
@Override | ||
public void onJavaxWebSocketSessionOpened(JavaxWebSocketSession session) | ||
{ | ||
sessions.add(session); | ||
} | ||
|
||
@Override | ||
public void onJavaxWebSocketSessionClosed(JavaxWebSocketSession session) | ||
{ | ||
sessions.remove(sessions); | ||
} | ||
|
||
@Override | ||
protected void doStop() throws Exception | ||
{ | ||
for (JavaxWebSocketSession session : sessions) | ||
{ | ||
LifeCycle.stop(session); | ||
} | ||
super.doStop(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.