decode not work

This commit is contained in:
rustdesk 2022-01-20 21:58:28 +08:00
parent 3dcbbcc416
commit 50834353b2
8 changed files with 468 additions and 272 deletions

View File

@ -4,7 +4,8 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="ogvjs/ogv.js"></script>
<script src="node_modules/ogv/dist/ogv.js"></script>
<script src="./yuv-canvas-1.2.6.js"></script>
<title>Vite App</title>
</head>
<body>

View File

@ -2,8 +2,8 @@
"name": "web_hbb",
"version": "1.0.0",
"scripts": {
"dev": "cp -rf node_modules/ogv/dist/* ogvjs/ && vite",
"build": "cp node_modules/ogv/dist/* dist/ogvjs/ && tsc && vite build",
"dev": "curl -O https://raw.githubusercontent.com/rgov/js-theora-decoder/main/yuv-canvas-1.2.6.js; vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"devDependencies": {

View File

@ -19,13 +19,14 @@
OGVDecoderVideoAV1SIMDMTW: 'ogv-decoder-video-av1-simd-mt-wasm.js',
*/
export function loadVp9() {
export function loadVp9(callback) {
window.OGVLoader.loadClass(
"OGVDecoderVideoVP9W",
(videoCodecClass) => {
window.videoCodecClass = videoCodecClass;
videoCodecClass().then((decoder) => {
decoder.init(() => {
onVp9Ready(decoder)
callback(decoder);
})
})
},
@ -33,30 +34,16 @@ export function loadVp9() {
);
}
export function loadOpus() {
export function loadOpus(callback) {
window.OGVLoader.loadClass(
"OGVDecoderAudioOpusW",
(audioCodecClass) => {
audioCodecClass().then((decoder) => {
decoder.init(() => {
onOpusReady(decoder)
callback(decoder);
})
})
},
{ worker: true }
);
}
async function onVp9Ready(decoder) {
console.log("Vp9 decoder ready");
/*
decoder.processFrame(buffer, () => {
player.drawFrame(decoder.frameBuffer)
})
*/
}
async function onOpusReady(decoder) {
console.log("Opus decoder ready");
}

View File

@ -1,16 +1,17 @@
import Websock from './websock';
import * as message from './message.js';
import * as rendezvous from './rendezvous.js';
import { loadVp9, loadOpus } from './codec';
import Websock from "./websock";
import * as message from "./message.js";
import * as rendezvous from "./rendezvous.js";
import { loadVp9, loadOpus } from "./codec";
import * as sha256 from "fast-sha256";
import * as globals from './globals';
import * as globals from "./globals";
const PORT = 21116;
const HOST = 'rs-sg.rustdesk.com';
const licenceKey = '';
const SCHEMA = 'ws://';
const HOST = "rs-sg.rustdesk.com";
const licenceKey = "";
const SCHEMA = "ws://";
type MsgboxCallback = (type: string, title: string, text: string) => void;
type DrawCallback = (Uint8Array) => void;
export default class Connection {
_msgs: any[];
@ -19,18 +20,30 @@ export default class Connection {
_id: string;
_hash: message.Hash | undefined;
_msgbox: MsgboxCallback | undefined;
_draw: DrawCallback | undefined;
_peerInfo: message.PeerInfo | undefined;
_firstFrame: Boolean | undefined;
_firstFrame: Boolean | undefined;
_videoDecoder: any;
_audioDecoder: any;
constructor() {
this._msgs = [];
this._id = '';
this._id = "";
this._interval = setInterval(() => {
while (this._msgs.length) {
this._ws?.sendMessage(this._msgs[0]);
this._msgs.splice(0, 1);
}
}, 1);
loadVp9((decoder: any) => {
this._videoDecoder = decoder;
console.log("vp9 loaded");
console.log(decoder);
});
loadOpus((decoder: any) => {
this._audioDecoder = decoder;
console.log("opus loaded");
});
}
async start(id: string) {
@ -38,9 +51,9 @@ export default class Connection {
const ws = new Websock(uri);
this._ws = ws;
this._id = id;
console.log(new Date() + ': Conntecting to rendezvoous server: ' + uri);
console.log(new Date() + ": Conntecting to rendezvoous server: " + uri);
await ws.open();
console.log(new Date() + ': Connected to rendezvoous server');
console.log(new Date() + ": Connected to rendezvoous server");
const connType = rendezvous.ConnType.DEFAULT_CONN;
const natType = rendezvous.NatType.SYMMETRIC;
const punchHoleRequest = rendezvous.PunchHoleRequest.fromPartial({
@ -52,24 +65,24 @@ export default class Connection {
ws.sendRendezvous({ punchHoleRequest });
const msg = ws.parseRendezvous(await ws.next());
ws.close();
console.log(new Date() + ': Got relay response');
console.log(new Date() + ": Got relay response");
const phr = msg.punchHoleResponse;
const rr = msg.relayResponse;
if (phr) {
if (phr.failure != rendezvous.PunchHoleResponse_Failure.UNKNOWN) {
switch (phr?.failure) {
case rendezvous.PunchHoleResponse_Failure.ID_NOT_EXIST:
this.msgbox('error', 'Error', 'ID does not exist');
this.msgbox("error", "Error", "ID does not exist");
break;
case rendezvous.PunchHoleResponse_Failure.OFFLINE:
this.msgbox('error', 'Error', 'Remote desktop is offline');
this.msgbox("error", "Error", "Remote desktop is offline");
break;
case rendezvous.PunchHoleResponse_Failure.LICENSE_MISMATCH:
this.msgbox('error', 'Error', 'Key mismatch');
this.msgbox("error", "Error", "Key mismatch");
break;
default:
if (phr?.otherFailure) {
this.msgbox('error', 'Error', phr?.otherFailure);
this.msgbox("error", "Error", phr?.otherFailure);
}
}
}
@ -87,10 +100,10 @@ export default class Connection {
uri = getDefaultUri(true);
}
const uuid = rr.uuid;
console.log(new Date() + ': Connecting to relay server: ' + uri);
console.log(new Date() + ": Connecting to relay server: " + uri);
const ws = new Websock(uri);
await ws.open();
console.log(new Date() + ': Connected to relay server');
console.log(new Date() + ": Connected to relay server");
this._ws = ws;
const requestRelay = rendezvous.RequestRelay.fromPartial({
licenceKey,
@ -103,7 +116,7 @@ export default class Connection {
async secure(pk: Uint8Array | undefined) {
if (pk) {
const RS_PK = 'OeVuKk5nlHiXp+APNn0Y3pC1Iwpwn44JGqrQCsWqmBw=';
const RS_PK = "OeVuKk5nlHiXp+APNn0Y3pC1Iwpwn44JGqrQCsWqmBw=";
try {
pk = await globals.verify(pk, RS_PK).catch();
if (pk?.length != 32) {
@ -113,7 +126,10 @@ export default class Connection {
console.error(e);
pk = undefined;
}
if (!pk) console.error('Handshake failed: invalid public key from rendezvous server');
if (!pk)
console.error(
"Handshake failed: invalid public key from rendezvous server"
);
}
if (!pk) {
// send an empty message out in case server is setting up secure and waiting for first message
@ -138,7 +154,7 @@ export default class Connection {
return;
}
signedId = new TextDecoder().decode(signedId!);
const tmp = signedId.split('\0');
const tmp = signedId.split("\0");
const id = tmp[0];
let theirPk = tmp[1];
if (id != this._id!) {
@ -148,16 +164,21 @@ export default class Connection {
}
theirPk = globals.decodeBase64(theirPk);
if (theirPk.length != 32) {
console.error("Handshake failed: invalid public box key length from peer");
console.error(
"Handshake failed: invalid public box key length from peer"
);
await this._ws?.sendMessage({});
return;
}
const [mySk, asymmetricValue] = globals.genBoxKeyPair();
const secretKey = globals.genSecretKey();
const symmetricValue = globals.seal(secretKey, theirPk, mySk);
const publicKey = message.PublicKey.fromPartial({ asymmetricValue, symmetricValue });
const publicKey = message.PublicKey.fromPartial({
asymmetricValue,
symmetricValue,
});
await this._ws?.sendMessage({ publicKey });
this._ws?.setSecretKey(secretKey)
this._ws?.setSecretKey(secretKey);
}
async msgLoop() {
@ -175,13 +196,17 @@ export default class Connection {
} else if (msg?.loginResponse) {
const r = msg?.loginResponse;
if (r.error) {
this.msgbox('error', 'Error', r.error);
this.msgbox("error", "Error", r.error);
} else if (r.peerInfo) {
this._peerInfo = r.peerInfo;
this.msgbox('success', 'Successful', 'Connected, waiting for image...');
this.msgbox(
"success",
"Successful",
"Connected, waiting for image..."
);
}
} else if (msg?.videoFrame) {
this.handleVideoFrame();
this.handleVideoFrame(msg?.videoFrame!);
}
}
}
@ -194,6 +219,10 @@ export default class Connection {
this._msgbox?.(type_, title, text);
}
draw(frame: Uint8Array) {
this._draw?.(frame);
}
close() {
clearInterval(this._interval);
this._ws?.close();
@ -203,8 +232,12 @@ export default class Connection {
this._msgbox = callback;
}
setDraw(callback: DrawCallback) {
this._draw = callback;
}
async login(password: string) {
this.msgbox('connecting', 'Connecting...', 'Logging in...');
this.msgbox("connecting", "Connecting...", "Logging in...");
let salt = this._hash?.salt;
if (salt) {
let p = hash([password, salt]);
@ -219,21 +252,34 @@ export default class Connection {
async _sendLoginMessage(password: Uint8Array | undefined = undefined) {
const loginRequest = message.LoginRequest.fromPartial({
username: this._id!,
myId: 'web', // to-do
myName: 'web', // to-do
myId: "web", // to-do
myName: "web", // to-do
password,
});
await this._ws?.sendMessage({ loginRequest });
}
handleVideoFrame() {
handleVideoFrame(vf: message.VideoFrame) {
if (!this._firstFrame) {
this.msgbox('', '', '');
this.msgbox("", "", "");
this._firstFrame = true;
}
if (vf.vp9s) {
let dec = this._videoDecoder;
vf.vp9s.frames.forEach((f) => {
dec.processFrame(f.data.buffer, (ok: any) => {
console.log(ok);
if (dec.frameBuffer) {
console.log(dec.frameBuffer);
this.draw(dec.frameBuffer);
}
});
});
}
}
}
// @ts-ignore
async function testDelay() {
const ws = new Websock(getDefaultUri(false));
await ws.open();
@ -241,17 +287,17 @@ async function testDelay() {
}
function getDefaultUri(isRelay: Boolean = false): string {
const host = localStorage.getItem('host');
return SCHEMA + (host || HOST) + ':' + (PORT + (isRelay ? 3 : 2));
const host = localStorage.getItem("host");
return SCHEMA + (host || HOST) + ":" + (PORT + (isRelay ? 3 : 2));
}
function getrUriFromRs(uri: string): string {
if (uri.indexOf(':') > 0) {
const tmp = uri.split(':');
if (uri.indexOf(":") > 0) {
const tmp = uri.split(":");
const port = parseInt(tmp[1]);
uri = tmp[0] + ':' + (port + 2);
uri = tmp[0] + ":" + (port + 2);
} else {
uri += ':' + (PORT + 3);
uri += ":" + (PORT + 3);
}
return SCHEMA + uri;
}
@ -259,10 +305,10 @@ function getrUriFromRs(uri: string): string {
function hash(datas: (string | Uint8Array)[]): Uint8Array {
const hasher = new sha256.Hash();
datas.forEach((data) => {
if (typeof data == 'string') {
if (typeof data == "string") {
data = new TextEncoder().encode(data);
}
return hasher.update(data);
});
return hasher.digest();
}
}

View File

@ -1,6 +1,6 @@
/* eslint-disable */
import { util, configure, Writer, Reader } from "protobufjs/minimal";
import * as Long from "long";
import Long from "long";
import _m0 from "protobufjs/minimal";
export const protobufPackage = "hbb";
@ -983,7 +983,7 @@ function createBaseVP9(): VP9 {
}
export const VP9 = {
encode(message: VP9, writer: Writer = Writer.create()): Writer {
encode(message: VP9, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.data.length !== 0) {
writer.uint32(10).bytes(message.data);
}
@ -996,8 +996,8 @@ export const VP9 = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): VP9 {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): VP9 {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseVP9();
while (reader.pos < end) {
@ -1055,15 +1055,15 @@ function createBaseVP9s(): VP9s {
}
export const VP9s = {
encode(message: VP9s, writer: Writer = Writer.create()): Writer {
encode(message: VP9s, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
for (const v of message.frames) {
VP9.encode(v!, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input: Reader | Uint8Array, length?: number): VP9s {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): VP9s {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseVP9s();
while (reader.pos < end) {
@ -1110,15 +1110,15 @@ function createBaseRGB(): RGB {
}
export const RGB = {
encode(message: RGB, writer: Writer = Writer.create()): Writer {
encode(message: RGB, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.compress === true) {
writer.uint32(8).bool(message.compress);
}
return writer;
},
decode(input: Reader | Uint8Array, length?: number): RGB {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): RGB {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseRGB();
while (reader.pos < end) {
@ -1159,7 +1159,7 @@ function createBaseYUV(): YUV {
}
export const YUV = {
encode(message: YUV, writer: Writer = Writer.create()): Writer {
encode(message: YUV, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.compress === true) {
writer.uint32(8).bool(message.compress);
}
@ -1169,8 +1169,8 @@ export const YUV = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): YUV {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): YUV {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseYUV();
while (reader.pos < end) {
@ -1217,7 +1217,10 @@ function createBaseVideoFrame(): VideoFrame {
}
export const VideoFrame = {
encode(message: VideoFrame, writer: Writer = Writer.create()): Writer {
encode(
message: VideoFrame,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.vp9s !== undefined) {
VP9s.encode(message.vp9s, writer.uint32(50).fork()).ldelim();
}
@ -1230,8 +1233,8 @@ export const VideoFrame = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): VideoFrame {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): VideoFrame {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseVideoFrame();
while (reader.pos < end) {
@ -1298,7 +1301,10 @@ function createBaseDisplayInfo(): DisplayInfo {
}
export const DisplayInfo = {
encode(message: DisplayInfo, writer: Writer = Writer.create()): Writer {
encode(
message: DisplayInfo,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.x !== 0) {
writer.uint32(8).sint32(message.x);
}
@ -1320,8 +1326,8 @@ export const DisplayInfo = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): DisplayInfo {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): DisplayInfo {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseDisplayInfo();
while (reader.pos < end) {
@ -1394,7 +1400,10 @@ function createBasePortForward(): PortForward {
}
export const PortForward = {
encode(message: PortForward, writer: Writer = Writer.create()): Writer {
encode(
message: PortForward,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.host !== "") {
writer.uint32(10).string(message.host);
}
@ -1404,8 +1413,8 @@ export const PortForward = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): PortForward {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): PortForward {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePortForward();
while (reader.pos < end) {
@ -1454,7 +1463,10 @@ function createBaseFileTransfer(): FileTransfer {
}
export const FileTransfer = {
encode(message: FileTransfer, writer: Writer = Writer.create()): Writer {
encode(
message: FileTransfer,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.dir !== "") {
writer.uint32(10).string(message.dir);
}
@ -1464,8 +1476,8 @@ export const FileTransfer = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): FileTransfer {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): FileTransfer {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFileTransfer();
while (reader.pos < end) {
@ -1522,7 +1534,10 @@ function createBaseLoginRequest(): LoginRequest {
}
export const LoginRequest = {
encode(message: LoginRequest, writer: Writer = Writer.create()): Writer {
encode(
message: LoginRequest,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.username !== "") {
writer.uint32(10).string(message.username);
}
@ -1553,8 +1568,8 @@ export const LoginRequest = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): LoginRequest {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): LoginRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseLoginRequest();
while (reader.pos < end) {
@ -1662,15 +1677,18 @@ function createBaseChatMessage(): ChatMessage {
}
export const ChatMessage = {
encode(message: ChatMessage, writer: Writer = Writer.create()): Writer {
encode(
message: ChatMessage,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.text !== "") {
writer.uint32(10).string(message.text);
}
return writer;
},
decode(input: Reader | Uint8Array, length?: number): ChatMessage {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): ChatMessage {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseChatMessage();
while (reader.pos < end) {
@ -1721,7 +1739,10 @@ function createBasePeerInfo(): PeerInfo {
}
export const PeerInfo = {
encode(message: PeerInfo, writer: Writer = Writer.create()): Writer {
encode(
message: PeerInfo,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.username !== "") {
writer.uint32(10).string(message.username);
}
@ -1746,8 +1767,8 @@ export const PeerInfo = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): PeerInfo {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): PeerInfo {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePeerInfo();
while (reader.pos < end) {
@ -1836,7 +1857,10 @@ function createBaseLoginResponse(): LoginResponse {
}
export const LoginResponse = {
encode(message: LoginResponse, writer: Writer = Writer.create()): Writer {
encode(
message: LoginResponse,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.error !== undefined) {
writer.uint32(10).string(message.error);
}
@ -1846,8 +1870,8 @@ export const LoginResponse = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): LoginResponse {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): LoginResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseLoginResponse();
while (reader.pos < end) {
@ -1904,7 +1928,10 @@ function createBaseMouseEvent(): MouseEvent {
}
export const MouseEvent = {
encode(message: MouseEvent, writer: Writer = Writer.create()): Writer {
encode(
message: MouseEvent,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.mask !== 0) {
writer.uint32(8).int32(message.mask);
}
@ -1922,8 +1949,8 @@ export const MouseEvent = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): MouseEvent {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): MouseEvent {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMouseEvent();
while (reader.pos < end) {
@ -2005,7 +2032,10 @@ function createBaseKeyEvent(): KeyEvent {
}
export const KeyEvent = {
encode(message: KeyEvent, writer: Writer = Writer.create()): Writer {
encode(
message: KeyEvent,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.down === true) {
writer.uint32(8).bool(message.down);
}
@ -2032,8 +2062,8 @@ export const KeyEvent = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): KeyEvent {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): KeyEvent {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseKeyEvent();
while (reader.pos < end) {
@ -2137,7 +2167,10 @@ function createBaseCursorData(): CursorData {
}
export const CursorData = {
encode(message: CursorData, writer: Writer = Writer.create()): Writer {
encode(
message: CursorData,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id !== 0) {
writer.uint32(8).uint64(message.id);
}
@ -2159,8 +2192,8 @@ export const CursorData = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): CursorData {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): CursorData {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseCursorData();
while (reader.pos < end) {
@ -2238,7 +2271,10 @@ function createBaseCursorPosition(): CursorPosition {
}
export const CursorPosition = {
encode(message: CursorPosition, writer: Writer = Writer.create()): Writer {
encode(
message: CursorPosition,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.x !== 0) {
writer.uint32(8).sint32(message.x);
}
@ -2248,8 +2284,8 @@ export const CursorPosition = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): CursorPosition {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): CursorPosition {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseCursorPosition();
while (reader.pos < end) {
@ -2298,7 +2334,7 @@ function createBaseHash(): Hash {
}
export const Hash = {
encode(message: Hash, writer: Writer = Writer.create()): Writer {
encode(message: Hash, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.salt !== "") {
writer.uint32(10).string(message.salt);
}
@ -2308,8 +2344,8 @@ export const Hash = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): Hash {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): Hash {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseHash();
while (reader.pos < end) {
@ -2356,7 +2392,10 @@ function createBaseClipboard(): Clipboard {
}
export const Clipboard = {
encode(message: Clipboard, writer: Writer = Writer.create()): Writer {
encode(
message: Clipboard,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.compress === true) {
writer.uint32(8).bool(message.compress);
}
@ -2366,8 +2405,8 @@ export const Clipboard = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): Clipboard {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): Clipboard {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseClipboard();
while (reader.pos < end) {
@ -2421,7 +2460,10 @@ function createBaseFileEntry(): FileEntry {
}
export const FileEntry = {
encode(message: FileEntry, writer: Writer = Writer.create()): Writer {
encode(
message: FileEntry,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.entryType !== 0) {
writer.uint32(8).int32(message.entryType);
}
@ -2440,8 +2482,8 @@ export const FileEntry = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): FileEntry {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): FileEntry {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFileEntry();
while (reader.pos < end) {
@ -2514,7 +2556,10 @@ function createBaseFileDirectory(): FileDirectory {
}
export const FileDirectory = {
encode(message: FileDirectory, writer: Writer = Writer.create()): Writer {
encode(
message: FileDirectory,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id !== 0) {
writer.uint32(8).int32(message.id);
}
@ -2527,8 +2572,8 @@ export const FileDirectory = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): FileDirectory {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): FileDirectory {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFileDirectory();
while (reader.pos < end) {
@ -2592,7 +2637,10 @@ function createBaseReadDir(): ReadDir {
}
export const ReadDir = {
encode(message: ReadDir, writer: Writer = Writer.create()): Writer {
encode(
message: ReadDir,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.path !== "") {
writer.uint32(10).string(message.path);
}
@ -2602,8 +2650,8 @@ export const ReadDir = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): ReadDir {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): ReadDir {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseReadDir();
while (reader.pos < end) {
@ -2653,7 +2701,10 @@ function createBaseReadAllFiles(): ReadAllFiles {
}
export const ReadAllFiles = {
encode(message: ReadAllFiles, writer: Writer = Writer.create()): Writer {
encode(
message: ReadAllFiles,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id !== 0) {
writer.uint32(8).int32(message.id);
}
@ -2666,8 +2717,8 @@ export const ReadAllFiles = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): ReadAllFiles {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): ReadAllFiles {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseReadAllFiles();
while (reader.pos < end) {
@ -2734,7 +2785,10 @@ function createBaseFileAction(): FileAction {
}
export const FileAction = {
encode(message: FileAction, writer: Writer = Writer.create()): Writer {
encode(
message: FileAction,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.readDir !== undefined) {
ReadDir.encode(message.readDir, writer.uint32(10).fork()).ldelim();
}
@ -2777,8 +2831,8 @@ export const FileAction = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): FileAction {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): FileAction {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFileAction();
while (reader.pos < end) {
@ -2935,16 +2989,16 @@ function createBaseFileTransferCancel(): FileTransferCancel {
export const FileTransferCancel = {
encode(
message: FileTransferCancel,
writer: Writer = Writer.create()
): Writer {
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id !== 0) {
writer.uint32(8).int32(message.id);
}
return writer;
},
decode(input: Reader | Uint8Array, length?: number): FileTransferCancel {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): FileTransferCancel {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFileTransferCancel();
while (reader.pos < end) {
@ -2992,7 +3046,10 @@ function createBaseFileResponse(): FileResponse {
}
export const FileResponse = {
encode(message: FileResponse, writer: Writer = Writer.create()): Writer {
encode(
message: FileResponse,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.dir !== undefined) {
FileDirectory.encode(message.dir, writer.uint32(10).fork()).ldelim();
}
@ -3014,8 +3071,8 @@ export const FileResponse = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): FileResponse {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): FileResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFileResponse();
while (reader.pos < end) {
@ -3104,7 +3161,10 @@ function createBaseFileTransferBlock(): FileTransferBlock {
}
export const FileTransferBlock = {
encode(message: FileTransferBlock, writer: Writer = Writer.create()): Writer {
encode(
message: FileTransferBlock,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id !== 0) {
writer.uint32(8).int32(message.id);
}
@ -3120,8 +3180,8 @@ export const FileTransferBlock = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): FileTransferBlock {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): FileTransferBlock {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFileTransferBlock();
while (reader.pos < end) {
@ -3188,7 +3248,10 @@ function createBaseFileTransferError(): FileTransferError {
}
export const FileTransferError = {
encode(message: FileTransferError, writer: Writer = Writer.create()): Writer {
encode(
message: FileTransferError,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id !== 0) {
writer.uint32(8).int32(message.id);
}
@ -3201,8 +3264,8 @@ export const FileTransferError = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): FileTransferError {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): FileTransferError {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFileTransferError();
while (reader.pos < end) {
@ -3260,8 +3323,8 @@ function createBaseFileTransferSendRequest(): FileTransferSendRequest {
export const FileTransferSendRequest = {
encode(
message: FileTransferSendRequest,
writer: Writer = Writer.create()
): Writer {
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id !== 0) {
writer.uint32(8).int32(message.id);
}
@ -3274,8 +3337,11 @@ export const FileTransferSendRequest = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): FileTransferSendRequest {
const reader = input instanceof Reader ? input : new Reader(input);
decode(
input: _m0.Reader | Uint8Array,
length?: number
): FileTransferSendRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFileTransferSendRequest();
while (reader.pos < end) {
@ -3333,7 +3399,10 @@ function createBaseFileTransferDone(): FileTransferDone {
}
export const FileTransferDone = {
encode(message: FileTransferDone, writer: Writer = Writer.create()): Writer {
encode(
message: FileTransferDone,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id !== 0) {
writer.uint32(8).int32(message.id);
}
@ -3343,8 +3412,8 @@ export const FileTransferDone = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): FileTransferDone {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): FileTransferDone {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFileTransferDone();
while (reader.pos < end) {
@ -3396,8 +3465,8 @@ function createBaseFileTransferReceiveRequest(): FileTransferReceiveRequest {
export const FileTransferReceiveRequest = {
encode(
message: FileTransferReceiveRequest,
writer: Writer = Writer.create()
): Writer {
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id !== 0) {
writer.uint32(8).int32(message.id);
}
@ -3411,10 +3480,10 @@ export const FileTransferReceiveRequest = {
},
decode(
input: Reader | Uint8Array,
input: _m0.Reader | Uint8Array,
length?: number
): FileTransferReceiveRequest {
const reader = input instanceof Reader ? input : new Reader(input);
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFileTransferReceiveRequest();
while (reader.pos < end) {
@ -3477,7 +3546,10 @@ function createBaseFileRemoveDir(): FileRemoveDir {
}
export const FileRemoveDir = {
encode(message: FileRemoveDir, writer: Writer = Writer.create()): Writer {
encode(
message: FileRemoveDir,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id !== 0) {
writer.uint32(8).int32(message.id);
}
@ -3490,8 +3562,8 @@ export const FileRemoveDir = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): FileRemoveDir {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): FileRemoveDir {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFileRemoveDir();
while (reader.pos < end) {
@ -3546,7 +3618,10 @@ function createBaseFileRemoveFile(): FileRemoveFile {
}
export const FileRemoveFile = {
encode(message: FileRemoveFile, writer: Writer = Writer.create()): Writer {
encode(
message: FileRemoveFile,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id !== 0) {
writer.uint32(8).int32(message.id);
}
@ -3559,8 +3634,8 @@ export const FileRemoveFile = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): FileRemoveFile {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): FileRemoveFile {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFileRemoveFile();
while (reader.pos < end) {
@ -3616,7 +3691,10 @@ function createBaseFileDirCreate(): FileDirCreate {
}
export const FileDirCreate = {
encode(message: FileDirCreate, writer: Writer = Writer.create()): Writer {
encode(
message: FileDirCreate,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id !== 0) {
writer.uint32(8).int32(message.id);
}
@ -3626,8 +3704,8 @@ export const FileDirCreate = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): FileDirCreate {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): FileDirCreate {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFileDirCreate();
while (reader.pos < end) {
@ -3676,7 +3754,10 @@ function createBaseSwitchDisplay(): SwitchDisplay {
}
export const SwitchDisplay = {
encode(message: SwitchDisplay, writer: Writer = Writer.create()): Writer {
encode(
message: SwitchDisplay,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.display !== 0) {
writer.uint32(8).int32(message.display);
}
@ -3695,8 +3776,8 @@ export const SwitchDisplay = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): SwitchDisplay {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): SwitchDisplay {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseSwitchDisplay();
while (reader.pos < end) {
@ -3764,7 +3845,10 @@ function createBasePermissionInfo(): PermissionInfo {
}
export const PermissionInfo = {
encode(message: PermissionInfo, writer: Writer = Writer.create()): Writer {
encode(
message: PermissionInfo,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.permission !== 0) {
writer.uint32(8).int32(message.permission);
}
@ -3774,8 +3858,8 @@ export const PermissionInfo = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): PermissionInfo {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): PermissionInfo {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePermissionInfo();
while (reader.pos < end) {
@ -3836,7 +3920,10 @@ function createBaseOptionMessage(): OptionMessage {
}
export const OptionMessage = {
encode(message: OptionMessage, writer: Writer = Writer.create()): Writer {
encode(
message: OptionMessage,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.imageQuality !== 0) {
writer.uint32(8).int32(message.imageQuality);
}
@ -3864,8 +3951,8 @@ export const OptionMessage = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): OptionMessage {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): OptionMessage {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseOptionMessage();
while (reader.pos < end) {
@ -3980,7 +4067,10 @@ function createBaseOptionResponse(): OptionResponse {
}
export const OptionResponse = {
encode(message: OptionResponse, writer: Writer = Writer.create()): Writer {
encode(
message: OptionResponse,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.opt !== undefined) {
OptionMessage.encode(message.opt, writer.uint32(10).fork()).ldelim();
}
@ -3990,8 +4080,8 @@ export const OptionResponse = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): OptionResponse {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): OptionResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseOptionResponse();
while (reader.pos < end) {
@ -4044,7 +4134,10 @@ function createBaseTestDelay(): TestDelay {
}
export const TestDelay = {
encode(message: TestDelay, writer: Writer = Writer.create()): Writer {
encode(
message: TestDelay,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.time !== 0) {
writer.uint32(8).int64(message.time);
}
@ -4054,8 +4147,8 @@ export const TestDelay = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): TestDelay {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): TestDelay {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseTestDelay();
while (reader.pos < end) {
@ -4107,7 +4200,10 @@ function createBasePublicKey(): PublicKey {
}
export const PublicKey = {
encode(message: PublicKey, writer: Writer = Writer.create()): Writer {
encode(
message: PublicKey,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.asymmetricValue.length !== 0) {
writer.uint32(10).bytes(message.asymmetricValue);
}
@ -4117,8 +4213,8 @@ export const PublicKey = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): PublicKey {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): PublicKey {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePublicKey();
while (reader.pos < end) {
@ -4181,15 +4277,18 @@ function createBaseSignedId(): SignedId {
}
export const SignedId = {
encode(message: SignedId, writer: Writer = Writer.create()): Writer {
encode(
message: SignedId,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id.length !== 0) {
writer.uint32(10).bytes(message.id);
}
return writer;
},
decode(input: Reader | Uint8Array, length?: number): SignedId {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): SignedId {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseSignedId();
while (reader.pos < end) {
@ -4233,7 +4332,10 @@ function createBaseAudioFormat(): AudioFormat {
}
export const AudioFormat = {
encode(message: AudioFormat, writer: Writer = Writer.create()): Writer {
encode(
message: AudioFormat,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.sampleRate !== 0) {
writer.uint32(8).uint32(message.sampleRate);
}
@ -4243,8 +4345,8 @@ export const AudioFormat = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): AudioFormat {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): AudioFormat {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseAudioFormat();
while (reader.pos < end) {
@ -4295,15 +4397,18 @@ function createBaseAudioFrame(): AudioFrame {
}
export const AudioFrame = {
encode(message: AudioFrame, writer: Writer = Writer.create()): Writer {
encode(
message: AudioFrame,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.data.length !== 0) {
writer.uint32(10).bytes(message.data);
}
return writer;
},
decode(input: Reader | Uint8Array, length?: number): AudioFrame {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): AudioFrame {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseAudioFrame();
while (reader.pos < end) {
@ -4360,7 +4465,7 @@ function createBaseMisc(): Misc {
}
export const Misc = {
encode(message: Misc, writer: Writer = Writer.create()): Writer {
encode(message: Misc, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.chatMessage !== undefined) {
ChatMessage.encode(
message.chatMessage,
@ -4403,8 +4508,8 @@ export const Misc = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): Misc {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): Misc {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMisc();
while (reader.pos < end) {
@ -4565,7 +4670,10 @@ function createBaseMessage(): Message {
}
export const Message = {
encode(message: Message, writer: Writer = Writer.create()): Writer {
encode(
message: Message,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.signedId !== undefined) {
SignedId.encode(message.signedId, writer.uint32(26).fork()).ldelim();
}
@ -4632,8 +4740,8 @@ export const Message = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): Message {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): Message {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMessage();
while (reader.pos < end) {
@ -4957,11 +5065,9 @@ function longToNumber(long: Long): number {
return long.toNumber();
}
// If you get a compile-error about 'Constructor<Long> and ... have no overlap',
// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'.
if (util.Long !== Long) {
util.Long = Long as any;
configure();
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
function isSet(value: any): boolean {

View File

@ -1,6 +1,6 @@
/* eslint-disable */
import { util, configure, Writer, Reader } from "protobufjs/minimal";
import * as Long from "long";
import Long from "long";
import _m0 from "protobufjs/minimal";
export const protobufPackage = "hbb";
@ -357,7 +357,10 @@ function createBaseRegisterPeer(): RegisterPeer {
}
export const RegisterPeer = {
encode(message: RegisterPeer, writer: Writer = Writer.create()): Writer {
encode(
message: RegisterPeer,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
@ -367,8 +370,8 @@ export const RegisterPeer = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): RegisterPeer {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): RegisterPeer {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseRegisterPeer();
while (reader.pos < end) {
@ -419,16 +422,19 @@ function createBaseRegisterPeerResponse(): RegisterPeerResponse {
export const RegisterPeerResponse = {
encode(
message: RegisterPeerResponse,
writer: Writer = Writer.create()
): Writer {
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.requestPk === true) {
writer.uint32(16).bool(message.requestPk);
}
return writer;
},
decode(input: Reader | Uint8Array, length?: number): RegisterPeerResponse {
const reader = input instanceof Reader ? input : new Reader(input);
decode(
input: _m0.Reader | Uint8Array,
length?: number
): RegisterPeerResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseRegisterPeerResponse();
while (reader.pos < end) {
@ -471,7 +477,10 @@ function createBasePunchHoleRequest(): PunchHoleRequest {
}
export const PunchHoleRequest = {
encode(message: PunchHoleRequest, writer: Writer = Writer.create()): Writer {
encode(
message: PunchHoleRequest,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
@ -487,8 +496,8 @@ export const PunchHoleRequest = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): PunchHoleRequest {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): PunchHoleRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePunchHoleRequest();
while (reader.pos < end) {
@ -551,7 +560,10 @@ function createBasePunchHole(): PunchHole {
}
export const PunchHole = {
encode(message: PunchHole, writer: Writer = Writer.create()): Writer {
encode(
message: PunchHole,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.socketAddr.length !== 0) {
writer.uint32(10).bytes(message.socketAddr);
}
@ -564,8 +576,8 @@ export const PunchHole = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): PunchHole {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): PunchHole {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePunchHole();
while (reader.pos < end) {
@ -627,15 +639,18 @@ function createBaseTestNatRequest(): TestNatRequest {
}
export const TestNatRequest = {
encode(message: TestNatRequest, writer: Writer = Writer.create()): Writer {
encode(
message: TestNatRequest,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.serial !== 0) {
writer.uint32(8).int32(message.serial);
}
return writer;
},
decode(input: Reader | Uint8Array, length?: number): TestNatRequest {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): TestNatRequest {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseTestNatRequest();
while (reader.pos < end) {
@ -678,7 +693,10 @@ function createBaseTestNatResponse(): TestNatResponse {
}
export const TestNatResponse = {
encode(message: TestNatResponse, writer: Writer = Writer.create()): Writer {
encode(
message: TestNatResponse,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.port !== 0) {
writer.uint32(8).int32(message.port);
}
@ -688,8 +706,8 @@ export const TestNatResponse = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): TestNatResponse {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): TestNatResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseTestNatResponse();
while (reader.pos < end) {
@ -748,7 +766,10 @@ function createBasePunchHoleSent(): PunchHoleSent {
}
export const PunchHoleSent = {
encode(message: PunchHoleSent, writer: Writer = Writer.create()): Writer {
encode(
message: PunchHoleSent,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.socketAddr.length !== 0) {
writer.uint32(10).bytes(message.socketAddr);
}
@ -767,8 +788,8 @@ export const PunchHoleSent = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): PunchHoleSent {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): PunchHoleSent {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePunchHoleSent();
while (reader.pos < end) {
@ -842,7 +863,10 @@ function createBaseRegisterPk(): RegisterPk {
}
export const RegisterPk = {
encode(message: RegisterPk, writer: Writer = Writer.create()): Writer {
encode(
message: RegisterPk,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
@ -858,8 +882,8 @@ export const RegisterPk = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): RegisterPk {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): RegisterPk {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseRegisterPk();
while (reader.pos < end) {
@ -930,16 +954,16 @@ function createBaseRegisterPkResponse(): RegisterPkResponse {
export const RegisterPkResponse = {
encode(
message: RegisterPkResponse,
writer: Writer = Writer.create()
): Writer {
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.result !== 0) {
writer.uint32(8).int32(message.result);
}
return writer;
},
decode(input: Reader | Uint8Array, length?: number): RegisterPkResponse {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): RegisterPkResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseRegisterPkResponse();
while (reader.pos < end) {
@ -993,7 +1017,10 @@ function createBasePunchHoleResponse(): PunchHoleResponse {
}
export const PunchHoleResponse = {
encode(message: PunchHoleResponse, writer: Writer = Writer.create()): Writer {
encode(
message: PunchHoleResponse,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.socketAddr.length !== 0) {
writer.uint32(10).bytes(message.socketAddr);
}
@ -1018,8 +1045,8 @@ export const PunchHoleResponse = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): PunchHoleResponse {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): PunchHoleResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePunchHoleResponse();
while (reader.pos < end) {
@ -1119,7 +1146,10 @@ function createBaseConfigUpdate(): ConfigUpdate {
}
export const ConfigUpdate = {
encode(message: ConfigUpdate, writer: Writer = Writer.create()): Writer {
encode(
message: ConfigUpdate,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.serial !== 0) {
writer.uint32(8).int32(message.serial);
}
@ -1129,8 +1159,8 @@ export const ConfigUpdate = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): ConfigUpdate {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): ConfigUpdate {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseConfigUpdate();
while (reader.pos < end) {
@ -1193,7 +1223,10 @@ function createBaseRequestRelay(): RequestRelay {
}
export const RequestRelay = {
encode(message: RequestRelay, writer: Writer = Writer.create()): Writer {
encode(
message: RequestRelay,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
@ -1218,8 +1251,8 @@ export const RequestRelay = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): RequestRelay {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): RequestRelay {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseRequestRelay();
while (reader.pos < end) {
@ -1313,7 +1346,10 @@ function createBaseRelayResponse(): RelayResponse {
}
export const RelayResponse = {
encode(message: RelayResponse, writer: Writer = Writer.create()): Writer {
encode(
message: RelayResponse,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.socketAddr.length !== 0) {
writer.uint32(10).bytes(message.socketAddr);
}
@ -1338,8 +1374,8 @@ export const RelayResponse = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): RelayResponse {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): RelayResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseRelayResponse();
while (reader.pos < end) {
@ -1429,15 +1465,18 @@ function createBaseSoftwareUpdate(): SoftwareUpdate {
}
export const SoftwareUpdate = {
encode(message: SoftwareUpdate, writer: Writer = Writer.create()): Writer {
encode(
message: SoftwareUpdate,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.url !== "") {
writer.uint32(10).string(message.url);
}
return writer;
},
decode(input: Reader | Uint8Array, length?: number): SoftwareUpdate {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): SoftwareUpdate {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseSoftwareUpdate();
while (reader.pos < end) {
@ -1480,7 +1519,10 @@ function createBaseFetchLocalAddr(): FetchLocalAddr {
}
export const FetchLocalAddr = {
encode(message: FetchLocalAddr, writer: Writer = Writer.create()): Writer {
encode(
message: FetchLocalAddr,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.socketAddr.length !== 0) {
writer.uint32(10).bytes(message.socketAddr);
}
@ -1490,8 +1532,8 @@ export const FetchLocalAddr = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): FetchLocalAddr {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): FetchLocalAddr {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFetchLocalAddr();
while (reader.pos < end) {
@ -1552,7 +1594,10 @@ function createBaseLocalAddr(): LocalAddr {
}
export const LocalAddr = {
encode(message: LocalAddr, writer: Writer = Writer.create()): Writer {
encode(
message: LocalAddr,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.socketAddr.length !== 0) {
writer.uint32(10).bytes(message.socketAddr);
}
@ -1571,8 +1616,8 @@ export const LocalAddr = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): LocalAddr {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): LocalAddr {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseLocalAddr();
while (reader.pos < end) {
@ -1658,7 +1703,10 @@ function createBasePeerDiscovery(): PeerDiscovery {
}
export const PeerDiscovery = {
encode(message: PeerDiscovery, writer: Writer = Writer.create()): Writer {
encode(
message: PeerDiscovery,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.cmd !== "") {
writer.uint32(10).string(message.cmd);
}
@ -1683,8 +1731,8 @@ export const PeerDiscovery = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): PeerDiscovery {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): PeerDiscovery {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePeerDiscovery();
while (reader.pos < end) {
@ -1781,7 +1829,10 @@ function createBaseRendezvousMessage(): RendezvousMessage {
}
export const RendezvousMessage = {
encode(message: RendezvousMessage, writer: Writer = Writer.create()): Writer {
encode(
message: RendezvousMessage,
writer: _m0.Writer = _m0.Writer.create()
): _m0.Writer {
if (message.registerPeer !== undefined) {
RegisterPeer.encode(
message.registerPeer,
@ -1878,8 +1929,8 @@ export const RendezvousMessage = {
return writer;
},
decode(input: Reader | Uint8Array, length?: number): RendezvousMessage {
const reader = input instanceof Reader ? input : new Reader(input);
decode(input: _m0.Reader | Uint8Array, length?: number): RendezvousMessage {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseRendezvousMessage();
while (reader.pos < end) {
@ -2240,11 +2291,9 @@ export type Exact<P, I extends P> = P extends Builtin
never
>;
// If you get a compile-error about 'Constructor<Long> and ... have no overlap',
// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'.
if (util.Long !== Long) {
util.Long = Long as any;
configure();
if (_m0.util.Long !== Long) {
_m0.util.Long = Long as any;
_m0.configure();
}
function isSet(value: any): boolean {

View File

@ -21,8 +21,11 @@ if (app) {
<div id="text" style="line-height: 2em"></div>
<button id="cancel" onclick="cancel();">Cancel</button>
</div>
<canvas id="player"></canvas>
`;
let player;
document.body.onload = () => {
const host = document.querySelector('#host');
host.value = localStorage.getItem('host');
@ -30,6 +33,7 @@ if (app) {
id.value = localStorage.getItem('id');
const key = document.querySelector('#key');
key.value = localStorage.getItem('key');
player = YUVCanvas.attach(document.getElementById("player"))
};
window.connect = () => {
@ -42,6 +46,9 @@ if (app) {
const func = async () => {
const conn = globals.newConn();
conn.setMsgbox(msgbox);
conn.setDraw((f) => {
player.drawFrame(f);
});
document.querySelector('div#status').style.display = 'block';
document.querySelector('div#connect').style.display = 'none';
document.querySelector('div#text').innerHTML = 'Connecting ...';

View File

@ -5,16 +5,16 @@ import os
path = os.path.abspath(os.path.join(os.getcwd(), '..', 'hbb', 'libs', 'hbb_common', 'protos'))
if os.name == 'nt':
cmd = r'protoc --plugin=protoc-gen-ts_proto=.\node_modules\.bin\protoc-gen-ts_proto.cmd -I "%s" --ts_proto_out=./src/ rendezvous.proto'%path
cmd = r'protoc --ts_proto_opt=esModuleInterop=true --plugin=protoc-gen-ts_proto=.\node_modules\.bin\protoc-gen-ts_proto.cmd -I "%s" --ts_proto_out=./src/ rendezvous.proto'%path
print(cmd)
os.system(cmd)
cmd = r'protoc --plugin=protoc-gen-ts_proto=.\node_modules\.bin\protoc-gen-ts_proto.cmd -I "%s" --ts_proto_out=./src/ message.proto'%path
cmd = r'protoc --ts_proto_opt=esModuleInterop=true --plugin=protoc-gen-ts_proto=.\node_modules\.bin\protoc-gen-ts_proto.cmd -I "%s" --ts_proto_out=./src/ message.proto'%path
print(cmd)
os.system(cmd)
else:
cmd = r'protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto -I "%s" --ts_proto_out=./src/ rendezvous.proto'%path
cmd = r'protoc --ts_proto_opt=esModuleInterop=true --plugin=./node_modules/.bin/protoc-gen-ts_proto -I "%s" --ts_proto_out=./src/ rendezvous.proto'%path
print(cmd)
os.system(cmd)
cmd = r'protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto -I "%s" --ts_proto_out=./src/ message.proto'%path
cmd = r'protoc --ts_proto_opt=esModuleInterop=true --plugin=./node_modules/.bin/protoc-gen-ts_proto -I "%s" --ts_proto_out=./src/ message.proto'%path
print(cmd)
os.system(cmd)
os.system(cmd)