Skip to content

Commit

Permalink
Signaling android final.
Browse files Browse the repository at this point in the history
  • Loading branch information
michalchudziak committed Aug 17, 2016
1 parent cc2f511 commit 2254387
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Session.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NativeModules, NativeAppEventEmitter } from 'react-native';
import { NativeModules, NativeAppEventEmitter, DeviceEventEmitter, Platform } from 'react-native';
const SessionManager = NativeModules.OpenTokSessionManager;

const listener = null;
Expand All @@ -8,9 +8,9 @@ export const sendMessage = SessionManager.sendMessage;

export const onMessageRecieved = (callback) => {
listener = NativeAppEventEmitter.addListener(
'onMessageRecieved',
(e) => callback(e)
);
'onMessageRecieved',
(e) => callback(e)
);
};

export const stopListener = () => listener.remove();
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.RCTEventEmitter;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.modules.core.RCTNativeAppEventEmitter;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
Expand Down Expand Up @@ -33,6 +31,7 @@ public String getName() {
public void connect(String apiKey, String sessionId, String token) {
mSession = new Session(getReactApplicationContext(), apiKey, sessionId);
mSession.setSessionListener(this);
mSession.setSignalListener(this);
mSession.connect(token);
}

Expand All @@ -44,7 +43,7 @@ public void sendMessage(String message) {
protected void sendEvent(Events event, WritableMap payload) {
ReactContext reactContext = (ReactContext)getReactApplicationContext();
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.getJSModule(RCTNativeAppEventEmitter.class)
.emit(event.toString(), payload);
}

Expand Down Expand Up @@ -72,6 +71,6 @@ public void onSignalReceived(Session session, String type, String data, Connecti
WritableMap payload = Arguments.createMap();
payload.putString("data", data);

sendEvent(Events.EVENT_PUBLISH_ERROR, payload);
sendEvent(Events.EVENT_ON_MESSAGE_RECIEVED, payload);
}
}

0 comments on commit 2254387

Please sign in to comment.