working rtc connection
This commit is contained in:
@@ -2,7 +2,7 @@ package gltronic.oozik.business;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.web.socket.TextMessage;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
public interface IRoomManager {
|
||||
@@ -10,7 +10,7 @@ public interface IRoomManager {
|
||||
public void leave(WebSocketSession session);
|
||||
public void createRoom(WebSocketSession session) throws InterruptedException, IOException;
|
||||
public void connectRoom(WebSocketSession session, String roomName) throws InterruptedException, IOException;
|
||||
public void followRTC(WebSocketSession session, JSONObject jsonObject) throws InterruptedException, IOException;
|
||||
public void followRTC(WebSocketSession session, TextMessage message) throws InterruptedException, IOException;
|
||||
public void sendMessage(WebSocketSession session, String type, String message) throws InterruptedException, IOException;
|
||||
public void sendServerInfos(WebSocketSession session) throws InterruptedException, IOException;
|
||||
}
|
||||
@@ -74,14 +74,17 @@ public class RoomManager implements IRoomManager{
|
||||
return;
|
||||
}
|
||||
|
||||
String roomAdmin = rooms.getKey(roomName);
|
||||
sendMessage(session, "coonectRoom", roomAdmin);
|
||||
String roomAdmin = rooms.get(roomName);
|
||||
sendMessage(session, "connectRoom", roomAdmin);
|
||||
|
||||
String userName = users.getKey(session);
|
||||
System.err.println("[ROOM] Connection to room "+roomName+" ("+roomAdmin+") by "+userName);
|
||||
}
|
||||
|
||||
public void followRTC(WebSocketSession session, JSONObject jsonObject) throws InterruptedException, IOException {
|
||||
public void followRTC(WebSocketSession session, TextMessage message) throws InterruptedException, IOException {
|
||||
String payload = message.getPayload();
|
||||
JSONObject jsonObject = new JSONObject(payload);
|
||||
String target = (String) jsonObject.get("target");
|
||||
String type = (String) jsonObject.get("type");
|
||||
String data = (String) jsonObject.get("data");
|
||||
|
||||
if (target == null) {
|
||||
sendMessage(session, "error", "no target");
|
||||
@@ -96,7 +99,11 @@ public class RoomManager implements IRoomManager{
|
||||
}
|
||||
|
||||
System.err.println("[ROOM] Foward RTC");
|
||||
sendMessage(targetSession, type, data);
|
||||
followMessage(targetSession, message);
|
||||
}
|
||||
|
||||
public void followMessage (WebSocketSession session, TextMessage message) throws IOException {
|
||||
session.sendMessage(message);
|
||||
}
|
||||
|
||||
public void sendMessage(WebSocketSession session, String type, String message) throws InterruptedException, IOException {
|
||||
|
||||
@@ -43,10 +43,12 @@ public class SocketHandler extends TextWebSocketHandler {
|
||||
break;
|
||||
case "leave":
|
||||
roomManager.leave(session);
|
||||
break;
|
||||
case "offer":
|
||||
case "answer":
|
||||
case "candidate":
|
||||
roomManager.followRTC(session, jsonObject);
|
||||
roomManager.followRTC(session, message);
|
||||
break;
|
||||
default:
|
||||
roomManager.sendMessage(session, "error", "unknow command");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user