-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Javalin v5 bump #930
Merged
Merged
Javalin v5 bump #930
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,8 @@ | |
package org.photonvision.server; | ||
|
||
import io.javalin.Javalin; | ||
import io.javalin.http.staticfiles.Location; | ||
import io.javalin.plugin.bundled.CorsPluginConfig; | ||
import java.net.InetSocketAddress; | ||
import java.util.StringJoiner; | ||
import org.photonvision.common.logging.LogGroup; | ||
import org.photonvision.common.logging.Logger; | ||
|
@@ -27,45 +28,45 @@ public class Server { | |
private static final Logger logger = new Logger(Server.class, LogGroup.WebServer); | ||
|
||
public static void start(int port) { | ||
Javalin app = | ||
var app = | ||
Javalin.create( | ||
config -> { | ||
config.showJavalinBanner = false; | ||
config.addStaticFiles("web", Location.CLASSPATH); | ||
config.enableCorsForAllOrigins(); | ||
javalinConfig -> { | ||
javalinConfig.showJavalinBanner = false; | ||
javalinConfig.staticFiles.add("web"); | ||
javalinConfig.plugins.enableCors( | ||
corsContainer -> { | ||
corsContainer.add(CorsPluginConfig::anyHost); | ||
}); | ||
|
||
config.requestLogger( | ||
javalinConfig.requestLogger.http( | ||
(ctx, ms) -> { | ||
StringJoiner joiner = | ||
new StringJoiner(" ") | ||
.add("Handled HTTP request of type") | ||
.add(ctx.req.getMethod()) | ||
.add(ctx.req().getMethod()) | ||
.add("from endpoint") | ||
.add(ctx.path()) | ||
.add("for host") | ||
.add(ctx.req.getRemoteHost()) | ||
.add(ctx.req().getRemoteHost()) | ||
.add("in") | ||
.add(ms.toString()) | ||
.add("ms"); | ||
|
||
logger.debug(joiner.toString()); | ||
}); | ||
|
||
config.wsLogger( | ||
ws -> | ||
ws.onMessage( | ||
ctx -> logger.debug("Got WebSockets message: " + ctx.message()))); | ||
|
||
config.wsLogger( | ||
ws -> | ||
ws.onBinaryMessage( | ||
ctx -> | ||
logger.trace( | ||
() -> { | ||
var insa = ctx.session.getRemote().getInetSocketAddress(); | ||
var host = insa.getAddress().toString() + ":" + insa.getPort(); | ||
return "Got WebSockets binary message from host " + host; | ||
}))); | ||
javalinConfig.requestLogger.ws( | ||
ws -> { | ||
ws.onMessage(ctx -> logger.debug("Got WebSockets message: " + ctx.message())); | ||
ws.onBinaryMessage( | ||
ctx -> | ||
logger.trace( | ||
() -> { | ||
var remote = (InetSocketAddress) ctx.session.getRemoteAddress(); | ||
var host = | ||
remote.getAddress().toString() + ":" + remote.getPort(); | ||
return "Got WebSockets binary message from host: " + host; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might get spammy, but should be fine since messages going this direction are rare There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And it was already like this |
||
})); | ||
}); | ||
}); | ||
|
||
/*Web Socket Events for Data Exchange */ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feels like a good time to find a better value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The frontend doesn't even connect to the CameraWebsocket anymore. What from this system is even required anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah kill the references here I think. It was from sending camera frames over WS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a lot of requests and things in photon-server which aren't used anymore. Like that entire UISettings class