import type { SocketApp } from './SocketApp'
import type { AppConnection } from './SocketConnect'
import { SocketCache } from './SocketCache'
export declare class SocketControl<Name extends SocketApp.Roles> {
  readonly name: Name
  constructor(name: Name)
  private _connections
  get connections(): AppConnection[]
  has(conn: string | AppConnection): boolean
  readonly tigger: Map<
    SocketApp.StoreNames<Name>,
    (conn: AppConnection) => void
  >
  static DISCONNECT_KEEPTIME: number
  mount(conn: AppConnection, dura?: number): void
  unmount(conn: AppConnection): void
  broadcast(event: SocketApp.SocketCallBack): void
  readonly stores: {
    [P in SocketApp.StoreNames<Name>]?: SocketCache<
      Name,
      P,
      SocketApp.Store<Name, P>,
      keyof SocketApp.Store<Name, P>
    >
  }
  defineCache<
    Cache extends SocketApp.StoreNames<Name>,
    Val extends SocketApp.Store<Name, Cache>,
    Key extends keyof Val
  >(
    name: Cache,
    init: (() => Promise<Val[]>) | (() => Val[]) | Val[],
    key: Key
  ): SocketCache<Name, Cache, Val, Key>
}
export declare const socketControl: {
  readonly group: SocketApp.Roles[]
  readonly connections: AppConnection[]
  broadcast(event: SocketApp.SocketCallBack, ...roles: SocketApp.Roles[]): void
  isRoles(conn: string | AppConnection, role: SocketApp.Roles): boolean
  setRoles(
    conn: AppConnection,
    roles: MaybeArray<SocketApp.Roles>,
    dura?: number
  ): void
  defineCache<
    Role extends SocketApp.Roles,
    Cache_1 extends SocketApp.StoreNames<Role>,
    Val extends SocketApp.Store<Role, Cache_1>,
    Key extends keyof Val
  >(
    role: Role,
    name: Cache_1,
    init: Val[] | (() => Promise<Val[]>) | (() => Val[]),
    key: Key
  ): SocketCache<Role, Cache_1, Val, Key>
}
declare type MaybeArray<T> = T | Array<T>
export {}
