1/* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import {AuthType} from "./AuthType.js"; 17import {HANDSHAKE_MESSAGE} from "../common/ConstantType.js"; 18import {BaseBean} from "./BaseBean.js"; 19 20export class SessionHandShake extends Object implements BaseBean{ 21 private _banner: string = HANDSHAKE_MESSAGE; // string must first index 22 private _authType: number = AuthType.AUTH_NONE; // uint8_t auth none 23 private _sessionId: number = 0; // uint32_t 24 private _connectKey: string = ""; // string 25 private _buf: string = ""; // string 26 private _version:string = ""; 27 28 constructor(banner: string, authType: number, sessionId: number, connectKey: string, buf: string) { 29 super(); 30 this._banner = banner; 31 this._authType = authType; 32 this._sessionId = sessionId; 33 this._connectKey = connectKey; 34 this._buf = buf; 35 } 36 37 getDataView(): DataView { 38 const view = new DataView(new ArrayBuffer(24)); 39 return view; 40 } 41 42 get banner(): string { 43 return this._banner; 44 } 45 46 set banner(value: string) { 47 this._banner = value; 48 } 49 50 get authType(): number { 51 return this._authType; 52 } 53 54 set authType(value: number) { 55 this._authType = value; 56 } 57 58 get sessionId(): number { 59 return this._sessionId; 60 } 61 62 set sessionId(value: number) { 63 this._sessionId = value; 64 } 65 66 get connectKey(): string { 67 return this._connectKey; 68 } 69 70 set connectKey(value: string) { 71 this._connectKey = value; 72 } 73 74 get buf(): string { 75 return this._buf; 76 } 77 78 set buf(value: string) { 79 this._buf = value; 80 } 81 82 get version(): string { 83 return this._version; 84 } 85 86 set version(value: string) { 87 this._version = value; 88 } 89 90 toString(): string { 91 return "banner: " + this._banner 92 + " authType: " + this._authType 93 + " sessionId: " + this._sessionId 94 + " connectKey: " + this._connectKey 95 + " buf: " + this._buf 96 + " version: " + this._version; 97 } 98} 99