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'; 17import { HANDSHAKE_MESSAGE } from '../common/ConstantType'; 18import { BaseBean } from './BaseBean'; 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 = 'Ver: 3.0.0b'; 27 28 constructor(banner: string, authType: number, sessionId: number, connectKey: string, buf: string, version: string) { 29 super(); 30 this._banner = banner; 31 this._authType = authType; 32 this._sessionId = sessionId; 33 this._connectKey = connectKey; 34 this._buf = buf; 35 this._version = version; 36 } 37 38 getDataView(): DataView { 39 const view = new DataView(new ArrayBuffer(24)); 40 return view; 41 } 42 43 get banner(): string { 44 return this._banner; 45 } 46 47 set banner(value: string) { 48 this._banner = value; 49 } 50 51 get authType(): number { 52 return this._authType; 53 } 54 55 set authType(value: number) { 56 this._authType = value; 57 } 58 59 get sessionId(): number { 60 return this._sessionId; 61 } 62 63 set sessionId(value: number) { 64 this._sessionId = value; 65 } 66 67 get connectKey(): string { 68 return this._connectKey; 69 } 70 71 set connectKey(value: string) { 72 this._connectKey = value; 73 } 74 75 get buf(): string { 76 return this._buf; 77 } 78 79 set buf(value: string) { 80 this._buf = value; 81 } 82 83 get version(): string { 84 return this._version; 85 } 86 87 set version(value: string) { 88 this._version = value; 89 } 90 91 toString(): string { 92 return ( 93 'banner: ' + 94 this._banner + 95 ' authType: ' + 96 this._authType + 97 ' sessionId: ' + 98 this._sessionId + 99 ' connectKey: ' + 100 this._connectKey + 101 ' buf: ' + 102 this._buf + 103 ' version: ' + 104 this._version 105 ); 106 } 107} 108