phoenix_socket 0.2.0 copy "phoenix_socket: ^0.2.0" to clipboard
phoenix_socket: ^0.2.0 copied to clipboard

outdated

PhoenixSocket provides a feature-complete implementation of Phoenix Sockets, using a single API based on StreamChannels compatible with any deployment of Flutter.

example/lib/main.dart

import 'dart:async';

import 'package:phoenix_socket/phoenix_socket.dart';
import 'package:uuid/uuid.dart';

void main() async {
  final socket1 = PhoenixSocket('ws://localhost:4000/socket/websocket');
  await socket1.connect();
  var channel1 = socket1.addChannel(topic: 'channel3');
  await channel1.join().future;
  var uuid = Uuid().v4();

  channel1.push('ping', {'from': uuid});

  await for (var message in channel1.messages) {
    if (message.event != 'pong' || message.payload['from'] == uuid) continue;
    print("received ${message.event} from ${message.payload['from']}");
    Timer(Duration(seconds: 1), () {
      channel1.push('ping', {'from': uuid});
    });
  }
}
49
likes
0
pub points
88%
popularity

Publisher

verified publisherbraver.health

PhoenixSocket provides a feature-complete implementation of Phoenix Sockets, using a single API based on StreamChannels compatible with any deployment of Flutter.

Homepage

License

unknown (LICENSE)

Dependencies

equatable, meta, pedantic, quiver, rxdart, web_socket_channel

More

Packages that depend on phoenix_socket