-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
238 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |