mirror of
https://github.com/netfun2000/rttys_zhaojh329.git
synced 2026-02-27 09:53:24 +08:00
@@ -12,6 +12,7 @@
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0",
|
||||
"iview": "^2.14.1",
|
||||
"protobufjs": "^6.8.6",
|
||||
"simple-websocket": "^7.0.2",
|
||||
"string-format-easy": "^1.0.1",
|
||||
"vue": "^2.5.13",
|
||||
|
||||
@@ -36,6 +36,7 @@ import 'xterm/lib/xterm.css'
|
||||
import * as fit from 'xterm/lib/addons/fit/fit';
|
||||
import axios from 'axios'
|
||||
import * as rtty from './rtty'
|
||||
import * as protobuf from 'protobufjs/light'
|
||||
|
||||
Terminal.applyAddon(fit);
|
||||
|
||||
@@ -401,6 +402,31 @@ export default {
|
||||
this.terminal.term.fit();
|
||||
}
|
||||
});
|
||||
|
||||
let root = protobuf.Root.fromJSON(require("./rtty.pb.json"));
|
||||
let rttyMessage = root.lookupType("rtty.rtty_message");
|
||||
|
||||
// Exemplary payload
|
||||
let payload = { version: 1, type: 12, sid: 'rwetr5345464'};
|
||||
|
||||
// Create a new message
|
||||
let message = rttyMessage.create(payload); // or use .fromObject if conversion is necessary
|
||||
|
||||
// Encode a message to an Uint8Array (browser) or Buffer (node)
|
||||
let buffer = rttyMessage.encode(message).finish();
|
||||
|
||||
// Decode an Uint8Array (browser) or Buffer (node) to a message
|
||||
message = rttyMessage.decode(buffer);
|
||||
|
||||
// Maybe convert the message back to a plain object
|
||||
var object = rttyMessage.toObject(message, {
|
||||
longs: String,
|
||||
enums: String,
|
||||
bytes: String,
|
||||
// see ConversionOptions
|
||||
});
|
||||
|
||||
console.log(object)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"nested": {
|
||||
"rtty": {
|
||||
"nested": {
|
||||
"rtty_message": {
|
||||
"fields": {
|
||||
"version": {
|
||||
"type": "uint32",
|
||||
"id": 1
|
||||
},
|
||||
"type": {
|
||||
"type": "uint32",
|
||||
"id": 2
|
||||
},
|
||||
"sid": {
|
||||
"type": "string",
|
||||
"id": 3
|
||||
}
|
||||
},
|
||||
"nested": {
|
||||
"Type": {
|
||||
"values": {
|
||||
"UNKNOWN": 0,
|
||||
"LOGIN": 1,
|
||||
"LOGINACK": 2,
|
||||
"LOGOUT": 3,
|
||||
"TTY": 4,
|
||||
"ANNOUNCE": 5,
|
||||
"UPFILE": 6,
|
||||
"DOWNFILE": 7
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"fields": {
|
||||
"code": {
|
||||
"type": "int32",
|
||||
"id": 1
|
||||
},
|
||||
"data": {
|
||||
"type": "bytes",
|
||||
"id": 2
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"id": 3
|
||||
},
|
||||
"size": {
|
||||
"type": "uint32",
|
||||
"id": 4
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user