Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
feat(#471): no breaking change in remote connection, use root path fo…
Browse files Browse the repository at this point in the history
…r socket
  • Loading branch information
peterpeterparker committed Nov 23, 2019
1 parent c6bf51f commit 21718cd
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 18 deletions.
4 changes: 2 additions & 2 deletions backend/src/socket-io-remote.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
let rooms = [];

module.exports = (server) => {
const socketIO = require('socket.io').listen(server, {'transports': ['websocket', 'xhr-polling'], path: '/remote'});
const socketIO = require('socket.io').listen(server, {'transports': ['websocket', 'xhr-polling']});

socketIO.set('origins', '*:*');

console.log('\x1b[36m%s\x1b[0m', '[DeckDeckGo]', 'Socket listening. Path: /remote');
console.log('\x1b[36m%s\x1b[0m', '[DeckDeckGo]', 'Socket listening. Path: /');

socketIO.sockets.on('connection', (socket) => {
socket.on('rooms', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ export class CommunicationService {
this.socket = io.connect(url, {
'reconnectionAttempts': 5,
'transports': ['websocket', 'xhr-polling'],
'query': 'type=app',
'path': '/remote'
'query': 'type=app'
});

this.socket.on('connect', async () => {
Expand Down
2 changes: 0 additions & 2 deletions webcomponents/remote/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export namespace Components {
'prevSlide': (slideAnimation?: boolean) => Promise<void>;
'room': string;
'slideTo': (index: number, speed?: number) => Promise<void>;
'socketPath': string;
'socketUrl': string;
'updateReveal': (reveal: boolean) => Promise<void>;
'updateSlide': (index: number, slide: DeckdeckgoSlideDefinition) => Promise<void>;
Expand Down Expand Up @@ -63,7 +62,6 @@ declare namespace LocalJSX {
'onEvent'?: (event: CustomEvent<DeckdeckgoEvent>) => void;
'onState'?: (event: CustomEvent<ConnectionState>) => void;
'room'?: string;
'socketPath'?: string;
'socketUrl'?: string;
'width'?: number;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export class DeckdeckgoRemote {

@Prop() room: string;
@Prop() socketUrl: string;
@Prop() socketPath: string;

@Prop() width: number;
@Prop() height: number;
Expand Down Expand Up @@ -185,11 +184,6 @@ export class DeckdeckgoRemote {
await this.initConnect();
}

@Watch('socketPath')
async onSocketPathChange() {
await this.initConnect();
}

private async initConnect() {
if (!this.autoConnect) {
return;
Expand All @@ -208,7 +202,6 @@ export class DeckdeckgoRemote {

this.communicationService.room = this.room;
this.communicationService.socketUrl = this.socketUrl;
this.communicationService.socketPath = this.socketPath;

await this.communicationService.disconnect();
await this.communicationService.connect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const dataChannelOptions = {
};

const DEFAULT_SOCKET_URL: string = 'https://api.deckdeckgo.com';
const DEFAULT_SOCKET_PATH: string = '/remote';

export enum ConnectionState {
DISCONNECTED,
Expand All @@ -56,7 +55,6 @@ export class CommunicationService {

room: string;
socketUrl: string;
socketPath: string;

private state: BehaviorSubject<ConnectionState> = new BehaviorSubject<ConnectionState>(ConnectionState.DISCONNECTED);
private event: Subject<DeckdeckgoEvent> = new Subject<DeckdeckgoEvent>();
Expand All @@ -81,15 +79,13 @@ export class CommunicationService {
}

const url: string = this.socketUrl ? this.socketUrl : DEFAULT_SOCKET_URL;
const path: string = this.socketPath ? this.socketPath : DEFAULT_SOCKET_PATH;

this.state.next(ConnectionState.CONNECTING);

this.socket = io.connect(url, {
'reconnectionAttempts': 5,
'transports': ['websocket', 'xhr-polling'],
'query': 'type=app',
'path': path
'query': 'type=app'
});

this.socket.on('connect', async () => {
Expand Down

0 comments on commit 21718cd

Please sign in to comment.