Skip to content

Commit

Permalink
Added rudimentary support for BNCS (chat service)
Browse files Browse the repository at this point in the history
  • Loading branch information
collinsmith committed Dec 2, 2019
1 parent c009982 commit b64900c
Show file tree
Hide file tree
Showing 10 changed files with 474 additions and 1 deletion.
18 changes: 18 additions & 0 deletions build.gradle
Expand Up @@ -234,6 +234,24 @@ project(":server:bnls") {
}
}

project(":server:bncs") {
apply plugin: "java"

dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
}

dependencies {
compile group: 'commons-cli', name: 'commons-cli', version: cliVersion
}

dependencies {
testCompile 'junit:junit:4.12'
}
}

project(":server:mcp") {
apply plugin: "java"

Expand Down
40 changes: 40 additions & 0 deletions core/gen/com/riiablo/net/packet/bncs/BNCS.java
@@ -0,0 +1,40 @@
// automatically generated by the FlatBuffers compiler, do not modify

package com.riiablo.net.packet.bncs;

import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.Table;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

@SuppressWarnings("unused")
public final class BNCS extends Table {
public static BNCS getRootAsBNCS(ByteBuffer _bb) { return getRootAsBNCS(_bb, new BNCS()); }
public static BNCS getRootAsBNCS(ByteBuffer _bb, BNCS obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
public BNCS __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }

public byte dataType() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 0; }
public Table data(Table obj) { int o = __offset(6); return o != 0 ? __union(obj, o) : null; }

public static int createBNCS(FlatBufferBuilder builder,
byte data_type,
int dataOffset) {
builder.startObject(2);
BNCS.addData(builder, dataOffset);
BNCS.addDataType(builder, data_type);
return BNCS.endBNCS(builder);
}

public static void startBNCS(FlatBufferBuilder builder) { builder.startObject(2); }
public static void addDataType(FlatBufferBuilder builder, byte dataType) { builder.addByte(0, dataType, 0); }
public static void addData(FlatBufferBuilder builder, int dataOffset) { builder.addOffset(1, dataOffset, 0); }
public static int endBNCS(FlatBufferBuilder builder) {
int o = builder.endObject();
return o;
}
public static void finishBNCSBuffer(FlatBufferBuilder builder, int offset) { builder.finish(offset); }
public static void finishSizePrefixedBNCSBuffer(FlatBufferBuilder builder, int offset) { builder.finishSizePrefixed(offset); }
}

14 changes: 14 additions & 0 deletions core/gen/com/riiablo/net/packet/bncs/BNCSData.java
@@ -0,0 +1,14 @@
// automatically generated by the FlatBuffers compiler, do not modify

package com.riiablo.net.packet.bncs;

public final class BNCSData {
private BNCSData() { }
public static final byte NONE = 0;
public static final byte ChatEvent = 1;

public static final String[] names = { "NONE", "ChatEvent", };

public static String name(int e) { return names[e]; }
}

46 changes: 46 additions & 0 deletions core/gen/com/riiablo/net/packet/bncs/ChatEvent.java
@@ -0,0 +1,46 @@
// automatically generated by the FlatBuffers compiler, do not modify

package com.riiablo.net.packet.bncs;

import com.google.flatbuffers.FlatBufferBuilder;
import com.google.flatbuffers.Table;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

@SuppressWarnings("unused")
public final class ChatEvent extends Table {
public static ChatEvent getRootAsChatEvent(ByteBuffer _bb) { return getRootAsChatEvent(_bb, new ChatEvent()); }
public static ChatEvent getRootAsChatEvent(ByteBuffer _bb, ChatEvent obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
public ChatEvent __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }

public byte eid() { int o = __offset(4); return o != 0 ? bb.get(o + bb_pos) : 19; }
public String name() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; }
public ByteBuffer nameAsByteBuffer() { return __vector_as_bytebuffer(6, 1); }
public ByteBuffer nameInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 6, 1); }
public String text() { int o = __offset(8); return o != 0 ? __string(o + bb_pos) : null; }
public ByteBuffer textAsByteBuffer() { return __vector_as_bytebuffer(8, 1); }
public ByteBuffer textInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 8, 1); }

public static int createChatEvent(FlatBufferBuilder builder,
byte eid,
int nameOffset,
int textOffset) {
builder.startObject(3);
ChatEvent.addText(builder, textOffset);
ChatEvent.addName(builder, nameOffset);
ChatEvent.addEid(builder, eid);
return ChatEvent.endChatEvent(builder);
}

