Support Board
Date/Time: Sun, 24 Nov 2024 21:50:25 +0000
Post From: [SC Relay Server] Documentation Needed
[2024-05-02 16:56:40] |
d9e5c763 - Posts: 108 |
and the code related to handling LOGON_REQUEST: (MessageSize,) = struct.unpack("<H", await Reader.readexactly(struct.calcsize("<H"))) MessageData = await Reader.readexactly(MessageSize - struct.calcsize("<H")) Type, = StructUnpack("<H", MessageData, MessageSize) if Type == dtc.DTCMessageType.ENCODING_REQUEST: Buffer = b"" _, ProtocolVersion, Encoding, ProtocolType = StructUnpack("<Hii4s", MessageData, MessageSize) ProtocolType = ProtocolType.decode().strip("\x00") if VerboseMode: print(f"EncodingRequest[Binary][{Port}] - ProtocolVersion: {ProtocolVersion}") print(f"EncodingRequest[Binary][{Port}] - Encoding: {Encoding}") print(f"EncodingRequest[Binary][{Port}] - ProtocolType: {ProtocolType}") MessageSize = struct.calcsize("<HHii4s") Type = dtc.DTCMessageType.ENCODING_RESPONSE ProtocolVersion = dtc.CURRENT_VERSION Encoding = dtc.EncodingEnum.BINARY_ENCODING ProtocolType = "DTC".encode() EncodingResponse = struct.pack("<HHii4s", MessageSize, Type, ProtocolVersion, Encoding, ProtocolType) Writer.write(EncodingResponse) await Writer.drain() else: Writer.close() return while True: IndexOnly = False Data = await Reader.read(1024) if not Data: break Buffer += Data while len(Buffer) >= 2: MessageSize, = struct.unpack("<H", Buffer[:2]) if len(Buffer) < MessageSize: break MessageData = Buffer[2:MessageSize] Buffer = Buffer[MessageSize:] Type, = struct.unpack("<H", MessageData[:2]) if Type == dtc.DTCMessageType.LOGON_REQUEST: _, ProtocolVersion, Username, Password, GeneralTextData, \ Integer1, Integer2, HeartbeatIntervalInSeconds, TradeAccount, \ HardwareIdentifier, ClientName, MarketDataTransmissionInterval = StructUnpack("<Hi32s32s64siii4x32s64s32si", MessageData, MessageSize) # Type, (uint16_t), 2 bytes, H # ProtocolVersion, (int32_t), 4 bytes, i # Username, (char), 32 bytes # Password, (char), 32 bytes # GeneralTextData, (char), 64 bytes # Integer1, (int32_t), 4 bytes, i # Integer2, (int32_t), 4 bytes, i # HeartbeatIntervalInSeconds, (int32_t), 4 bytes, i # TradeAccount, (char), 32 bytes # HardwareIdentifier, (char), 64 bytes # ClientName, (char), 32 bytes # MarketDataTransmissionInterval, (int32_t), 4 bytes, i Username = Username.decode().strip("\x00") Password = Password.decode().strip("\x00") GeneralTextData = GeneralTextData.decode().strip("\x00") TradeAccount = TradeAccount.decode().strip("\x00") HardwareIdentifier = HardwareIdentifier.decode().strip("\x00") ClientName = ClientName.decode().strip("\x00") if VerboseMode: print(f"LogonRequest[Binary][{Port}] - ProtocolVersion: {ProtocolVersion}") print(f"LogonRequest[Binary][{Port}] - Username: {Username}") print(f"LogonRequest[Binary][{Port}] - Password: {Password}") print(f"LogonRequest[Binary][{Port}] - GeneralTextData: {GeneralTextData}") print(f"LogonRequest[Binary][{Port}] - Integer1: {Integer1}") print(f"LogonRequest[Binary][{Port}] - Integer2: {Integer2}") print(f"LogonRequest[Binary][{Port}] - HeartbeatIntervalInSeconds: {HeartbeatIntervalInSeconds}") print(f"LogonRequest[Binary][{Port}] - TradeAccount: {TradeAccount}") print(f"LogonRequest[Binary][{Port}] - HardwareIdentifier: {HardwareIdentifier}") print(f"LogonRequest[Binary][{Port}] - ClientName: {ClientName}") print(f"LogonRequest[Binary][{Port}] - MarketDataTransmissionInterval: {MarketDataTransmissionInterval}") |