diff options
author | Andrew Comminos <andrewcomminos@gmail.com> | 2013-07-31 07:45:12 +0400 |
---|---|---|
committer | Andrew Comminos <andrewcomminos@gmail.com> | 2013-07-31 07:45:12 +0400 |
commit | 0003aa679da8422031ee260e20ed3e9e74a81452 (patch) | |
tree | 5b3f0f255b9f7ac85717109e452463d49d4d2176 | |
parent | f4ed3c399385e5b314b909eec6f9116b8bfbb1f8 (diff) |
Added more service protocol functionality.
4 files changed, 47 insertions, 14 deletions
diff --git a/src/instrumentTest/java/com/morlunk/jumble/test/ServiceTest.java b/src/instrumentTest/java/com/morlunk/jumble/test/ServiceTest.java index 77cd8e7..16c83b8 100644 --- a/src/instrumentTest/java/com/morlunk/jumble/test/ServiceTest.java +++ b/src/instrumentTest/java/com/morlunk/jumble/test/ServiceTest.java @@ -183,7 +183,7 @@ public class ServiceTest extends ServiceTestCase<JumbleService> { } } - public void testSendMessages() throws RemoteException { + public void _testSendMessages() throws RemoteException { List<Channel> channelList = mBinder.getChannelList(); List<User> userList = mBinder.getUserList(); for(Channel channel : channelList) @@ -215,7 +215,14 @@ public class ServiceTest extends ServiceTestCase<JumbleService> { mBinder.kickBanUser(user.getSession(), String.format(TEST_KICK_MESSAGE, user.getName()), false); } - public void testCreateChannel() throws RemoteException { + public void _testCreateChannel() throws RemoteException { mBinder.createChannel(0, String.format(TEST_CHANNEL_NAME, UUID.randomUUID().toString()), "", 0, false); } + + /** + * Gives the tester time to just observe the client from another client. Useful for testing something, I'm sure. + */ + public void testSandbox() throws InterruptedException{ + Thread.sleep(500000); + } } diff --git a/src/main/aidl/com/morlunk/jumble/IJumbleService.aidl b/src/main/aidl/com/morlunk/jumble/IJumbleService.aidl index 1f11c84..aa5b70d 100644 --- a/src/main/aidl/com/morlunk/jumble/IJumbleService.aidl +++ b/src/main/aidl/com/morlunk/jumble/IJumbleService.aidl @@ -25,15 +25,20 @@ interface IJumbleService { void disconnect(); boolean isConnected(); - // Data + // Session and users int getSession(); + User getSessionUser(); Server getConnectedServer(); - User getUserWithId(int id); - Channel getChannelWithId(int id); + User getUser(int id); + Channel getChannel(int id); List getUserList(); List getChannelList(); - // Actions + // Audio actions + int getTransmitMode(); + void setTalkingState(boolean talking); + + // Server actions void joinChannel(int channel); void createChannel(int parent, String name, String description, int position, boolean temporary); //void setTexture(byte[] texture); @@ -51,6 +56,7 @@ interface IJumbleService { void setSelfMuteDeafState(boolean mute, boolean deaf); //void announceRecordingState(boolean recording); + // Observation void registerObserver(in IJumbleObserver observer); void unregisterObserver(in IJumbleObserver observer); }
\ No newline at end of file diff --git a/src/main/java/com/morlunk/jumble/Constants.java b/src/main/java/com/morlunk/jumble/Constants.java index e286971..eb9522b 100644 --- a/src/main/java/com/morlunk/jumble/Constants.java +++ b/src/main/java/com/morlunk/jumble/Constants.java @@ -51,6 +51,10 @@ public class Constants { public static final int PROTOCOL_MINOR = 2; public static final int PROTOCOL_PATCH = 4; + public static final int TRANSMIT_VOICE_ACTIVITY = 0; + public static final int TRANSMIT_PUSH_TO_TALK = 1; + public static final int TRANSMIT_CONTINUOUS = 2; + public static final int PROTOCOL_VERSION = (PROTOCOL_MAJOR << 16) | (PROTOCOL_MINOR << 8) | PROTOCOL_PATCH; public static final String PROTOCOL_STRING = PROTOCOL_MAJOR+"."+PROTOCOL_MINOR+"."+PROTOCOL_PATCH; public static final int DEFAULT_PORT = 64738; diff --git a/src/main/java/com/morlunk/jumble/JumbleService.java b/src/main/java/com/morlunk/jumble/JumbleService.java index 914659c..17d2106 100644 --- a/src/main/java/com/morlunk/jumble/JumbleService.java +++ b/src/main/java/com/morlunk/jumble/JumbleService.java @@ -27,14 +27,14 @@ import android.util.Log; import com.morlunk.jumble.audio.AudioOutput; import com.morlunk.jumble.db.Database; import com.morlunk.jumble.model.Channel; -import com.morlunk.jumble.net.ChannelHandler; import com.morlunk.jumble.model.Server; import com.morlunk.jumble.model.User; -import com.morlunk.jumble.net.TextMessageHandler; -import com.morlunk.jumble.net.UserHandler; +import com.morlunk.jumble.net.ChannelHandler; import com.morlunk.jumble.net.JumbleConnection; import com.morlunk.jumble.net.JumbleConnectionException; import com.morlunk.jumble.net.JumbleTCPMessageType; +import com.morlunk.jumble.net.TextMessageHandler; +import com.morlunk.jumble.net.UserHandler; import com.morlunk.jumble.protobuf.Mumble; import java.security.Security; @@ -54,7 +54,7 @@ public class JumbleService extends Service implements JumbleConnection.JumbleCon public static final String EXTRAS_CERTIFICATE = "certificate"; public static final String EXTRAS_CERTIFICATE_PASSWORD = "certificate_password"; public static final String EXTRAS_DETECTION_THRESHOLD = "detection_threshold"; - public static final String EXTRAS_PUSH_TO_TALK = "use_ptt"; + public static final String EXTRAS_TRANSMIT_MODE = "transmit_mode"; public static final String EXTRAS_USE_OPUS = "use_opus"; public static final String EXTRAS_FORCE_TCP = "force_tcp"; public static final String EXTRAS_CLIENT_NAME = "client_name"; @@ -68,7 +68,7 @@ public class JumbleService extends Service implements JumbleConnection.JumbleCon public byte[] mCertificate; public String mCertificatePassword; public int mDetectionThreshold; - public boolean mUsePushToTalk; + public int mTransmitMode; public boolean mUseOpus; public boolean mForceTcp; public String mClientName; @@ -107,17 +107,22 @@ public class JumbleService extends Service implements JumbleConnection.JumbleCon } @Override + public User getSessionUser() throws RemoteException { + return mUserHandler.getUser(getSession()); + } + + @Override public Server getConnectedServer() throws RemoteException { return mServer; } @Override - public User getUserWithId(int id) throws RemoteException { + public User getUser(int id) throws RemoteException { return mUserHandler.getUser(id); } @Override - public Channel getChannelWithId(int id) throws RemoteException { + public Channel getChannel(int id) throws RemoteException { return mChannelHandler.getChannel(id); } @@ -132,6 +137,16 @@ public class JumbleService extends Service implements JumbleConnection.JumbleCon } @Override + public int getTransmitMode() throws RemoteException { + return mTransmitMode; + } + + @Override + public void setTalkingState(boolean talking) throws RemoteException { + + } + + @Override public void joinChannel(int channel) throws RemoteException { Mumble.UserState.Builder usb = Mumble.UserState.newBuilder(); usb.setSession(mConnection.getSession()); @@ -249,7 +264,7 @@ public class JumbleService extends Service implements JumbleConnection.JumbleCon mCertificate = extras.getByteArray(EXTRAS_CERTIFICATE); mCertificatePassword = extras.getString(EXTRAS_CERTIFICATE_PASSWORD); mDetectionThreshold = extras.getInt(EXTRAS_DETECTION_THRESHOLD, 1400); - mUsePushToTalk = extras.getBoolean(EXTRAS_PUSH_TO_TALK, false); + mTransmitMode = extras.getInt(EXTRAS_TRANSMIT_MODE, Constants.TRANSMIT_VOICE_ACTIVITY); mUseOpus = extras.getBoolean(EXTRAS_USE_OPUS, true); mForceTcp = extras.getBoolean(EXTRAS_FORCE_TCP, false); mClientName = extras.containsKey(EXTRAS_CLIENT_NAME) ? extras.getString(EXTRAS_CLIENT_NAME) : "Jumble"; @@ -402,6 +417,7 @@ public class JumbleService extends Service implements JumbleConnection.JumbleCon * @param info An HTML info string to be messaged to the client. */ public void logInfo(final String info) { + Log.v(Constants.TAG, info); notifyObservers(new ObserverRunnable() { @Override public void run(IJumbleObserver observer) throws RemoteException { |