mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-23 21:45:42 +03:00
Preparing all the models for websockets
This commit is contained in:
parent
7bce24a850
commit
0f0509c2d4
13 changed files with 366 additions and 1 deletions
|
@ -24,10 +24,13 @@ import com.bluelinelabs.logansquare.annotation.JsonField;
|
|||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.squareup.moshi.Json;
|
||||
|
||||
import org.parceler.Parcel;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonObject
|
||||
@Parcel
|
||||
public class AuthParametersWebSocketMessage {
|
||||
@JsonField(name = "userid")
|
||||
String userid;
|
||||
|
|
|
@ -24,10 +24,13 @@ import com.bluelinelabs.logansquare.annotation.JsonField;
|
|||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.squareup.moshi.Json;
|
||||
|
||||
import org.parceler.Parcel;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonObject
|
||||
@Parcel
|
||||
public class AuthWebSocketMessage {
|
||||
@JsonField(name = "url")
|
||||
String url;
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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.JsonObject;
|
||||
|
||||
import org.parceler.Parcel;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonObject
|
||||
@Parcel
|
||||
public class BaseSignalingWebSocketMessage extends BaseWebSocketMessage {
|
||||
}
|
|
@ -23,11 +23,14 @@ 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
|
||||
public class BaseWebSocketMessage {
|
||||
@Parcel
|
||||
public class BaseWebSocketMessage{
|
||||
@JsonField(name = "type")
|
||||
String type;
|
||||
}
|
||||
|
|
|
@ -24,10 +24,13 @@ import com.bluelinelabs.logansquare.annotation.JsonField;
|
|||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.squareup.moshi.Json;
|
||||
|
||||
import org.parceler.Parcel;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonObject
|
||||
@Parcel
|
||||
public class HelloOverallWebSocketMessage extends BaseWebSocketMessage {
|
||||
@JsonField(name = "hello")
|
||||
HelloWebSocketMessage helloWebSocketMessage;
|
||||
|
|
|
@ -24,10 +24,13 @@ import com.bluelinelabs.logansquare.annotation.JsonField;
|
|||
import com.bluelinelabs.logansquare.annotation.JsonObject;
|
||||
import com.squareup.moshi.Json;
|
||||
|
||||
import org.parceler.Parcel;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonObject
|
||||
@Parcel
|
||||
public class HelloWebSocketMessage {
|
||||
@JsonField(name = "version")
|
||||
String version;
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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 RecipientWebSocketMessage {
|
||||
@JsonField(name = "type")
|
||||
String type;
|
||||
|
||||
@JsonField(name = "sessionid")
|
||||
String sessionId;
|
||||
}
|
|
@ -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 RequestOfferOverallWebSocketMessage extends BaseWebSocketMessage {
|
||||
@JsonField(name = "message")
|
||||
RequestOfferSignalingMessage requestOfferOverallWebSocketMessage;
|
||||
}
|
|
@ -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.squareup.moshi.Json;
|
||||
|
||||
import org.parceler.Parcel;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonObject
|
||||
@Parcel
|
||||
public class RequestOfferSignalingMessage {
|
||||
@JsonField(name = "recipient")
|
||||
RecipientWebSocketMessage recipientWebSocketMessage;
|
||||
|
||||
@JsonField(name = "data")
|
||||
SignalingDataWebSocketMessageForOffer signalingDataWebSocketMessageForOffer;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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.rooms.RoomOverall;
|
||||
|
||||
import org.parceler.Parcel;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@JsonObject
|
||||
@Parcel
|
||||
public class RoomOverallWebSocketMessage extends BaseWebSocketMessage {
|
||||
@JsonField(name = "room")
|
||||
RoomOverallWebSocketMessage roomOverallWebSocketMessage;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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 RoomWebSocketMessage {
|
||||
@JsonField(name = "roomid")
|
||||
String roomId;
|
||||
|
||||
@JsonField(name = "sessionid")
|
||||
String sessiondId;
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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 SignalingDataWebSocketMessageForOffer {
|
||||
@JsonField(name = "type")
|
||||
String type;
|
||||
|
||||
@JsonField(name = "roomType")
|
||||
String roomType;
|
||||
}
|
|
@ -20,8 +20,23 @@
|
|||
|
||||
package com.nextcloud.talk.webrtc;
|
||||
|
||||
import com.google.android.gms.common.api.Api;
|
||||
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.NCSignalingMessage;
|
||||
import com.nextcloud.talk.models.json.websocket.AuthParametersWebSocketMessage;
|
||||
import com.nextcloud.talk.models.json.websocket.AuthWebSocketMessage;
|
||||
import com.nextcloud.talk.models.json.websocket.HelloOverallWebSocketMessage;
|
||||
import com.nextcloud.talk.models.json.websocket.HelloWebSocketMessage;
|
||||
import com.nextcloud.talk.models.json.websocket.RecipientWebSocketMessage;
|
||||
import com.nextcloud.talk.models.json.websocket.RequestOfferOverallWebSocketMessage;
|
||||
import com.nextcloud.talk.models.json.websocket.RequestOfferSignalingMessage;
|
||||
import com.nextcloud.talk.models.json.websocket.RoomOverallWebSocketMessage;
|
||||
import com.nextcloud.talk.models.json.websocket.RoomWebSocketMessage;
|
||||
import com.nextcloud.talk.models.json.websocket.SignalingDataWebSocketMessageForOffer;
|
||||
import com.nextcloud.talk.utils.ApiUtils;
|
||||
import com.tinder.scarlet.Scarlet;
|
||||
import com.tinder.scarlet.messageadapter.moshi.MoshiMessageAdapter;
|
||||
import com.tinder.scarlet.retry.LinearBackoffStrategy;
|
||||
|
@ -76,4 +91,76 @@ public class ScarletHelper {
|
|||
return externalSignaling;
|
||||
}
|
||||
}
|
||||
|
||||
public HelloOverallWebSocketMessage getAssembledHelloModel(UserEntity userEntity, String ticket) {
|
||||
HelloOverallWebSocketMessage helloOverallWebSocketMessage = new HelloOverallWebSocketMessage();
|
||||
helloOverallWebSocketMessage.setType("hello");
|
||||
HelloWebSocketMessage helloWebSocketMessage = new HelloWebSocketMessage();
|
||||
helloWebSocketMessage.setVersion("1.0");
|
||||
AuthWebSocketMessage authWebSocketMessage = new AuthWebSocketMessage();
|
||||
authWebSocketMessage.setUrl(ApiUtils.getUrlForExternalServerAuthBackend(userEntity.getBaseUrl()));
|
||||
AuthParametersWebSocketMessage authParametersWebSocketMessage = new AuthParametersWebSocketMessage();
|
||||
authParametersWebSocketMessage.setTicket(ticket);
|
||||
authParametersWebSocketMessage.setUserid(userEntity.getUserId());
|
||||
authWebSocketMessage.setAuthParametersWebSocketMessage(authParametersWebSocketMessage);
|
||||
helloWebSocketMessage.setAuthWebSocketMessage(authWebSocketMessage);
|
||||
return helloOverallWebSocketMessage;
|
||||
}
|
||||
|
||||
public HelloOverallWebSocketMessage getAssembledHelloModelForResume(String resumeId) {
|
||||
HelloOverallWebSocketMessage helloOverallWebSocketMessage = new HelloOverallWebSocketMessage();
|
||||
helloOverallWebSocketMessage.setType("hello");
|
||||
HelloWebSocketMessage helloWebSocketMessage = new HelloWebSocketMessage();
|
||||
helloWebSocketMessage.setVersion("1.0");
|
||||
helloWebSocketMessage.setResumeid(resumeId);
|
||||
return helloOverallWebSocketMessage;
|
||||
}
|
||||
|
||||
public RoomOverallWebSocketMessage getAssembledJoinOrLeaveRoomModel(String roomId, String sessionId) {
|
||||
RoomOverallWebSocketMessage roomOverallWebSocketMessage = new RoomOverallWebSocketMessage();
|
||||
roomOverallWebSocketMessage.setType("room");
|
||||
RoomWebSocketMessage roomWebSocketMessage = new RoomWebSocketMessage();
|
||||
roomWebSocketMessage.setRoomId(roomId);
|
||||
roomWebSocketMessage.setSessiondId(sessionId);
|
||||
return roomOverallWebSocketMessage;
|
||||
}
|
||||
|
||||
public RequestOfferOverallWebSocketMessage getAssembledRequestOfferModel(String sessionId, String roomType) {
|
||||
RequestOfferOverallWebSocketMessage requestOfferOverallWebSocketMessage = new RequestOfferOverallWebSocketMessage();
|
||||
requestOfferOverallWebSocketMessage.setType("message");
|
||||
|
||||
RequestOfferSignalingMessage requestOfferSignalingMessage = new RequestOfferSignalingMessage();
|
||||
|
||||
RecipientWebSocketMessage recipientWebSocketMessage = new RecipientWebSocketMessage();
|
||||
recipientWebSocketMessage.setType("session");
|
||||
recipientWebSocketMessage.setSessionId(sessionId);
|
||||
requestOfferSignalingMessage.setRecipientWebSocketMessage(recipientWebSocketMessage);
|
||||
|
||||
SignalingDataWebSocketMessageForOffer signalingDataWebSocketMessageForOffer = new SignalingDataWebSocketMessageForOffer();
|
||||
signalingDataWebSocketMessageForOffer.setRoomType(roomType);
|
||||
signalingDataWebSocketMessageForOffer.setType("requestoffer");
|
||||
requestOfferSignalingMessage.setSignalingDataWebSocketMessageForOffer(signalingDataWebSocketMessageForOffer);
|
||||
|
||||
requestOfferOverallWebSocketMessage.setRequestOfferOverallWebSocketMessage(requestOfferSignalingMessage);
|
||||
return requestOfferOverallWebSocketMessage;
|
||||
}
|
||||
|
||||
/*
|
||||
- (void)sendCallMessage:(NCSignalingMessage *)message
|
||||
{
|
||||
NSDictionary *messageDict = @{
|
||||
@"type": @"message",
|
||||
@"message": @{
|
||||
@"recipient": @{
|
||||
@"type": @"session",
|
||||
@"sessionid": message.to
|
||||
},
|
||||
@"data": [message functionDict]
|
||||
}
|
||||
};
|
||||
|
||||
[self sendMessage:messageDict];
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue