/// <summary> /// 创建一个Sora服务 /// </summary> /// <param name="config">配置文件</param> /// <param name="crashAction">发生未处理异常时的回调</param> /// <exception cref="DataException">数据初始化错误</exception> /// <exception cref="ArgumentNullException">空配置文件错误</exception> /// <exception cref="ArgumentOutOfRangeException">参数错误</exception> /// <exception cref="ArgumentException">配置文件类型错误</exception> public static ISoraService CreateService(ISoraConfig config, Action <Exception> crashAction = null) { return(config switch { ClientConfig s1 => new SoraWebsocketClient(s1, crashAction), ServerConfig s2 => new SoraWebsocketServer(s2, crashAction), _ => throw new ArgumentException("接收到了不认识的 Sora 配置对象。") });
internal ConnectionManager(ISoraConfig config) { HeartBeatTimeOut = config.HeartBeatTimeOut; }
/// <summary> /// 创建 Sora 服务实例 /// </summary> /// <param name="config">服务器配置</param> /// <param name="crashAction">发生未处理异常时的回调</param> /// <returns>Sora 服务实例</returns> public static ISoraService CreateInstance(ISoraConfig config, Action <Exception> crashAction = null) => config switch {