-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
0b9a9d7
commit 7bd01a0
Showing
7 changed files
with
186 additions
and
13 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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:shelf/shelf.dart'; | ||
import 'package:shelf/shelf_io.dart' as io; | ||
import 'package:shelf_static/shelf_static.dart'; | ||
import 'package:shelf_web_socket/shelf_web_socket.dart'; | ||
import 'package:web_socket_channel/web_socket_channel.dart'; | ||
|
||
void main() { | ||
final staticHandler = | ||
createStaticHandler('app/build/web', defaultDocument: 'index.html'); | ||
|
||
final socketHandler = webSocketHandler((WebSocketChannel webSocket) async { | ||
final proxied = await WebSocket.connect('ws://localhost:10357'); | ||
webSocket.stream.listen((message) { | ||
proxied.add(message); | ||
}, onDone: () { | ||
proxied.close(); | ||
}); | ||
proxied.listen((message) { | ||
webSocket.sink.add(message); | ||
}, onDone: () { | ||
webSocket.sink.close(); | ||
}); | ||
}); | ||
|
||
// Serve /connect requests with the web socket handler. | ||
// Serve other requests with the static file handler. | ||
handler(Request request) { | ||
print(request.url.path); | ||
if (request.url.path == 'connect') { | ||
return socketHandler(request); | ||
} else { | ||
return staticHandler(request); | ||
} | ||
} | ||
|
||
io.serve(handler, 'localhost', 80); | ||
} |
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
7bd01a0
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:
qeck – ./app
qeck.vercel.app
qeck-git-develop-linwood.vercel.app
qeck-linwood.vercel.app