mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-11-08 06:28:29 +01:00
update Antunnel
This commit is contained in:
parent
8523c7fbb6
commit
51ab2d13a3
@ -3,3 +3,6 @@
|
|||||||
`Antunnel` is a client side API that allows AntOS applications to
|
`Antunnel` is a client side API that allows AntOS applications to
|
||||||
talk to server side applications via the [`antd-tunnel-pligin`](https://github.com/lxsang/antd-tunnel-plugin) plugin
|
talk to server side applications via the [`antd-tunnel-pligin`](https://github.com/lxsang/antd-tunnel-plugin) plugin
|
||||||
using a single websocket API.
|
using a single websocket API.
|
||||||
|
|
||||||
|
## Changes log
|
||||||
|
- v0.1.3-a Remove magic number in the frame to reduce frame overhead
|
||||||
|
@ -3,3 +3,6 @@
|
|||||||
`Antunnel` is a client side API that allows AntOS applications to
|
`Antunnel` is a client side API that allows AntOS applications to
|
||||||
talk to server side applications via the [`antd-tunnel-pligin`](https://github.com/lxsang/antd-tunnel-plugin) plugin
|
talk to server side applications via the [`antd-tunnel-pligin`](https://github.com/lxsang/antd-tunnel-plugin) plugin
|
||||||
using a single websocket API.
|
using a single websocket API.
|
||||||
|
|
||||||
|
## Changes log
|
||||||
|
- v0.1.3-a Remove magic number in the frame to reduce frame overhead
|
||||||
|
File diff suppressed because one or more lines are too long
@ -9,7 +9,7 @@
|
|||||||
"author": "Xuan Sang LE",
|
"author": "Xuan Sang LE",
|
||||||
"email": "xsang.le@lxsang.me"
|
"email": "xsang.le@lxsang.me"
|
||||||
},
|
},
|
||||||
"version":"0.1.2-a",
|
"version":"0.1.3-a",
|
||||||
"category":"Library",
|
"category":"Library",
|
||||||
"iconclass":"fa fa-adn",
|
"iconclass":"fa fa-adn",
|
||||||
"mimes":["none"],
|
"mimes":["none"],
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
<afx-app-window apptitle="Antunnel" width="500" height="400" data-id="Antunnel">
|
|
||||||
<afx-hbox >
|
|
||||||
<afx-button text="Sub" data-id="btsub"></afx-button>
|
|
||||||
</afx-hbox>
|
|
||||||
</afx-app-window>
|
|
Binary file not shown.
@ -12,33 +12,33 @@ class Msg
|
|||||||
|
|
||||||
|
|
||||||
as_raw:() ->
|
as_raw:() ->
|
||||||
length = 21 + @header.size
|
length = 13 + @header.size
|
||||||
arr = new Uint8Array(length)
|
arr = new Uint8Array(length)
|
||||||
arr.set(Msg.MAGIC_START, 0)
|
#arr.set(Msg.MAGIC_START, 0)
|
||||||
arr[4] = @header.type
|
arr[0] = @header.type
|
||||||
bytes = Msg.bytes_of @header.cid
|
bytes = Msg.bytes_of @header.cid
|
||||||
arr.set(bytes,5)
|
arr.set(bytes,1)
|
||||||
bytes = Msg.bytes_of @header.sid
|
bytes = Msg.bytes_of @header.sid
|
||||||
arr.set(bytes,9)
|
arr.set(bytes,5)
|
||||||
bytes = Msg.bytes_of @header.size
|
bytes = Msg.bytes_of @header.size
|
||||||
arr.set(bytes,13)
|
arr.set(bytes,9)
|
||||||
if @data
|
if @data
|
||||||
arr.set(@data, 17)
|
arr.set(@data, 13)
|
||||||
arr.set(Msg.MAGIC_END, @header.size + 17)
|
# arr.set(Msg.MAGIC_END, @header.size + 13)
|
||||||
arr.buffer
|
arr.buffer
|
||||||
|
|
||||||
Msg.decode = (raw) ->
|
Msg.decode = (raw) ->
|
||||||
new Promise (resolve, reject) ->
|
new Promise (resolve, reject) ->
|
||||||
msg = new Msg()
|
msg = new Msg()
|
||||||
if(Msg.int_from(Msg.MAGIC_START, 0) != Msg.int_from(raw, 0))
|
#if(Msg.int_from(Msg.MAGIC_START, 0) != Msg.int_from(raw, 0))
|
||||||
return reject("Unmatch message begin magic number")
|
# return reject("Unmatch message begin magic number")
|
||||||
msg.header.type = raw[4]
|
msg.header.type = raw[0]
|
||||||
msg.header.cid = Msg.int_from(raw, 5)
|
msg.header.cid = Msg.int_from(raw, 1)
|
||||||
msg.header.sid = Msg.int_from(raw,9)
|
msg.header.sid = Msg.int_from(raw,5)
|
||||||
msg.header.size = Msg.int_from(raw, 13)
|
msg.header.size = Msg.int_from(raw, 9)
|
||||||
msg.data = raw.slice(17, 17+msg.header.size)
|
msg.data = raw.slice(13, 13+msg.header.size)
|
||||||
if(Msg.int_from(Msg.MAGIC_END, 0) != Msg.int_from(raw, 17+msg.header.size))
|
#if(Msg.int_from(Msg.MAGIC_END, 0) != Msg.int_from(raw, 17+msg.header.size))
|
||||||
return reject("Unmatch message end magic number")
|
# return reject("Unmatch message end magic number")
|
||||||
resolve msg
|
resolve msg
|
||||||
|
|
||||||
|
|
||||||
@ -63,8 +63,8 @@ Msg.CLOSE = 5
|
|||||||
Msg.SUBSCRIBE = 2
|
Msg.SUBSCRIBE = 2
|
||||||
Msg.UNSUBSCRIBE = 3
|
Msg.UNSUBSCRIBE = 3
|
||||||
Msg.CTRL = 7
|
Msg.CTRL = 7
|
||||||
Msg.MAGIC_END = [ 0x41, 0x4e, 0x54, 0x44]
|
#Msg.MAGIC_END = [ 0x41, 0x4e, 0x54, 0x44]
|
||||||
Msg.MAGIC_START = [0x44, 0x54, 0x4e, 0x41 ]
|
#Msg.MAGIC_START = [0x44, 0x54, 0x4e, 0x41 ]
|
||||||
|
|
||||||
class Subscriber
|
class Subscriber
|
||||||
constructor: (@channel) ->
|
constructor: (@channel) ->
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"author": "Xuan Sang LE",
|
"author": "Xuan Sang LE",
|
||||||
"email": "xsang.le@lxsang.me"
|
"email": "xsang.le@lxsang.me"
|
||||||
},
|
},
|
||||||
"version":"0.1.2-a",
|
"version":"0.1.3-a",
|
||||||
"category":"Library",
|
"category":"Library",
|
||||||
"iconclass":"fa fa-adn",
|
"iconclass":"fa fa-adn",
|
||||||
"mimes":["none"],
|
"mimes":["none"],
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antunnel/README.md",
|
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antunnel/README.md",
|
||||||
"category": "Library",
|
"category": "Library",
|
||||||
"author": "Xuan Sang LE",
|
"author": "Xuan Sang LE",
|
||||||
"version": "0.1.2-a",
|
"version": "0.1.3-a",
|
||||||
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antunnel/build/release/Antunnel.zip"
|
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antunnel/build/release/Antunnel.zip"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user