public static void startChatEvent(FlatBufferBuilder builder) { builder.startObject(3); }
public static void addEid(FlatBufferBuilder builder, byte eid) { builder.addByte(0, eid, 19); }
public static void addName(FlatBufferBuilder builder, int nameOffset) { builder.addOffset(1, nameOffset, 0); }
public static void addText(FlatBufferBuilder builder, int textOffset) { builder.addOffset(2, textOffset, 0); }
public static int endChatEvent(FlatBufferBuilder builder) {
int o = builder.endObject();
return o;
}
}

29 changes: 29 additions & 0 deletions core/gen/com/riiablo/net/packet/bncs/EID.java
@@ -0,0 +1,29 @@
// automatically generated by the FlatBuffers compiler, do not modify

package com.riiablo.net.packet.bncs;

public final class EID {
private EID() { }
public static final byte EID_SHOWUSER = 1;
public static final byte EID_JOIN = 2;
public static final byte EID_LEAVE = 3;
public static final byte EID_WHISPER = 4;
public static final byte EID_TALK = 5;
public static final byte EID_BROADCAST = 6;
public static final byte EID_CHANNEL = 7;
public static final byte EID_USERFLAGS = 9;
public static final byte EID_WHISPERSENT = 10;
public static final byte EID_CHANNELFULL = 13;
public static final byte EID_CHANNELDOESNOTEXIST = 14;
public static final byte EID_CHANNELRESTRICTED = 15;
public static final byte EID_INFO = 18;
public static final byte EID_ERROR = 19;
public static final byte EID_IGNORE = 21;
public static final byte EID_ACCEPT = 22;
public static final byte EID_EMOTE = 23;

public static final String[] names = { "EID_SHOWUSER", "EID_JOIN", "EID_LEAVE", "EID_WHISPER", "EID_TALK", "EID_BROADCAST", "EID_CHANNEL", "", "EID_USERFLAGS", "EID_WHISPERSENT", "", "", "EID_CHANNELFULL", "EID_CHANNELDOESNOTEXIST", "EID_CHANNELRESTRICTED", "", "", "EID_INFO", "EID_ERROR", "", "EID_IGNORE", "EID_ACCEPT", "EID_EMOTE", };

public static String name(int e) { return names[e - EID_SHOWUSER]; }
}

13 changes: 13 additions & 0 deletions core/src/com/riiablo/net/bncs/BNCS.fbs
@@ -0,0 +1,13 @@
include "ChatEvent.fbs";

namespace com.riiablo.net.packet.bncs;

union BNCSData {
ChatEvent,
}

table BNCS {
data:BNCSData;
}

root_type BNCS;
27 changes: 27 additions & 0 deletions core/src/com/riiablo/net/bncs/ChatEvent.fbs
@@ -0,0 +1,27 @@
namespace com.riiablo.net.packet.bncs;

enum EID : byte {
EID_SHOWUSER = 0x01, // User in channel
EID_JOIN = 0x02, // User joined channel
EID_LEAVE = 0x03, // User left channel
EID_WHISPER = 0x04, // Recieved whisper
EID_TALK = 0x05, // Chat text
EID_BROADCAST = 0x06, // Server broadcast
EID_CHANNEL = 0x07, // Channel information
EID_USERFLAGS = 0x09, // Flags update
EID_WHISPERSENT = 0x0A, // Sent whisper
EID_CHANNELFULL = 0x0D, // Channel full
EID_CHANNELDOESNOTEXIST = 0x0E, // Channel doesn't exist
EID_CHANNELRESTRICTED = 0x0F, // Channel is restricted
EID_INFO = 0x12, // Information
EID_ERROR = 0x13, // Error message
EID_IGNORE = 0x15, // Notifies that a user has been ignored (DEFUNCT)
EID_ACCEPT = 0x16, // Notifies that a user has been unignored (DEFUNCT)
EID_EMOTE = 0x17, // Emote
}

table ChatEvent {
eid:EID = EID_ERROR;
name:string;
text:string;
}
29 changes: 29 additions & 0 deletions server/bncs/build.gradle
@@ -0,0 +1,29 @@
apply plugin: "java"

sourceCompatibility = 1.7
sourceSets.main.java.srcDirs = [ "src/" ]
sourceSets.test.java.srcDirs = [ "test/" ]

project.ext.mainClassName = "com.riiablo.server.bncs.BNCS"
project.ext.assetsDir = new File("../android/assets");

task run(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
}

task dist(type: Jar) {
from files(sourceSets.main.output.classesDir)
from files(sourceSets.main.output.resourcesDir)
from {configurations.compile.collect {zipTree(it)}}
from files(project.assetsDir);

manifest {
attributes 'Server-Class': project.mainClassName
}
}

dist.dependsOn classes

0 comments on commit b64900c

Please sign in to comment.