本文整理汇总了TypeScript中node-opcua-binary-stream.BinaryStream.writeUInt8方法的典型用法代码示例。如果您正苦于以下问题:TypeScript BinaryStream.writeUInt8方法的具体用法?TypeScript BinaryStream.writeUInt8怎么用?TypeScript BinaryStream.writeUInt8使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类node-opcua-binary-stream.BinaryStream
的用法示例。
在下文中一共展示了BinaryStream.writeUInt8方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: write_header
public write_header(finalC: string, buffer: Buffer, length: number): void {
assert(buffer.length > 12);
assert(finalC.length === 1);
assert(buffer instanceof Buffer);
const stream = new BinaryStream(buffer);
// message header --------------------------
// ---------------------------------------------------------------
// OPC UA Secure Conversation Message Header : Part 6 page 36
// MessageType Byte[3]
// IsFinal Byte[1] C : intermediate, F: Final , A: Final with Error
// MessageSize UInt32 The length of the MessageChunk, in bytes. This value includes size of the message header.
// SecureChannelId UInt32 A unique identifier for the ClientSecureChannelLayer assigned by the server.
stream.writeUInt8(this.msgType.charCodeAt(0));
stream.writeUInt8(this.msgType.charCodeAt(1));
stream.writeUInt8(this.msgType.charCodeAt(2));
stream.writeUInt8(finalC.charCodeAt(0));
stream.writeUInt32(length);
stream.writeUInt32(this.channelId);
assert(stream.length === 12);
// write Security Header -----------------
this.securityHeader.encode(stream);
assert(stream.length === this.headerSize);
}
示例2: randomGuid
export function randomGuid(): Guid {
const b = new BinaryStream(20);
for (let i = 0; i < 20; i++) {
b.writeUInt8(getRandomInt(0, 255));
}
b.rewind();
const value = decodeGuid(b) as Guid;
return value;
}