joinChannel method

Future<Channel> joinChannel({
  1. required String target,
  2. required ChannelType type,
  3. required bool persistence,
  4. required bool hidden,
})

Implementation

Future<Channel> joinChannel({
  required String target,
  required ChannelType type,
  required bool persistence,
  required bool hidden,
}) async {
  final res = await _send<rtpb.Channel>(rtpb.Envelope(
      channelJoin: rtpb.ChannelJoin(
    target: target,
    type: () {
      switch (type) {
        case ChannelType.room:
          return rtpb.ChannelJoin_Type.ROOM;
        case ChannelType.group:
          return rtpb.ChannelJoin_Type.GROUP;
        case ChannelType.directMessage:
          return rtpb.ChannelJoin_Type.DIRECT_MESSAGE;
        default:
          return rtpb.ChannelJoin_Type.TYPE_UNSPECIFIED;
      }
    }()
        .value,
    persistence: api.BoolValue(value: persistence),
    hidden: api.BoolValue(value: hidden),
  )));

  return Channel.fromDto(res);
}