fluttersocketssocket.io

Creating Flutter app both act as client and server for a LAN mobile game using Socket.io


I am trying to write a cross-platform mobile app (My priority is ANDROID). I am using Flutter. In my application, one of the device will be both host and player. The game will be played through LAN. There must be low latency between players and data must be broadcasted. So I decided to use Socket.io. My problem is I could not find the server library for the Socket.io

  1. Tried to implement my on Dart Server which is complicated for me.
  2. Bundle Java or Javascript Socket.io code with Dart.

I am very new to the subject. I could not find the way to bundle Java (or any other language with Socket.io ) code with Flutter properly.

Which way do you suggest? If you suggest where can i start or suggest me any reading it would be very helpful


Solution

  • Have you tried using this package? https://github.com/rikulo/socket.io-client-dart (here also explains the basic usage of client and server)

    Well, I used it to create a pool game, although the server runs in Python and the client in Dart, you can implement both in Dart too.

    Regarding the suggestions you asked for, to read I recommend the socket.io documentation itself: https://socket.io/docs/v4/

    A tip that might help you would be to first think about the model you intend to implement in your game (server and client), study this model and then try to apply these concepts to your code