Giter Site home page Giter Site logo

Comments (6)

jumperchen avatar jumperchen commented on June 2, 2024

FYI: https://github.com/rikulo/socket.io-client-dart#version-info

from socket.io-client-dart.

albatomuch avatar albatomuch commented on June 2, 2024

when i use any v2, the socket server is not detected at all.

from socket.io-client-dart.

jumperchen avatar jumperchen commented on June 2, 2024

To work with socket.io dart client, you have to know which application type you are using, such as Flutter app, Flutter Web app, Pure Dart Client app, or Pure Dart app. Each different type requires a different connecting argument, which you can find in the README.md file in the repo. Even if the connecting arguments are correct, you have to setup the http server config (such as Apache HTTP server or Nginx) to make it work with socket.io connection, such as WebSocket, or pure HTTP connection.
The pure test code can work in the pure Dart app or pure Dart client app, please take a look at Dart client to access NodeJs server and this Flutter example can work too.

from socket.io-client-dart.

albatomuch avatar albatomuch commented on June 2, 2024

what would be the ideal setup if I am using using socket_io_client on flutter app and now shifted to pure dart for server side using socket_io 1.0.1? I am still getting the same error message [ping timeout, null] .

from socket.io-client-dart.

jumperchen avatar jumperchen commented on June 2, 2024

Dart server doesn't support v2 version and Flutter app (not web) can only work with websocket transport.

from socket.io-client-dart.

ravikinharavi avatar ravikinharavi commented on June 2, 2024

Dart server doesn't support v2 version and Flutter app (not web) can only work with websocket transport.

hello sir my socket.on(message not working. import 'package:flutter/material.dart';
import 'package:socket_io_client/socket_io_client.dart' as IO;

class checking extends StatefulWidget {
const checking({Key? key}) : super(key: key);

@OverRide
State createState() => _checkingState();
}

class _checkingState extends State {
late IO.Socket socket;

@OverRide
void initState() {
super.initState();
initSocket();
}

var k = "click";

Future initSocket() async {
socket = IO.io("http://13.126.94.67:1000", <String, dynamic>{
'autoConnect': true,
'transports': ['websocket'],
});

 socket.onConnect((_) {
  print('Connection established');

  // Emit the "connected" event after connecting
  socket.emit('connected', {
    'livestreamId': "651674a1907e321ab7acb78a",
    'coursefieldId': "649eb48d8bfdc575a18c64c6",
  });



  socket.on('connected', (data) {
    print('Response from connected event: ${data["roomId"]}');
    socket.emit('joinRoom', {
      'roomId': data["roomId"],
    });
  });
});

socket.onDisconnect((_) => print('Connection Disconnection'));
socket.onConnectError((err) => print(err));
socket.onError((err) => print(err));

// Listen for "message" event
socket.on("message", (data) {
  print("Received message: $data");
});

var test =socket;
// Connect to the server
socket.connect();
}

@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () {
print(socket.connected);

        // Emit the "message" event here
        socket.emit("message", {
          "livestreamId": "651674a1907e321ab7acb78a",
          "coursefieldId": "649eb48d8bfdc575a18c64c6",
          "studentId": "64d4804b4c3c39e38865b041",
          "subjectId": "649eb5718bfdc575a18c64da",
          "message": "ravi msg emmit",
          "roomId": "S_9ShObYjjcePoBGAAGV",
        });

        print(socket.connected);
      },
      child: Text("$k"),
    ),
  ),
);

}
}

from socket.io-client-dart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.