dart_ws_grpc 0.0.2 copy "dart_ws_grpc: ^0.0.2" to clipboard
dart_ws_grpc: ^0.0.2 copied to clipboard

outdated

A dart client for wsgrpc. Using Websocket as transport of grpc will make client stream and server stream call available for browser scripts.

example/main.dart

import 'dart:core';
import 'dart:convert';
import 'package:grpc/grpc_web.dart';
import 'package:dart_ws_grpc/api/ws/proto/ws.pb.dart';
import 'package:dart_ws_grpc/grpc_streaming.dart';

void main() async {
  final channel = GrpcWebClientChannel.xhr(Uri.parse('http://127.0.0.1:80'));
  final service = WsClient(channel);

  String msg = ("Pong Pong Pong");

  final request = Message(
    topic: Topic.PONG,
    channelId: Topic.PONG.toString(),
    msgId: "ws.test",
    payload: utf8.encode(msg),
  );

  service.streaming(request as Stream<Message>).listen((response) {
    print(response.writeToJsonMap());
  }, onError: (error) {
    print(error.toString());
  }, onDone: () => print('Closed connection to server.'));
}
1
likes
0
points
46
downloads

Publisher

unverified uploader

Weekly Downloads

A dart client for wsgrpc. Using Websocket as transport of grpc will make client stream and server stream call available for browser scripts.

Repository (GitLab)
View/report issues

License

unknown (license)

Dependencies

fixnum, flutter, grpc, protobuf

More

Packages that depend on dart_ws_grpc