npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hackaton-uikit-audio-controller

v0.4.0

Published

Client wrapper for donstu hackaton backend

Downloads

2

Readme

Быстрый старт

Установка

npm i hackaton-uikit-audio-controller

Использование

import { AudioController } from "hackaton-uikit-audio-controller";

const audioController = new AudioController("https://somebaseurl.com");

// ***

someConnectButton.addEventListener("click", async () => {
  if (audioController.isConnected()) {
    await audioController.disconnect();
  } else {
    audioController.connect();
  }
});

someMicrophoneButton.addEventListener("click", async () => {
  if (audioController.isSpeakEnabled()) {
    await audioController.speakOff();
  } else {
    await audioController.speakOn();
  }
});

Методы

AudioController(baseUrl: string, bufferSize?: number = 2048)

Основной конструктор класса

  • baseUrl - URL адрес сокет-сервера
  • bufferSize - размер буфера аудио пакетов
const audioController = new AudioController("https://somebaseurl.com", 2048);

isConnected(): boolean

Состояние подключения, true если подключение активно, false если нет.

const isConnected = audioController.isConnected();

connect(): Promise<void>

Процедура подключения к сокет-серверу.

audioController.connect();

disconnect(): Promise<void>

Процедура отключения от сокет-сервера.

Важно: после отключения от сервера, микрофон пользователя также отключается.

audioController.diconnect().then(() => {
  console.log("Disconnected");
});

isSpeakerEnabled(): boolean

Процедура получения статуса микрофона, true если микрофон в данный момент используется и данные передаются на сервер, false если микрофон не активен.

audioController.diconnect().then(() => {
  console.log("Disconnected");
});

getUsers() => Promise<string[]>

Функция получения подключенных пользователей, возвращает массив, состоящий из id сокетов пользователей.

audioController.getUsers().then((users) => {
  for (const user of users) {
    console.log(user);
  }
});

sendAudioSticker(sticker: string) => void

Функция отправки аудио стикеров

Доступные на данный момент стикеры: airhorn, boi, bruh, cricket, wow

audioController.sendAudioSticker("bruh");

Ивенты

Пример использования ивента

audioController.events.on(EventType, (data) => {
  console.log(data);
});

Типы ивентов

Ивент подключения юзера к серверу:

user_join: { id: string }

audioController.events.on("user_join", (user) => {
  someLocalList.push(user.id);
});

Ивент отключения юзера от сервера:

user_leave: { id: string }


Ивент приема звука от пользователя

user_speak: { id: string }


Ивент отключения юзера от сервера:

user_leave: { id: string }