Skip to content

Commit

Permalink
Basic code structure and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
alula committed May 17, 2019
1 parent 1c811cc commit 1908629
Show file tree
Hide file tree
Showing 8 changed files with 238 additions and 2 deletions.
71 changes: 71 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,74 @@ buildNumber.properties

# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
.idea/modules.xml
.idea/*.iml
.idea/modules
*.iml
*.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Kyoko
Copyright (c) 2019 Gabriel Konopiński (gabixdev)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# koe
Tiny and embeddable Discord voice library based on Netty.

Tiny and embeddable Discord voice library based on Netty, aiming for high performance and reduced garbage collection.

##### Non-goals

- Support for sending PCM data - Koe only accepts Opus frames to keep things simple, set up an encoder yourself or use [lavaplayer](https://github.com/sedmelluq/lavaplayer).
- Voice receiving support - [it's not supported by Discord anyway](https://github.com/discordapp/discord-api-docs/issues/808#issuecomment-458863743).
42 changes: 42 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>moe.kyokobot</groupId>
<artifactId>koe</artifactId>
<version>1.0.0-SNAPSHOT</version>

<repositories>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.36.Final</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>13.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
33 changes: 33 additions & 0 deletions src/main/java/moe/kyokobot/koe/Koe.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package moe.kyokobot.koe;

import org.jetbrains.annotations.NotNull;

import java.util.Objects;

public class Koe {
private final KoeOptions options;

public Koe(@NotNull KoeOptions options) {
this.options = Objects.requireNonNull(options);
}

@NotNull
public KoeClient newClient(long clientId) {
return new KoeClient(clientId);
}

@NotNull
public KoeOptions getOptions() {
return options;
}

@NotNull
public static Koe koe(@NotNull KoeOptions options) {
return new Koe(options);
}

@NotNull
public static Koe koe() {
return new Koe(KoeOptions.defaultOptions());
}
}
43 changes: 43 additions & 0 deletions src/main/java/moe/kyokobot/koe/KoeClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package moe.kyokobot.koe;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.Closeable;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class KoeClient implements Closeable {
private final long clientId;
private final Map<Long, KoeConnection> connections;

public KoeClient(long clientId) {
this.clientId = clientId;
this.connections = new ConcurrentHashMap<>();
}

public long getClientId() {
return clientId;
}

@NotNull
public KoeConnection createConnection(long guildId) {
return connections.computeIfAbsent(guildId, KoeConnection::new);
}

@Nullable
public KoeConnection getConnection(long guildId) {
return connections.get(guildId);
}

@NotNull
public Map<Long, KoeConnection> getConnections() {
return Collections.unmodifiableMap(connections);
}

@Override
public void close() {

}
}
13 changes: 13 additions & 0 deletions src/main/java/moe/kyokobot/koe/KoeConnection.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package moe.kyokobot.koe;

public class KoeConnection {
private final long guildId;

public KoeConnection(long guildId) {
this.guildId = guildId;
}

public long getGuildId() {
return guildId;
}
}
28 changes: 28 additions & 0 deletions src/main/java/moe/kyokobot/koe/KoeOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package moe.kyokobot.koe;

import io.netty.channel.EventLoopGroup;
import io.netty.channel.epoll.Epoll;
import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;

import java.util.Objects;

public class KoeOptions {
private final EventLoopGroup eventLoopGroup;

KoeOptions(EventLoopGroup eventLoopGroup) {
this.eventLoopGroup = Objects.requireNonNull(eventLoopGroup);
}

public EventLoopGroup getEventLoopGroup() {
return eventLoopGroup;
}

public static KoeOptions defaultOptions() {
var eventLoop = Epoll.isAvailable()
? new EpollEventLoopGroup()
: new NioEventLoopGroup();

return new KoeOptions(eventLoop);
}
}

0 comments on commit 1908629

Please sign in to comment.