summaryrefslogtreecommitdiff
path: root/src/com/encrox/twitchbot/client/messages
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/encrox/twitchbot/client/messages')
-rwxr-xr-xsrc/com/encrox/twitchbot/client/messages/Login.java49
-rwxr-xr-xsrc/com/encrox/twitchbot/client/messages/Message.java9
2 files changed, 58 insertions, 0 deletions
diff --git a/src/com/encrox/twitchbot/client/messages/Login.java b/src/com/encrox/twitchbot/client/messages/Login.java
new file mode 100755
index 0000000..b439c99
--- /dev/null
+++ b/src/com/encrox/twitchbot/client/messages/Login.java
@@ -0,0 +1,49 @@
+package com.encrox.twitchbot.client.messages;
+
+import java.io.UnsupportedEncodingException;
+
+import com.encrox.twitchbot.client.Utils;
+
+public class Login extends Message {
+
+ private byte id = 1;
+ private String username, password;
+
+ public Login(String username, String password) {
+ this.username = username;
+ this.password = password;
+ }
+
+ public Login() {
+ username = null;
+ password = null;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public byte getID() {
+ return id;
+ }
+
+ public byte[] getData() {
+ byte[] output = new byte[160];
+ try {
+ byte[] user = Utils.fill(username.getBytes("UTF-8"), 32), pass = Utils.fill(password.getBytes("UTF-8"), 128);
+ for(int i = 0; i < 32; i++)
+ output[i] = user[i];
+ for(int i = 0; i < 128; i++)
+ output[32+i] = pass[i];
+ return output;
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+}
diff --git a/src/com/encrox/twitchbot/client/messages/Message.java b/src/com/encrox/twitchbot/client/messages/Message.java
new file mode 100755
index 0000000..aac9f38
--- /dev/null
+++ b/src/com/encrox/twitchbot/client/messages/Message.java
@@ -0,0 +1,9 @@
+package com.encrox.twitchbot.client.messages;
+
+public abstract class Message {
+
+ public abstract byte getID();
+
+ public abstract byte[] getData();
+
+}