Preparing all the models for websockets

This commit is contained in:
Mario Danic 2018-10-11 10:44:43 +02:00
parent 7bce24a850
commit 0f0509c2d4
13 changed files with 366 additions and 1 deletions

View file

@ -24,10 +24,13 @@ import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject; import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.squareup.moshi.Json; import com.squareup.moshi.Json;
import org.parceler.Parcel;
import lombok.Data; import lombok.Data;
@Data @Data
@JsonObject @JsonObject
@Parcel
public class AuthParametersWebSocketMessage { public class AuthParametersWebSocketMessage {
@JsonField(name = "userid") @JsonField(name = "userid")
String userid; String userid;

View file

@ -24,10 +24,13 @@ import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject; import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.squareup.moshi.Json; import com.squareup.moshi.Json;
import org.parceler.Parcel;
import lombok.Data; import lombok.Data;
@Data @Data
@JsonObject @JsonObject
@Parcel
public class AuthWebSocketMessage { public class AuthWebSocketMessage {
@JsonField(name = "url") @JsonField(name = "url")
String url; String url;

View file

@ -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 {
}

View file

@ -23,11 +23,14 @@ package com.nextcloud.talk.models.json.websocket;
import com.bluelinelabs.logansquare.annotation.JsonField; import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject; import com.bluelinelabs.logansquare.annotation.JsonObject;
import org.parceler.Parcel;
import lombok.Data; import lombok.Data;
@Data @Data
@JsonObject @JsonObject
public class BaseWebSocketMessage { @Parcel
public class BaseWebSocketMessage{
@JsonField(name = "type") @JsonField(name = "type")
String type; String type;
} }

View file

@ -24,10 +24,13 @@ import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject; import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.squareup.moshi.Json; import com.squareup.moshi.Json;
import org.parceler.Parcel;
import lombok.Data; import lombok.Data;
@Data @Data
@JsonObject @JsonObject
@Parcel
public class HelloOverallWebSocketMessage extends BaseWebSocketMessage { public class HelloOverallWebSocketMessage extends BaseWebSocketMessage {
@JsonField(name = "hello") @JsonField(name = "hello")
HelloWebSocketMessage helloWebSocketMessage; HelloWebSocketMessage helloWebSocketMessage;

View file

@ -24,10 +24,13 @@ import com.bluelinelabs.logansquare.annotation.JsonField;
import com.bluelinelabs.logansquare.annotation.JsonObject; import com.bluelinelabs.logansquare.annotation.JsonObject;
import com.squareup.moshi.Json; import com.squareup.moshi.Json;
import org.parceler.Parcel;
import lombok.Data; import lombok.Data;
@Data @Data
@JsonObject @JsonObject
@Parcel
public class HelloWebSocketMessage { public class HelloWebSocketMessage {
@JsonField(name = "version") @JsonField(name = "version")
String version; String version;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -20,8 +20,23 @@
package com.nextcloud.talk.webrtc; package com.nextcloud.talk.webrtc;
import com.google.android.gms.common.api.Api;
import com.nextcloud.talk.api.ExternalSignaling; import com.nextcloud.talk.api.ExternalSignaling;
import com.nextcloud.talk.application.NextcloudTalkApplication; 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.Scarlet;
import com.tinder.scarlet.messageadapter.moshi.MoshiMessageAdapter; import com.tinder.scarlet.messageadapter.moshi.MoshiMessageAdapter;
import com.tinder.scarlet.retry.LinearBackoffStrategy; import com.tinder.scarlet.retry.LinearBackoffStrategy;
@ -76,4 +91,76 @@ public class ScarletHelper {
return externalSignaling; 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];
}
*/
} }