phoenix_socket 0.3.0+1 copy "phoenix_socket: ^0.3.0+1" to clipboard
phoenix_socket: ^0.3.0+1 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});
    });
  }
}
55
likes
0
pub points
86%
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

effective_dart, equatable, logging, meta, pedantic, quiver, rxdart, web_socket_channel

More

Packages that depend on phoenix_socket