Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 917401c

Browse files
committed
Add host events to the api and to tipeeestream
1 parent d868bf0 commit 917401c

File tree

7 files changed

+115
-2
lines changed

7 files changed

+115
-2
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.codeoverflow.chatoverflow.api.io.dto.stat.stream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.User;
4+
5+
import java.time.OffsetDateTime;
6+
7+
/**
8+
* Another streamer has started hosting your stream on their channel.
9+
*/
10+
public class Host<T extends User> {
11+
private final T streamer;
12+
private final String message;
13+
private final int viewerCount;
14+
private final OffsetDateTime time;
15+
16+
public Host(T streamer, String message, int viewerCount, OffsetDateTime time) {
17+
this.streamer = streamer;
18+
this.message = message;
19+
this.viewerCount = viewerCount;
20+
this.time = time;
21+
}
22+
23+
/**
24+
* Get the streamer which started hosting you.
25+
*
26+
* @return streamer that hosts you
27+
*/
28+
public T getStreamer() {
29+
return streamer;
30+
}
31+
32+
/**
33+
* Get the message from the streamer that has started hosting you.
34+
*
35+
* @return the host message
36+
*/
37+
public String getMessage() {
38+
return message;
39+
}
40+
41+
/**
42+
* Get the viewer count with which the streamer is hosting you.
43+
*
44+
* @return the viewer count of the host
45+
*/
46+
public int getViewerCount() {
47+
return viewerCount;
48+
}
49+
50+
/**
51+
* Get the time when the streamer has started hosting you.
52+
*
53+
* @return host time
54+
*/
55+
public OffsetDateTime getTime() {
56+
return time;
57+
}
58+
}

src/main/java/org/codeoverflow/chatoverflow/api/io/dto/stat/stream/Raid.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public Raid(T streamer, String message, int viewerCount, OffsetDateTime time) {
2121
}
2222

2323
/**
24-
* Get the stream which started the raid.
24+
* Get the streamer which started the raid.
2525
*
2626
* @return initiating streamer
2727
*/
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.codeoverflow.chatoverflow.api.io.dto.stat.stream.tipeeestream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.User;
4+
import org.codeoverflow.chatoverflow.api.io.dto.stat.stream.Host;
5+
6+
import java.time.OffsetDateTime;
7+
8+
public class TipeeestreamHost extends Host<User> {
9+
public TipeeestreamHost(User streamer, String message, int viewerCount, OffsetDateTime time) {
10+
super(streamer, message, viewerCount, time);
11+
}
12+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.codeoverflow.chatoverflow.api.io.event.stream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.stat.stream.Host;
4+
5+
/**
6+
* Generic event for hosts
7+
*/
8+
public abstract class HostEvent<T extends Host> {
9+
10+
private final T info;
11+
12+
protected HostEvent(T cheerInfo) {
13+
this.info = cheerInfo;
14+
}
15+
16+
/**
17+
* Get the Host object that contains all information about that host
18+
*
19+
* @return all info about that host
20+
*/
21+
public T getInfo() {
22+
return info;
23+
}
24+
}

src/main/java/org/codeoverflow/chatoverflow/api/io/event/stream/RaidEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* Generic event for raids
77
*/
8-
public class RaidEvent<T extends Raid> {
8+
public abstract class RaidEvent<T extends Raid> {
99

1010
private final T info;
1111

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.codeoverflow.chatoverflow.api.io.event.stream.tipeeestream;
2+
3+
import org.codeoverflow.chatoverflow.api.io.dto.stat.stream.tipeeestream.TipeeestreamHost;
4+
import org.codeoverflow.chatoverflow.api.io.event.stream.HostEvent;
5+
6+
public class TipeeestreamHostEvent extends HostEvent<TipeeestreamHost> implements TipeeestreamEvent {
7+
public TipeeestreamHostEvent(TipeeestreamHost cheerInfo) {
8+
super(cheerInfo);
9+
}
10+
}

src/main/java/org/codeoverflow/chatoverflow/api/io/input/event/TipeeestreamEventInput.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,13 @@ default void registerCheerEventHandler(Consumer<TipeeestreamCheerEvent> eventHan
5252
default void registerRaidEventHandler(Consumer<TipeeestreamRaidEvent> eventHandler) {
5353
registerEventHandler(eventHandler, TipeeestreamRaidEvent.class);
5454
}
55+
56+
/**
57+
* Register an event handler that listens to all {@link TipeeestreamHostEvent}
58+
*
59+
* @param eventHandler consumer that receives the Events
60+
*/
61+
default void registerHostEventHandler(Consumer<TipeeestreamHostEvent> eventHandler) {
62+
registerEventHandler(eventHandler, TipeeestreamHostEvent.class);
63+
}
5564
}

0 commit comments

Comments
 (0)