Skip to content

Commit 315d81a

Browse files
committed
app-launched-message
1 parent abca85d commit 315d81a

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

src/GlobalInputMessageConnector.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,12 @@ export default class GlobalInputMessageConnector {
8888
onError && onError(message);
8989
}
9090
const onRegistered = options.onRegistered;
91-
options.onRegistered = (connectionCode) => {
92-
resolve({ type: "device", connectionCode });
93-
onRegistered && onRegistered(connectionCode);
91+
options.onRegistered = (connectionCode, registeredInfo) => {
92+
resolve({ type: "device", connectionCode, registeredInfo });
93+
if(registeredInfo){
94+
registeredInfo.url=this.url;
95+
}
96+
onRegistered && onRegistered(connectionCode,registeredInfo);
9497
}
9598
const onRegisterFailed = options.onRegisterFailed;
9699
options.onRegisterFailed = (error) => {
@@ -157,7 +160,26 @@ export default class GlobalInputMessageConnector {
157160
that.onRegistered(options);
158161
if (options.onRegistered) {
159162
const connectionCode = that.buildInputCodeData();
160-
options.onRegistered(connectionCode);
163+
options.onRegistered(connectionCode, registeredMessage.registeredInfo);
164+
if(options.onClientAppLaunched){
165+
that.socket.on("app/launched", function (data) {
166+
if(options.onClientAppLaunched){
167+
if(!data){
168+
console.log("onClientAppLaunched data received empty data");
169+
return;
170+
}
171+
try{
172+
data=JSON.parse(data);
173+
}
174+
catch(error){
175+
console.log("failed-to-parse-launched-data:"+data);
176+
return;
177+
}
178+
options.onClientAppLaunched(data);
179+
}
180+
});
181+
}
182+
161183
}
162184
if (options.onSocket) {
163185
options.onSocket(that.socket);

0 commit comments

Comments
 (0)