浏览代码

Prepare more models for websockets communication

Mario Danic 6 年之前
父节点
当前提交
a488ebafdf

+ 36 - 0
app/src/main/java/com/nextcloud/talk/models/json/websocket/CallOverallWebSocketMessage.java

@@ -0,0 +1,36 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.models.json.websocket;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Data
+@JsonObject
+@Parcel
+public class CallOverallWebSocketMessage extends BaseWebSocketMessage {
+    @JsonField(name = "message")
+    CallWebSocketMessage callWebSocketMessage;
+}

+ 40 - 0
app/src/main/java/com/nextcloud/talk/models/json/websocket/CallWebSocketMessage.java

@@ -0,0 +1,40 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Mario Danic
+ * Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.talk.models.json.websocket;
+
+import com.bluelinelabs.logansquare.annotation.JsonField;
+import com.bluelinelabs.logansquare.annotation.JsonObject;
+import com.nextcloud.talk.models.json.signaling.NCMessageWrapper;
+
+import org.parceler.Parcel;
+
+import lombok.Data;
+
+@Data
+@JsonObject
+@Parcel
+public class CallWebSocketMessage {
+    @JsonField(name = "recipient")
+    RecipientWebSocketMessage recipientWebSocketMessage;
+
+    @JsonField(name = "data")
+    NCMessageWrapper ncMessageWrapper;
+}

+ 17 - 17
app/src/main/java/com/nextcloud/talk/webrtc/ScarletHelper.java

@@ -25,9 +25,12 @@ import com.nextcloud.talk.api.ExternalSignaling;
 import com.nextcloud.talk.application.NextcloudTalkApplication;
 import com.nextcloud.talk.models.database.UserEntity;
 import com.nextcloud.talk.models.json.rooms.Conversation;
+import com.nextcloud.talk.models.json.signaling.NCMessageWrapper;
 import com.nextcloud.talk.models.json.signaling.NCSignalingMessage;
 import com.nextcloud.talk.models.json.websocket.AuthParametersWebSocketMessage;
 import com.nextcloud.talk.models.json.websocket.AuthWebSocketMessage;
+import com.nextcloud.talk.models.json.websocket.CallOverallWebSocketMessage;
+import com.nextcloud.talk.models.json.websocket.CallWebSocketMessage;
 import com.nextcloud.talk.models.json.websocket.HelloOverallWebSocketMessage;
 import com.nextcloud.talk.models.json.websocket.HelloWebSocketMessage;
 import com.nextcloud.talk.models.json.websocket.RecipientWebSocketMessage;
@@ -145,22 +148,19 @@ public class ScarletHelper {
         return requestOfferOverallWebSocketMessage;
     }
 
-    /*
-    - (void)sendCallMessage:(NCSignalingMessage *)message
-    {
-    NSDictionary *messageDict = @{
-                                  @"type": @"message",
-                                  @"message": @{
-                                          @"recipient": @{
-                                                  @"type": @"session",
-                                                  @"sessionid": message.to
-                                                  },
-                                          @"data": [message functionDict]
-                                          }
-                                  };
-
-    [self sendMessage:messageDict];
-    }
+    public CallOverallWebSocketMessage getAssembledCallMessageModel(NCMessageWrapper ncMessageWrapper) {
+        CallOverallWebSocketMessage callOverallWebSocketMessage = new CallOverallWebSocketMessage();
+        callOverallWebSocketMessage.setType("message");
+
+        CallWebSocketMessage callWebSocketMessage = new CallWebSocketMessage();
+
+        RecipientWebSocketMessage recipientWebSocketMessage = new RecipientWebSocketMessage();
+        recipientWebSocketMessage.setType("session");
+        recipientWebSocketMessage.setSessionId(ncMessageWrapper.getSignalingMessage().getTo());
+        callWebSocketMessage.setRecipientWebSocketMessage(recipientWebSocketMessage);
+        callWebSocketMessage.setNcMessageWrapper(ncMessageWrapper);
 
-     */
+        callOverallWebSocketMessage.setCallWebSocketMessage(callWebSocketMessage);
+        return callOverallWebSocketMessage;
+    }
 }