main function

void main()

Implementation

void main() async {
 /* final channel = ClientChannel(
    'localhost',
    port: 5000,
    options: const ChannelOptions(credentials: ChannelCredentials.insecure()),
  );*/

  final channel = ClientChannel(
    '127.0.0.1',
    port: 5000,
    options: const ChannelOptions(credentials: ChannelCredentials.insecure()),
  );

  final stub = AlbumServiceClient(channel);

  // unary style responses
  var response = await stub.getAlbums(AlbumRequest());
  print('Response received: ${response.writeToJson()}');

  response = await stub.getAlbums(AlbumRequest()..id = 1);
 // print('Response received: ${response.writeToJsonMap()}');

  var response2 = await stub.getAlbumsWithPhotos(AlbumRequest()..id = 3);
  print('data with id -> 3  ${response2}');
  /*
  print('Got response! ${response2.albums[0]}');
  print('Got response! ${response2.albums[0].writeToJson()}');
  print('Got response! ${response2.albums[0].writeToJsonMap()}');*/

  // Streaming server rpc style responses
  var photoStream = stub.getPhotos(AlbumRequest());
  await for (var photo in photoStream) {
    print('Received photo! ${photo.url}');
  }

  photoStream = stub.getPhotos(AlbumRequest()..id = 3);
  /*await for (var photo in photoStream) {
    print('Received filtered photo! ${photo.url}');
  }*/


  var response1= await stub.getDataDemo(AlbumRequest());
  print(response1.albums[0].title);
  await channel.shutdown();
}