-
Notifications
You must be signed in to change notification settings - Fork 54
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
Use web socket along Http request #182
Comments
import 'dart:async';
import 'package:functions_framework/functions_framework.dart';
import 'package:shelf/shelf.dart';
import 'package:shelf_router/shelf_router.dart';
import 'package:shelf_web_socket/shelf_web_socket.dart';
/// ./server.exe
@CloudFunction()
FutureOr<Response> function(Request request) async {
final app = Router();
app.get('/', (Request request) {
return Response.ok('root');
});
return app(request);
}
@CloudFunction()
FutureOr<Response> webSocket(Request request) async {
var app = Router();
var wsHandle = webSocketHandler((webSocket) {
webSocket.stream.listen((message) {
print(message);
webSocket.sink.add('echo $message');
});
});
app.get('/', wsHandle);
return app(request);
} ./bin/server.exe --target=webSocket Connect in |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Is there a way to setup WebSocket listeners along with http requests?
The text was updated successfully, but these errors were encountered: