-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Seven Du
committed
Sep 25, 2023
1 parent
1465c47
commit 59929e3
Showing
1 changed file
with
29 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
library spry.websocket; | ||
|
||
import 'dart:io'; | ||
|
||
import 'spry.dart'; | ||
|
||
class WebSocketHandler { | ||
Future<void> call(Context context) async { | ||
final HttpRequest request = context[HttpRequest]; | ||
|
||
if (!WebSocketTransformer.isUpgradeRequest(request)) { | ||
throw Exception('Not a WebSocket upgrade request'); | ||
} | ||
|
||
final websocket = await WebSocketTransformer.upgrade(request); | ||
websocket.listen((event) { | ||
print(event); | ||
}); | ||
|
||
await websocket.done; | ||
} | ||
} | ||
|
||
final handler = WebSocketHandler(); | ||
final spry = Spry(); | ||
|
||
void main() async { | ||
await spry.listen(handler, port: 3030); | ||
} |
59929e3
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.
Successfully deployed to the following URLs:
spry – ./
spry-git-main-odroe.vercel.app
spry-odroe.vercel.app
spry.fun
spry-framework.vercel.app
www.spry.fun