Content-Length: 324008 | pFad | http://github.com/NetAsmCom/Socketify/commit/3b9a5c26d90fc3376b8f63d0b33aad5185f54100

5B Implement API Basics · NetAsmCom/Socketify@3b9a5c2 · GitHub
Skip to content

Commit 3b9a5c2

Browse files
committed
Implement API Basics
1 parent e9222d7 commit 3b9a5c2

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

Extensions/Chrome/socketify.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
window.socketify = {
22
connect: function (encrypt) {
3+
window.postMessage({
4+
type: "socketify-outbound",
5+
action: "connect",
6+
encrypt: (typeof encrypt === typeof true) && encrypt
7+
}, "*");
38
},
49
send: function (reliable, message) {
10+
window.postMessage({
11+
type: "socketify-outbound",
12+
action: "send",
13+
reliable: (typeof reliable === typeof true) && reliable,
14+
message: message || {}
15+
}, "*");
516
},
617
disconnect: function () {
18+
window.postMessage({
19+
type: "socketify-outbound",
20+
action: "disconnect"
21+
}, "*");
722
},
823
isConnected: false,
924
isEncrypted: false,
@@ -17,5 +32,19 @@ window.addEventListener("message", function (event) {
1732
return;
1833
}
1934

20-
// TODO
35+
switch (event.data.action) {
36+
case "setProps":
37+
window.socketify.isConnected = event.data.isConnected;
38+
window.socketify.isEncrypted = event.data.isEncrypted;
39+
break;
40+
case "onConnect":
41+
window.socketify.onConnect();
42+
break;
43+
case "onReceive":
44+
window.socketify.onReceive(event.data.reliable, event.data.message);
45+
break;
46+
case "onDisconnect":
47+
window.socketify.onDisconnect(event.data.error);
48+
break;
49+
}
2150
}, false);

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/NetAsmCom/Socketify/commit/3b9a5c26d90fc3376b8f63d0b33aad5185f54100

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy