Login Page - Create Account

Support Board


Date/Time: Sun, 05 May 2024 11:13:46 +0000



Post From: Connecting to DTC with javascript websockets

[2021-11-29 20:50:17]
KylieV1618 - Posts: 59
Ok, I downloaded a binary encoding/decoding library for javascript. And it seems I can connect to the websockets.
ut Im not sure if Im encoding correctly.

The error I get on LOGON_REQUEST is


WSServer | DTC client #62. 127.0.0.1 (2) | Response HANDSHAKE with status code 101 | 2021-11-29 12:48:50.209
JSON data:
DTC_CLIENT | 2021-11-29 12:48:50.244
DTC JSON message: Missing 'Type' field. Ignoring message. | 2021-11-29 12:48:50.244 *
JSON data: | 2021-11-29 12:48:50.244
JSON data: | 2021-11-29 12:48:50.244
JSON data: x | 2021-11-29 12:48:50.244
DTC JSON message: Missing 'Type' field. Ignoring message. | 2021-11-29 12:48:50.244 *
JSON data: | 2021-11-29 12:48:50.244
JSON data: | 2021-11-29 12:48:50.244
JSON data:  | 2021-11-29 12:48:50.244
DTC JSON message: Missing 'Type' field. Ignoring message. | 2021-11-29 12:48:50.244 *
JSON data:  | 2021-11-29 12:48:50.244
DTC JSON message: Missing 'Type' field. Ignoring message. | 2021-11-29 12:48:50.244 *
JSON data:  | 2021-11-29 12:48:50.244





This is my current code.

Not really sure what to put in Size



var sp = require('../../schemapack/schemapack.js');


var logonSchema = sp.build({
Size: 'uint16',
Type: 'uint16',
ProtocolVersion: 'int32',
HeartbeatIntervalInSeconds: 'int32',
ClientName: 'string'
});

var logon = {
Size: 23,
Type: 1,
ProtocolVersion: 8,
HeartbeatIntervalInSeconds: 120,
ClientName: "DTC_CLIENT"
};

var buffer = logonSchema.encode(logon);

let socket = new WebSocket('ws://127.0.0.1:11099');
socket.onopen = function(e) {
console.log(buffer);
socket.send(buffer.buffer);
};


Do I need to be appending extra bytes somewhere, that will not be part of this encoding/decoding library?
Date Time Of Last Edit: 2021-11-30 01:11:36