Topics
19 Jul 2023, 12:53
 483
 2
Replies

krixfega
18 Jul 2023, 12:02 ( Updated at: 21 Dec 2023, 09:23 )

I have tried using a pure socket connection and I keep getting this response

[21, 3, 1, 0, 2, 2, 70] 

 

CODE: 

Socket socket = await Socket.connect('demo.ctraderapi.com', 5035);

var req = ProtoOAApplicationAuthReq()

..clientId = dotenv.get('CLIENT_ID')

..clientSecret = dotenv.get('CLIENT_SECRET');

var newByteArray = req.writeToBuffer();

var lengthOfByteArray = newByteArray.length;

debugPrint('lengthOfByteArray ===$lengthOfByteArray===');

Int32 int32 = Int32(lengthOfByteArray);

var newArray = int32.toBytes().reversed.toList() + newByteArray;

print(newArray);

socket.write(newArray);

// await socket.flush();

socket.listen((event) {

debugPrint('event ===${event.length}=== $event');

var response = ProtoOAApplicationAuthRes.fromBuffer(event);

debugPrint('response ===${response.payloadType}=== $response');

debugPrint('received ===${response.toString()}===');

});

 


@krixfega