Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Creating Byte Array and sending it through scoket

$
0
0

Hi there,

I need someone to show me how to properly define the Array and transmit it over TCP socket in it's raw form:

var sendPacket = ([0x02, 0x3E, 0x12, 0x84, 0xF6, 0x33, 0x94, 0x8B, 0x2F, 0xB3, 0x89, 0xF8, 0xAF, 0xFE, 0x68, 0xAA, 0xA2, 0x83, 0xED]};
 
var socket = Ti.Network.Socket.createTCP({
    host: 'gamea.clashofclans.com', port: 9339,
    connected: function (e) {
        Ti.API.info('Socket opened!');
        Ti.Stream.pump(e.socket, readCallback, 1024, true);
        Ti.Stream.write(socket, Ti.createBuffer({
            value: send_packet
        }), writeCallback);
    },
        error: function (e) {
        Ti.API.info('Error (' + e.errorCode + '): ' + e.error);
    },
});
sendPacket array can differ in size, but it will be prepared prior to sending.

Thank you for answering this noob question, i really appreciate it.


Viewing all articles
Browse latest Browse all 8068

Trending Articles