Skip to content

Commit

Permalink
- create a common message project
Browse files Browse the repository at this point in the history
  • Loading branch information
ritzalam committed Jun 10, 2015
1 parent b89d3b2 commit 17a39a6
Show file tree
Hide file tree
Showing 119 changed files with 7,416 additions and 3 deletions.
57 changes: 54 additions & 3 deletions bbb-common-message/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,56 @@
.classpath
.DS_Store
._.DS_Store*
.metadata
.project
.classpath
.settings
bin
build
.history
.worksheet
gen
**/*.swp
**/*~.nib
**/build/
**/*.pbxuser
**/*.perspective
**/*.perspectivev3
*.xcworkspace
*.xcuserdatad
**/target
target
*.iml
project/*.ipr
project/*.iml
project/*.iws
project/out
project/*/target
project/target
project/*/bin
project/*/build
project/*.iml
project/*/*.iml
project/.idea
project/.idea/*
.idea
.idea/*
.idea/**/*
.DS_Store
project/.DS_Store
project/*/.DS_Store
tm.out
tmlog*.log
*.tm*.epoch
out/
provisioning/.vagrant
provisioning/*/.vagrant
provisioning/*/*.known
/sbt/akka-patterns-store/
/daemon/src/build/
*.lock
log/
tmp/
build/
akka-patterns-store/
lib_managed/
.cache
bin/

77 changes: 77 additions & 0 deletions bbb-common-message/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@


name := "bbb-common-message"

organization := "org.bigbluebutton"

version := "0.0.1"

// We want to have our jar files in lib_managed dir.
// This way we'll have the right path when we import
// into eclipse.
retrieveManaged := true

testOptions in Test += Tests.Argument(TestFrameworks.Specs2, "html", "console", "junitxml")

testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-h", "target/scalatest-reports")

libraryDependencies ++= {
Seq(
"com.google.code.gson" % "gson" % "1.7.1"
)}

seq(Revolver.settings: _*)

//-----------
// Packaging
//
// Reference:
// http://xerial.org/blog/2014/03/24/sbt/
// http://www.scala-sbt.org/sbt-pgp/usage.html
// http://www.scala-sbt.org/0.13/docs/Using-Sonatype.html
// http://central.sonatype.org/pages/requirements.html
// http://central.sonatype.org/pages/releasing-the-deployment.html
//-----------

// Build pure Java lib (i.e. without scala)
// Do not append Scala versions to the generated artifacts
crossPaths := false

// This forbids including Scala related libraries into the dependency
autoScalaLibrary := false


publishTo := Some(Resolver.file("file", new File(Path.userHome.absolutePath+"/dev/repo/maven-repo/releases" )) )

publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}

// Enables publishing to maven repo
publishMavenStyle := true

publishArtifact in Test := false

pomIncludeRepository := { _ => false }

pomExtra := (
<scm>
<url>git@github.com:bigbluebutton/bigbluebutton.git</url>
<connection>scm:git:git@github.com:bigbluebutton/bigbluebutton.git</connection>
</scm>
<developers>
<developer>
<id>ritzalam</id>
<name>Richard Alam</name>
<url>http://www.bigbluebutton.org</url>
</developer>
</developers>)

licenses := Seq("LGPL-3.0" -> url("http://opensource.org/licenses/LGPL-3.0"))

homepage := Some(url("http://www.bigbluebutton.org"))

Empty file.
1 change: 1 addition & 0 deletions bbb-common-message/project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=0.13.8
8 changes: 8 additions & 0 deletions bbb-common-message/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
addSbtPlugin("io.spray" % "sbt-revolver" % "0.7.2")

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.2.0")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")



Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.bigbluebutton.common.messages;

import java.util.HashMap;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

public class AssignPresenterRequestMessage implements IPublishedMessage {
public static final String ASSIGN_PRESENTER_REQUEST = "assign_presenter_request_message";
public final String VERSION = "0.0.1";

public final String meetingId;
public final String newPresenterId;
public final String newPresenterName;
public final String assignedBy;

public AssignPresenterRequestMessage(String meetingID, String newPresenterId, String newPresenterName, String assignedBy) {
this.meetingId = meetingID;
this.newPresenterId = newPresenterId;
this.newPresenterName = newPresenterName;
this.assignedBy = assignedBy;
}

public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put(Constants.MEETING_ID, meetingId);
payload.put(Constants.NEW_PRESENTER_ID, newPresenterId);
payload.put(Constants.NEW_PRESENTER_NAME, newPresenterName);
payload.put(Constants.ASSIGNED_BY, assignedBy);

java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(ASSIGN_PRESENTER_REQUEST, VERSION, null);

return MessageBuilder.buildJson(header, payload);
}

public static AssignPresenterRequestMessage fromJson(String message) {
JsonParser parser = new JsonParser();
JsonObject obj = (JsonObject) parser.parse(message);

if (obj.has("header") && obj.has("payload")) {
JsonObject header = (JsonObject) obj.get("header");
JsonObject payload = (JsonObject) obj.get("payload");

if (header.has("name")) {
String messageName = header.get("name").getAsString();
if (ASSIGN_PRESENTER_REQUEST.equals(messageName)) {
if (payload.has(Constants.MEETING_ID)
&& payload.has(Constants.NEW_PRESENTER_ID)
&& payload.has(Constants.NEW_PRESENTER_NAME)
&& payload.has(Constants.ASSIGNED_BY)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
String newPresenterId = payload.get(Constants.NEW_PRESENTER_ID).getAsString();
String newPresenterName = payload.get(Constants.NEW_PRESENTER_NAME).getAsString();
String assignedBy = payload.get(Constants.ASSIGNED_BY).getAsString();

return new AssignPresenterRequestMessage(meetingId, newPresenterId, newPresenterName, assignedBy);
}
}
}
}

return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.bigbluebutton.common.messages;

import java.util.HashMap;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

public class BbbAppsIsAliveMessage implements ISubscribedMessage {
public static final String BBB_APPS_IS_ALIVE = "bbb_apps_is_alive_message";
public static final String VERSION = "0.0.1";

public static final String TIMESTAMP = "timestamp";
public static final String STARTED_ON = "started_on";

public final Long timestamp;
public final Long startedOn;

public BbbAppsIsAliveMessage(Long startedOn, Long timestamp) {
this.startedOn = startedOn;
this.timestamp = timestamp;
}

public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put(TIMESTAMP, timestamp);
payload.put(STARTED_ON, timestamp);

java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(BBB_APPS_IS_ALIVE, VERSION, null);
return MessageBuilder.buildJson(header, payload);
}

public static BbbAppsIsAliveMessage fromJson(String message) {
JsonParser parser = new JsonParser();
JsonObject obj = (JsonObject) parser.parse(message);
if (obj.has("header") && obj.has("payload")) {
JsonObject header = (JsonObject) obj.get("header");
JsonObject payload = (JsonObject) obj.get("payload");

if (header.has("name")) {
String messageName = header.get("name").getAsString();
if (BBB_APPS_IS_ALIVE.equals(messageName)) {

if (payload.has(TIMESTAMP) && payload.has(STARTED_ON)) {
Long timestamp = payload.get(TIMESTAMP).getAsLong();
Long startedOn = payload.get(STARTED_ON).getAsLong();
return new BbbAppsIsAliveMessage(startedOn, timestamp);
}
}
}
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package org.bigbluebutton.common.messages;

import java.util.ArrayList;
import java.util.HashMap;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;


public class BroadcastLayoutMessage implements ISubscribedMessage {
public static final String BROADCAST_LAYOUT = "broadcast_layout_message";
public static final String VERSION = "0.0.1";

public static final String SET_BY_USERID = "set_by_userid";
public static final String LAYOUT = "layout";
public static final String LOCKED = "locked";
public static final String USERS = "users";

public final String meetingId;
public final String setByUserid;
public final String layout;
public final Boolean locked;
public final ArrayList<String> users;

public BroadcastLayoutMessage(String meetingId, String setByUserid, String layout, Boolean locked, ArrayList<String> users) {
this.meetingId = meetingId;
this.setByUserid = setByUserid;
this.layout = layout;
this.locked = locked;
this.users = users;
}

public String toJson() {
HashMap<String, Object> payload = new HashMap<String, Object>();
payload.put(Constants.MEETING_ID, meetingId);
payload.put(SET_BY_USERID, setByUserid);
payload.put(LAYOUT, layout);
payload.put(LOCKED, locked);
payload.put(USERS, users);

java.util.HashMap<String, Object> header = MessageBuilder.buildHeader(BROADCAST_LAYOUT, VERSION, null);

return MessageBuilder.buildJson(header, payload);
}

public static BroadcastLayoutMessage fromJson(String message) {
JsonParser parser = new JsonParser();
JsonObject obj = (JsonObject) parser.parse(message);

if (obj.has("header") && obj.has("payload")) {
JsonObject header = (JsonObject) obj.get("header");
JsonObject payload = (JsonObject) obj.get("payload");

if (header.has("name")) {
String messageName = header.get("name").getAsString();
if (BROADCAST_LAYOUT.equals(messageName)) {
if (payload.has(Constants.MEETING_ID)
&& payload.has(LOCKED)
&& payload.has(SET_BY_USERID)
&& payload.has(USERS)
&& payload.has(LAYOUT)) {
String id = payload.get(Constants.MEETING_ID).getAsString();
String setByUserid = payload.get(SET_BY_USERID).getAsString();
String layout = payload.get(LAYOUT).getAsString();
Boolean locked = payload.get(LOCKED).getAsBoolean();
JsonArray usersArr = (JsonArray) payload.get(USERS);

Util util = new Util();

ArrayList<String> users = util.extractUserids(usersArr);
return new BroadcastLayoutMessage(id, setByUserid, layout, locked, users);
}
}
}
}
return null;

}
}
Loading

0 comments on commit 17a39a6

Please sign in to comment.