Skip to content

Commit

Permalink
take host name & port from user
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahad-10 committed May 4, 2024
1 parent c3cf34e commit a1c0182
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/src/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ class Server {

Router router;

Future<void> websocketHandler() async {
var server = await HttpServer.bind(InternetAddress.anyIPv4, 8080);
Future<void> start(String host, int port) async {
var server = await HttpServer.bind(host, port);

await for (final request in server) {
var webSocket = await WebSocketTransformer.upgrade(request);
WAMPSessionAcceptor a = WAMPSessionAcceptor();
BaseSession baseSession = await a.accept(webSocket);
router.attachClient(baseSession);

handleWebSocket(baseSession);
_handleWebSocket(baseSession);
}
}

void handleWebSocket(BaseSession baseSession) {
void _handleWebSocket(BaseSession baseSession) {
Future.microtask(() async {
while (true) {
var message = await baseSession.receive();
Expand Down

0 comments on commit a1c0182

Please sign in to comment.