Comparing version 1.0.8 to 1.1.0
/* | ||
* Orange ocast-sdk | ||
* version : 1.0.8 | ||
* version : 1.1.0 | ||
* Copyright (C) 2017 Orange | ||
@@ -1232,6 +1232,25 @@ */ | ||
if (typeof returnCode !== "undefined") { | ||
this.sendReply(transport.id, transport.src, { | ||
name: transport.message.data.name, | ||
params: { code: returnCode } | ||
}); | ||
if (returnCode.hasOwnProperty("then")) { | ||
returnCode.then(result => { | ||
if (typeof result !== "undefined") { | ||
this.sendReply(transport.id, transport.src, { | ||
name: transport.message.data.name, | ||
params: { code: result } | ||
}); | ||
} | ||
}, e => { | ||
Log$1.error(TAG$1 + "Error while executing " + methodDescriptor.methodName + " with error ", e); | ||
if (transport.type === EnumTransport.COMMAND) { | ||
this.sendReply(transport.id, transport.src, { | ||
name: transport.message.data.name, | ||
params: { code: exports.EnumError.UNKNOWN_ERROR } | ||
}); | ||
} | ||
}); | ||
} else { | ||
this.sendReply(transport.id, transport.src, { | ||
name: transport.message.data.name, | ||
params: { code: returnCode } | ||
}); | ||
} | ||
} | ||
@@ -1448,3 +1467,3 @@ } catch (e) { | ||
try { | ||
return this.notifier[method].apply(this, args); | ||
return this.notifier[method].apply(this.notifier, args); | ||
} catch (e) { | ||
@@ -1620,7 +1639,15 @@ Log$1.error(TAG$1 + "Implementation error on Notifier Method " + method + " : ", e); | ||
start() { | ||
this.ws = new WebSocket(this.url); | ||
this.ws.onopen = this.onConnected.bind(this); | ||
this.ws.onmessage = this.onMessage.bind(this); | ||
this.ws.onerror = this.onError.bind(this); | ||
this.ws.onclose = this.onClose.bind(this); | ||
return new Promise((resolve, reject) => { | ||
this.ws = new WebSocket(this.url); | ||
this.ws.onopen = () => { | ||
resolve(); | ||
this.onConnected(); | ||
}; | ||
this.ws.onmessage = this.onMessage.bind(this); | ||
this.ws.onerror = e => { | ||
reject(e); | ||
this.onError(e); | ||
}; | ||
this.ws.onclose = this.onClose.bind(this); | ||
}); | ||
} | ||
@@ -1727,3 +1754,3 @@ /** | ||
*/ | ||
onConnected(event) { | ||
onConnected() { | ||
Log$5.info(TAG$4 + "websocket onConnected event"); | ||
@@ -1779,2 +1806,3 @@ this.updateSocketChannel(); | ||
exports.OCast = OCast; | ||
exports.Transport = Transport; | ||
@@ -1781,0 +1809,0 @@ return exports; |
@@ -44,3 +44,3 @@ import { Transport } from "../protocol/transport"; | ||
*/ | ||
private sendMessage(message); | ||
private sendMessage; | ||
} |
@@ -12,3 +12,3 @@ export declare enum EnumMediaMessage { | ||
MUTE = "mute", | ||
PREPARE = "prepare", | ||
PREPARE = "prepare" | ||
} |
@@ -45,3 +45,3 @@ import { Metadata } from "../protocol/metadata"; | ||
*/ | ||
doPrepare(url: string, title: string, subtitle: string, logo: string, mediaType: EnumMedia, transferMode: EnumTransferMode, autoplay: boolean, frequency: number, options: any): EnumError; | ||
doPrepare(url: string, title: string, subtitle: string, logo: string, mediaType: EnumMedia, transferMode: EnumTransferMode, autoplay: boolean, frequency: number, options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -53,3 +53,3 @@ * track | ||
*/ | ||
doTrack(type: EnumTrack, trackId: string, enabled: boolean, options: any): EnumError; | ||
doTrack(type: EnumTrack, trackId: string, enabled: boolean, options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -60,3 +60,3 @@ * resume | ||
*/ | ||
doResume(options: any): EnumError; | ||
doResume(options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -67,3 +67,3 @@ * pause | ||
*/ | ||
doPause(options: any): EnumError; | ||
doPause(options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -74,3 +74,3 @@ * stop | ||
*/ | ||
doStop(options: any): EnumError; | ||
doStop(options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -81,3 +81,3 @@ * close | ||
*/ | ||
doClose(options: any): EnumError; | ||
doClose(options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -89,3 +89,3 @@ * on Seek | ||
*/ | ||
doSeek(position: number, options: any): EnumError; | ||
doSeek(position: number, options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -97,3 +97,3 @@ * Implements volume command | ||
*/ | ||
doVolume(volume: number, options: any): EnumError; | ||
doVolume(volume: number, options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -105,3 +105,3 @@ * Send a mute command | ||
*/ | ||
doMute(mute: boolean, options: any): EnumError; | ||
doMute(mute: boolean, options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -133,3 +133,3 @@ * getPlaybackStatus | ||
onUpdateMetadata(metadata: Metadata): void; | ||
private callNotifier(method, args); | ||
private callNotifier; | ||
} |
@@ -21,3 +21,3 @@ import { Metadata } from "../protocol/metadata"; | ||
*/ | ||
onPrepare(url: string, title: string, subtitle: string, logo: string, mediaType: EnumMedia, transferMode: EnumTransferMode, autoplay: boolean, frequency: number, options: any): EnumError; | ||
onPrepare(url: string, title: string, subtitle: string, logo: string, mediaType: EnumMedia, transferMode: EnumTransferMode, autoplay: boolean, frequency: number, options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -28,3 +28,3 @@ * pause | ||
*/ | ||
onPause(options: any): EnumError; | ||
onPause(options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -38,3 +38,3 @@ * track | ||
*/ | ||
onTrack(type: EnumTrack, trackId: string, enabled: boolean, options: any): EnumError; | ||
onTrack(type: EnumTrack, trackId: string, enabled: boolean, options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -45,3 +45,3 @@ * resume | ||
*/ | ||
onResume(options: any): EnumError; | ||
onResume(options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -52,3 +52,3 @@ * stop | ||
*/ | ||
onStop(options: any): EnumError; | ||
onStop(options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -59,3 +59,3 @@ * close | ||
*/ | ||
onClose(options: any): EnumError; | ||
onClose(options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -67,3 +67,3 @@ * on Seek | ||
*/ | ||
onSeek(position: number, options: any): EnumError; | ||
onSeek(position: number, options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -75,3 +75,3 @@ * Implements volume command | ||
*/ | ||
onVolume(volume: number, options: any): EnumError; | ||
onVolume(volume: number, options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -83,3 +83,3 @@ * Send a mute command | ||
*/ | ||
onMute(mute: boolean, options: any): EnumError; | ||
onMute(mute: boolean, options: any): EnumError | Promise<EnumError>; | ||
/** | ||
@@ -86,0 +86,0 @@ * @param {PlaybackStatus} status |
@@ -30,3 +30,3 @@ import { Channel } from "./channel"; | ||
*/ | ||
private sendConnected(); | ||
private sendConnected; | ||
} |
@@ -19,1 +19,2 @@ import "./channel/media.notifier"; | ||
export { OCast } from "./ocast"; | ||
export { Transport } from "./protocol/transport"; |
@@ -80,4 +80,4 @@ import { MediaChannel } from "../channel/media.channel"; | ||
protected onUpdateMetadata(event: any): void; | ||
private onUpdateStatus(event); | ||
private updateStatus(status); | ||
private onUpdateStatus; | ||
private updateStatus; | ||
} |
@@ -69,4 +69,4 @@ import { Metadata } from "../protocol/metadata"; | ||
*/ | ||
private logTrackMissingFields(track, type, trackNumber, properties); | ||
private updateTracks(); | ||
private logTrackMissingFields; | ||
private updateTracks; | ||
} |
@@ -21,3 +21,3 @@ import { Channel } from "./channel/channel"; | ||
*/ | ||
start(): void; | ||
start(): Promise<void>; | ||
/** | ||
@@ -53,3 +53,3 @@ * Create a Custom Channel | ||
*/ | ||
private setupMediaChannel(); | ||
private setupMediaChannel; | ||
/** | ||
@@ -59,3 +59,3 @@ * Initialize MediaChannel | ||
*/ | ||
private setupWebappChannel(); | ||
private setupWebappChannel; | ||
/** | ||
@@ -66,3 +66,3 @@ * publish message on internal Bus | ||
*/ | ||
private publish(transport); | ||
private publish; | ||
/** | ||
@@ -73,5 +73,5 @@ * Handler to receive messages | ||
*/ | ||
private onMessage(event); | ||
private onError(error); | ||
private onClose(close); | ||
private onMessage; | ||
private onError; | ||
private onClose; | ||
/** | ||
@@ -81,3 +81,3 @@ * Send Connected Event when Connection Opened | ||
*/ | ||
private onConnected(event); | ||
private onConnected; | ||
/** | ||
@@ -87,3 +87,3 @@ * Set websocket on all channels | ||
*/ | ||
private updateSocketChannel(); | ||
private updateSocketChannel; | ||
} |
@@ -28,3 +28,3 @@ /** | ||
/** In the namespace org.ocast.media, the command is not implemented by the application */ | ||
IMPLEMENTATION_ERROR = 2400, | ||
IMPLEMENTATION_ERROR = 2400 | ||
} |
@@ -7,3 +7,3 @@ /** | ||
IMAGE = "image", | ||
AUDIO = "audio", | ||
AUDIO = "audio" | ||
} |
@@ -9,3 +9,3 @@ /** | ||
PAUSED = 3, | ||
BUFFERING = 4, | ||
BUFFERING = 4 | ||
} |
@@ -7,3 +7,3 @@ /** | ||
TEXT = "text", | ||
AUDIO = "audio", | ||
AUDIO = "audio" | ||
} |
@@ -6,3 +6,3 @@ /** | ||
STREAMED = "streamed", | ||
BUFFERED = "buffered", | ||
BUFFERED = "buffered" | ||
} |
@@ -7,3 +7,3 @@ /** | ||
COMMAND = "command", | ||
EVENT = "event", | ||
EVENT = "event" | ||
} |
{ | ||
"name": "ocast-sdk", | ||
"version": "1.0.8", | ||
"version": "1.1.0", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": ">=8.6.0" |
@@ -142,8 +142,27 @@ /* | ||
try { | ||
const returnCode: string | void = methodDescriptor.method.apply(this, paramsToCallMethod); | ||
const returnCode: EnumError | Promise<EnumError> = methodDescriptor.method.apply(this, paramsToCallMethod); | ||
if (typeof (returnCode) !== "undefined") { | ||
this.sendReply(transport.id, transport.src, { | ||
name: transport.message.data.name, | ||
params: { code: returnCode }, | ||
}); | ||
if (returnCode.hasOwnProperty("then")) { | ||
(<Promise<EnumError>> returnCode).then((result: EnumError) => { | ||
if (typeof (result) !== "undefined") { | ||
this.sendReply(transport.id, transport.src, { | ||
name: transport.message.data.name, | ||
params: { code: result }, | ||
}); | ||
} | ||
}, (e) => { | ||
Log.error(TAG + "Error while executing " + methodDescriptor.methodName + " with error ", e); | ||
if (transport.type === EnumTransport.COMMAND) { | ||
this.sendReply(transport.id, transport.src, { | ||
name: transport.message.data.name, | ||
params: { code: EnumError.UNKNOWN_ERROR }, | ||
}); | ||
} | ||
}); | ||
} else { | ||
this.sendReply(transport.id, transport.src, { | ||
name: transport.message.data.name, | ||
params: { code: returnCode }, | ||
}); | ||
} | ||
} | ||
@@ -189,3 +208,4 @@ } catch (e) { | ||
public doPrepare(url: string, title: string, subtitle: string, logo: string, mediaType: EnumMedia, | ||
transferMode: EnumTransferMode, autoplay: boolean, frequency: number, options: any): EnumError { | ||
transferMode: EnumTransferMode, autoplay: boolean, frequency: number, | ||
options: any): EnumError | Promise<EnumError> { | ||
Log.debug(TAG + "onPrepare Receives (" + url + "," + title + "," + subtitle + "," + logo + "," + mediaType + | ||
@@ -218,3 +238,3 @@ "," + transferMode + "," + autoplay + "," + frequency + "," + options); | ||
}) | ||
public doTrack(type: EnumTrack, trackId: string, enabled: boolean, options: any): EnumError { | ||
public doTrack(type: EnumTrack, trackId: string, enabled: boolean, options: any): EnumError | Promise<EnumError> { | ||
Log.debug(TAG + "onTrack"); | ||
@@ -239,3 +259,3 @@ if (!this.media) { | ||
}) | ||
public doResume(options: any): EnumError { | ||
public doResume(options: any): EnumError | Promise<EnumError> { | ||
Log.debug(TAG + "onResume"); | ||
@@ -265,3 +285,3 @@ if (!this.media) { | ||
}) | ||
public doPause(options: any): EnumError { | ||
public doPause(options: any): EnumError | Promise<EnumError> { | ||
Log.debug(TAG + "onPause"); | ||
@@ -286,3 +306,3 @@ if (!this.media) { | ||
}) | ||
public doStop(options: any): EnumError { | ||
public doStop(options: any): EnumError | Promise<EnumError> { | ||
Log.debug("onStop"); | ||
@@ -308,3 +328,3 @@ if (!this.media) { | ||
}) | ||
public doClose(options: any): EnumError { | ||
public doClose(options: any): EnumError | Promise<EnumError> { | ||
Log.debug(TAG + "onClose"); | ||
@@ -332,3 +352,3 @@ if (!this.media) { | ||
}) | ||
public doSeek(position: number, options: any): EnumError { | ||
public doSeek(position: number, options: any): EnumError | Promise<EnumError> { | ||
@@ -357,3 +377,3 @@ Log.debug(TAG + "onSeek"); | ||
}) | ||
public doVolume(volume: number, options: any): EnumError { | ||
public doVolume(volume: number, options: any): EnumError | Promise<EnumError> { | ||
Log.debug(TAG + "onVolume"); | ||
@@ -381,3 +401,3 @@ if (!this.media) { | ||
}) | ||
public doMute(mute: boolean, options: any): EnumError { | ||
public doMute(mute: boolean, options: any): EnumError | Promise<EnumError> { | ||
Log.debug(TAG + "onMute"); | ||
@@ -474,6 +494,6 @@ if (!this.media) { | ||
private callNotifier(method: string, args): EnumError { | ||
private callNotifier(method: string, args): EnumError | Promise<EnumError> { | ||
if (this.notifier !== undefined) { | ||
try { | ||
return this.notifier[method].apply(this, args); | ||
return this.notifier[method].apply(this.notifier, args); | ||
} catch (e) { | ||
@@ -480,0 +500,0 @@ Log.error(TAG + "Implementation error on Notifier Method " + method + " : ", e); |
@@ -40,3 +40,4 @@ /* | ||
onPrepare(url: string, title: string, subtitle: string, logo: string, mediaType: EnumMedia, | ||
transferMode: EnumTransferMode, autoplay: boolean, frequency: number, options: any): EnumError; | ||
transferMode: EnumTransferMode, autoplay: boolean, frequency: number, | ||
options: any): EnumError | Promise<EnumError>; | ||
@@ -48,3 +49,3 @@ /** | ||
*/ | ||
onPause(options: any): EnumError; | ||
onPause(options: any): EnumError | Promise<EnumError>; | ||
@@ -59,3 +60,3 @@ /** | ||
*/ | ||
onTrack(type: EnumTrack, trackId: string, enabled: boolean, options): EnumError; | ||
onTrack(type: EnumTrack, trackId: string, enabled: boolean, options): EnumError | Promise<EnumError>; | ||
@@ -67,3 +68,3 @@ /** | ||
*/ | ||
onResume(options: any): EnumError; | ||
onResume(options: any): EnumError | Promise<EnumError>; | ||
@@ -75,3 +76,3 @@ /** | ||
*/ | ||
onStop(options: any): EnumError; | ||
onStop(options: any): EnumError | Promise<EnumError>; | ||
@@ -83,3 +84,3 @@ /** | ||
*/ | ||
onClose(options: any): EnumError; | ||
onClose(options: any): EnumError | Promise<EnumError>; | ||
@@ -92,3 +93,3 @@ /** | ||
*/ | ||
onSeek(position: number, options: any): EnumError; | ||
onSeek(position: number, options: any): EnumError | Promise<EnumError>; | ||
@@ -101,3 +102,3 @@ /** | ||
*/ | ||
onVolume(volume: number, options: any): EnumError; | ||
onVolume(volume: number, options: any): EnumError | Promise<EnumError>; | ||
@@ -110,3 +111,3 @@ /** | ||
*/ | ||
onMute(mute: boolean, options: any): EnumError; | ||
onMute(mute: boolean, options: any): EnumError | Promise<EnumError>; | ||
@@ -113,0 +114,0 @@ /** |
@@ -35,1 +35,2 @@ /* | ||
export {OCast} from "./ocast"; | ||
export { Transport } from "./protocol/transport"; |
@@ -50,8 +50,16 @@ /* | ||
*/ | ||
public start() { | ||
this.ws = new WebSocket(this.url); | ||
this.ws.onopen = this.onConnected.bind(this); | ||
this.ws.onmessage = this.onMessage.bind(this); | ||
this.ws.onerror = this.onError.bind(this); | ||
this.ws.onclose = this.onClose.bind(this); | ||
public start(): Promise<void> { | ||
return new Promise<void>((resolve, reject) => { | ||
this.ws = new WebSocket(this.url); | ||
this.ws.onopen = () => { | ||
resolve(); | ||
this.onConnected(); | ||
}; | ||
this.ws.onmessage = this.onMessage.bind(this); | ||
this.ws.onerror = (e: Event) => { | ||
reject(e); | ||
this.onError(e); | ||
}; | ||
this.ws.onclose = this.onClose.bind(this); | ||
}); | ||
} | ||
@@ -172,3 +180,3 @@ | ||
*/ | ||
private onConnected(event) { | ||
private onConnected() { | ||
Log.info(TAG + "websocket onConnected event"); | ||
@@ -175,0 +183,0 @@ this.updateSocketChannel(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
627148
8363