{"id":18917585,"url":"https://github.com/infitio/flutter_socket_io","last_synced_at":"2025-04-04T22:08:22.764Z","repository":{"id":41271481,"uuid":"157768433","full_name":"infitio/flutter_socket_io","owner":"infitio","description":"Socket IO supprt for flutter. Looking for contributors Swift and Java.","archived":false,"fork":false,"pushed_at":"2024-08-09T18:11:59.000Z","size":498,"stargazers_count":189,"open_issues_count":65,"forks_count":113,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-28T21:06:42.153Z","etag":null,"topics":["android","flutter","flutter-plugin","ios","mobile-development","socket-client","socket-io","socket-io-client","websocket","websocket-client"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/infitio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-15T20:26:43.000Z","updated_at":"2025-02-15T20:24:28.000Z","dependencies_parsed_at":"2024-11-22T12:01:01.699Z","dependency_job_id":"0aa6254c-f8cf-4c2c-9485-bae625c7206e","html_url":"https://github.com/infitio/flutter_socket_io","commit_stats":{"total_commits":173,"total_committers":19,"mean_commits":9.105263157894736,"dds":0.676300578034682,"last_synced_commit":"2fe00031e06e67b3202c45f1295f916fdac42bf3"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infitio%2Fflutter_socket_io","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infitio%2Fflutter_socket_io/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infitio%2Fflutter_socket_io/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/infitio%2Fflutter_socket_io/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/infitio","download_url":"https://codeload.github.com/infitio/flutter_socket_io/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256115,"owners_count":20909240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","flutter","flutter-plugin","ios","mobile-development","socket-client","socket-io","socket-io-client","websocket","websocket-client"],"created_at":"2024-11-08T10:27:06.435Z","updated_at":"2025-04-04T22:08:22.739Z","avatar_url":"https://github.com/infitio.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# adhara_socket_io\n\n[![.github/workflows/flutter_integration.yaml](https://github.com/infitio/flutter_socket_io/actions/workflows/flutter_integration.yaml/badge.svg?branch=main)](https://github.com/infitio/flutter_socket_io/actions/workflows/flutter_integration.yaml)\n\n[socket.io](https://socket.io/) for flutter by [adhara](https://github.com/infitio/)\n\nsupports both Android and iOS\n\nsocket.io version supported: v2\ndevelopment in progress for v3 and v4\n\n\u003e If you are using v3/v4 socket on server side, you may face connection issues, please downgrade and try in such scenario.\n\nUsage:\n\n\u003e See `example/lib/main.dart` for more detailed example\n\n```dart\n\tfinal SOCKET_SERVER = 'http://192.168.1.2:7070/';\t//To be modified accordingly\n        SocketIO socket;\n\tStreamSubscription connectSubscription;\n\tStreamSubscription echoSubscription;\n\n\tFuture\u003cvoid\u003e demonstrateSocket() async {\n    \t// Create a socket instance\n\t\tsocket = await SocketIOManager().createInstance(\n        \tSocketOptions(SOCKET_SERVER),\n        );\n\n\t// Listen to socket connect event\n\tsubscription = socket.onConnect.listen((data){\n\t  print('connected: $data');\n\t  socket.emit('message', ['Hello world!']);\n\t});\n\n        // Listen to an custom (\"news\") event\n\techoSubscription = socket.on('echo', (data){\n  \t    print(\"news event recieved with data: $data\");\n\t});\n\n\t// There are 2 ways to connect to socket server\n\t//  - normal: doesn't wait for connectio success\n\t//  - sync: ensures connection or errors out on failure\n\n        // normal:\n        //  connect to socket server - will initialize connection,\n        //  but not ensure the connection yet.\n        //  If this method used to connect to server, then emit events should be sent\n        //  only after ensuring connection to socket server is successful by listening\n        //  to onConnect events\n\t// await socket.connect();\n\n\t// sync:\n        //  This API will ensure connection to server is successful\n        //  or will throw error on connect error\n        await socket.connectSync();\n\n        // publish data - will publish to server, won't ensure the delivery\n\tawait socket.emit('echo', ['hello']);\n\n        // emit with acknowledgement - will publish to server\n        //  and ensure delivery with ack if ack is implemented in server\n        dynamic ackData = await socket.emitWithAck('echo', ['hello']);\n            print('acknowledgement recieved from server: $ackData');\n    \t}\n\n\tFuture\u003cvoid\u003e dispose() async {\n\t    // cancel echo and onConnect subscriptions\n\t    await echoSubscription.cancel();\n\t    await connectSubscription.cancel();\n\n            // clear socket instance from manager\n            await SocketIOManager().clearInstance(socket);\n        }\n\n\t// register liteners, connect to a socket, and publish data\n\tdemonstrateSocket();\n\n\t// will dispose listeners and socket\n\tdispose();\n```\n\n\n## Running example:\n\n\n1. clone the project\n2. start socket server in the background\n```bash\ncd socket.io.server\nnpm i\n./node_modules/.bin/pm2/ index.js\ncd ../\n```\n\n3. open `example/lib/main.dart` and edit the `URI` in #7 to point to your hosted/local socket server instances as mentioned step 2\n\n    For example:\n\n    ```dart\n    const String URI = \"http://192.168.1.2:7000/\";\n    ```\n\n    ```dart\n    const String URI = \"http://mysite.com/\";\n    ```\n\n3. run example\n```\ncd example\nflutter run\n```\n\n## iOS support 📢📢\nThis project uses Swift for iOS support, please enable Swift support for your project for this plugin to work\n\n\n## Android support for SDK \u003e 27\n\nConfigure `android:usesCleartextTraffic=\"true\"` as a property of `\u003capplication ...\u003e` tag in `android/app/src/main/AndroidManifest.xml`\n\nFor example:\n\n```xml\n\n\u003capplication\n        android:name=\"io.flutter.app.FlutterApplication\"\n        android:label=\"adhara_socket_io_example\"\n        android:usesCleartextTraffic=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\u003e\n        \u003cactivity\n            android:name=\".MainActivity\"...\u003e...\u003c/activity\u003e\n        ...\n\u003c/application\u003e\n```\n\n[Refer to discussion here](https://github.com/infitio/flutter_socket_io/issues/42)\n\n## Running tests\n\nThis plugin uses flutter driver to run integration tests tests. Use below command to run integration tests on Android/iOS\n\n```bash\nsh bin/run_tests.sh\n```\n\n## Sample Video - Running the example\n\n[![Running adhara socket io for flutter, example](https://img.youtube.com/vi/rc6Kv95FJ4M/0.jpg)](https://www.youtube.com/watch?v=rc6Kv95FJ4M \"Running the example\")\n\n\n## FAQ's\n\n##### AdharaSocketIoPlugin.m:2:9: fatal error: 'adhara_socket_io/adhara_socket_io-Swift.h' file not found\nadd `use_frameworks!` to your Podfile as in the example\nhttps://github.com/infitio/flutter_socket_io/blob/master/example/ios/Podfile#L30\n\nRead more about this: [discussion](https://github.com/infitio/flutter_socket_io/issues/58)\n\n\n## Other Packages:\n\nFeel free to checkout our [Adhara](https://pub.dartlang.org/packages/adhara) package\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfitio%2Fflutter_socket_io","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfitio%2Fflutter_socket_io","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfitio%2Fflutter_socket_io/lists"}