import 'package:agora_rtc_engine/agora_rtc_engine.dart';

/// 声网SDK相关工具类
class AgoraUtil{
  /// 获取网络连接状态
  static String getConnectionStateChangedType(ConnectionStateType type){
    var returnTypeStr = "";
    switch(type){
      case ConnectionStateType.connectionStateDisconnected:
        returnTypeStr = "网络连接断开";
        break;
      case ConnectionStateType.connectionStateConnecting:
        returnTypeStr = "网络连接中";
        break;
      case ConnectionStateType.connectionStateConnected:
        returnTypeStr = "网络已连接";
        break;
      case ConnectionStateType.connectionStateReconnecting:
        returnTypeStr = "网络重新连接中";
        break;
      case ConnectionStateType.connectionStateFailed:
        returnTypeStr = "网络连接失败";
        break;
    }
    return returnTypeStr;
  }

  /// 获取网络连接状态发生变化的原因
  static String getConnectionChangedReasonType(ConnectionChangedReasonType type){
    var returnTypeStr = "";
    switch(type){
      case ConnectionChangedReasonType.connectionChangedConnecting:
        returnTypeStr = "建立网络连接中";
        break;
      case ConnectionChangedReasonType.connectionChangedJoinSuccess:
        returnTypeStr = "成功加入频道";
        break;
      case ConnectionChangedReasonType.connectionChangedInterrupted:
        returnTypeStr = "网络连接中断";
        break;
      case ConnectionChangedReasonType.connectionChangedBannedByServer:
        returnTypeStr = "网络连接被服务器禁止";
        break;
      case ConnectionChangedReasonType.connectionChangedJoinFailed:
        returnTypeStr = "加入频道失败";
        break;
      case ConnectionChangedReasonType.connectionChangedLeaveChannel:
        returnTypeStr = "离开频道";
        break;
      case ConnectionChangedReasonType.connectionChangedInvalidAppId:
        returnTypeStr = "App ID 无效";
        break;
      case ConnectionChangedReasonType.connectionChangedInvalidChannelName:
        returnTypeStr = "频道名无效";
        break;
      case ConnectionChangedReasonType.connectionChangedInvalidToken:
        returnTypeStr = "Token 无效";
        break;
      case ConnectionChangedReasonType.connectionChangedTokenExpired:
        returnTypeStr = "当前使用的 Token 已过期";
        break;
      case ConnectionChangedReasonType.connectionChangedRejectedByServer:
        returnTypeStr = "此用户被服务器禁止";
        break;
      case ConnectionChangedReasonType.connectionChangedSettingProxyServer:
        returnTypeStr = "设置了代理服务器";
        break;
      case ConnectionChangedReasonType.connectionChangedRenewToken:
        returnTypeStr = "更新 Token 引起网络连接状态改变";
        break;
      case ConnectionChangedReasonType.connectionChangedClientIpAddressChanged:
        returnTypeStr = "客户端 IP 地址变更";
        break;
      case ConnectionChangedReasonType.connectionChangedKeepAliveTimeout:
        returnTypeStr = "SDK 和服务器连接保活超时";
        break;
      case ConnectionChangedReasonType.connectionChangedRejoinSuccess:
        returnTypeStr = "重新加入频道成功";
        break;
      case ConnectionChangedReasonType.connectionChangedLost:
        returnTypeStr = "SDK 和服务器失去连接";
        break;
      case ConnectionChangedReasonType.connectionChangedEchoTest:
        returnTypeStr = "连接状态变化由回声测试引起";
        break;
      case ConnectionChangedReasonType.connectionChangedClientIpAddressChangedByUser:
        returnTypeStr = "本地 IP 地址被用户更改";
        break;
      case ConnectionChangedReasonType.connectionChangedSameUidLogin:
        returnTypeStr = "使用相同的 UID 从不同的设备加入同一频道";
        break;
      case ConnectionChangedReasonType.connectionChangedTooManyBroadcasters:
        returnTypeStr = "频道内主播人数已达上限";
        break;
      case ConnectionChangedReasonType.connectionChangedLicenseValidationFailure:
        returnTypeStr = "连接已更改许可证验证失败";
        break;
      case ConnectionChangedReasonType.connectionChangedCertificationVeryfyFailure:
        returnTypeStr = "连接已更改认证版本失败";
        break;
      case ConnectionChangedReasonType.connectionChangedStreamChannelNotAvailable:
        returnTypeStr = "连接已更改流通道不可用";
        break;
      case ConnectionChangedReasonType.connectionChangedInconsistentAppid:
        returnTypeStr = "连接已更改不一致Appid";
        break;
    }
    return returnTypeStr;
  }
}