mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-12-26 04:08:21 +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
|
||||
talk to server side applications via the [`antd-tunnel-pligin`](https://github.com/lxsang/antd-tunnel-plugin) plugin
|
||||
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
|
||||
talk to server side applications via the [`antd-tunnel-pligin`](https://github.com/lxsang/antd-tunnel-plugin) plugin
|
||||
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",
|
||||
"email": "xsang.le@lxsang.me"
|
||||
},
|
||||
"version":"0.1.2-a",
|
||||
"version":"0.1.3-a",
|
||||
"category":"Library",
|
||||
"iconclass":"fa fa-adn",
|
||||
"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:() ->
|
||||
length = 21 + @header.size
|
||||
length = 13 + @header.size
|
||||
arr = new Uint8Array(length)
|
||||
arr.set(Msg.MAGIC_START, 0)
|
||||
arr[4] = @header.type
|
||||
#arr.set(Msg.MAGIC_START, 0)
|
||||
arr[0] = @header.type
|
||||
bytes = Msg.bytes_of @header.cid
|
||||
arr.set(bytes,5)
|
||||
arr.set(bytes,1)
|
||||
bytes = Msg.bytes_of @header.sid
|
||||
arr.set(bytes,9)
|
||||
arr.set(bytes,5)
|
||||
bytes = Msg.bytes_of @header.size
|
||||
arr.set(bytes,13)
|
||||
arr.set(bytes,9)
|
||||
if @data
|
||||
arr.set(@data, 17)
|
||||
arr.set(Msg.MAGIC_END, @header.size + 17)
|
||||
arr.set(@data, 13)
|
||||
# arr.set(Msg.MAGIC_END, @header.size + 13)
|
||||
arr.buffer
|
||||
|
||||
Msg.decode = (raw) ->
|
||||
new Promise (resolve, reject) ->
|
||||
msg = new Msg()
|
||||
if(Msg.int_from(Msg.MAGIC_START, 0) != Msg.int_from(raw, 0))
|
||||
return reject("Unmatch message begin magic number")
|
||||
msg.header.type = raw[4]
|
||||
msg.header.cid = Msg.int_from(raw, 5)
|
||||
msg.header.sid = Msg.int_from(raw,9)
|
||||
msg.header.size = Msg.int_from(raw, 13)
|
||||
msg.data = raw.slice(17, 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")
|
||||
#if(Msg.int_from(Msg.MAGIC_START, 0) != Msg.int_from(raw, 0))
|
||||
# return reject("Unmatch message begin magic number")
|
||||
msg.header.type = raw[0]
|
||||
msg.header.cid = Msg.int_from(raw, 1)
|
||||
msg.header.sid = Msg.int_from(raw,5)
|
||||
msg.header.size = Msg.int_from(raw, 9)
|
||||
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))
|
||||
# return reject("Unmatch message end magic number")
|
||||
resolve msg
|
||||
|
||||
|
||||
@ -63,8 +63,8 @@ Msg.CLOSE = 5
|
||||
Msg.SUBSCRIBE = 2
|
||||
Msg.UNSUBSCRIBE = 3
|
||||
Msg.CTRL = 7
|
||||
Msg.MAGIC_END = [ 0x41, 0x4e, 0x54, 0x44]
|
||||
Msg.MAGIC_START = [0x44, 0x54, 0x4e, 0x41 ]
|
||||
#Msg.MAGIC_END = [ 0x41, 0x4e, 0x54, 0x44]
|
||||
#Msg.MAGIC_START = [0x44, 0x54, 0x4e, 0x41 ]
|
||||
|
||||
class Subscriber
|
||||
constructor: (@channel) ->
|
||||
|
@ -9,7 +9,7 @@
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "xsang.le@lxsang.me"
|
||||
},
|
||||
"version":"0.1.2-a",
|
||||
"version":"0.1.3-a",
|
||||
"category":"Library",
|
||||
"iconclass":"fa fa-adn",
|
||||
"mimes":["none"],
|
||||
|
@ -23,7 +23,7 @@
|
||||
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Antunnel/README.md",
|
||||
"category": "Library",
|
||||
"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"
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user