[TIMOB-19935] Windows: Implement Ti.Network.Socket.TCP
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-08-12T03:55:32.000+0000 |
Affected Version/s | Release 5.1.0 |
Fix Version/s | Release 6.1.0 |
Components | Windows |
Labels | LiveView |
Reporter | Kota Iguchi |
Assignee | Gary Mathews |
Created | 2015-11-12T08:25:37.000+0000 |
Updated | 2017-01-20T22:59:49.000+0000 |
Description
Implement
Ti.Network.Socket.TCP
for Windows.
http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Network.Socket.TCP
NOTE: This is needed for LiveView
*Test Case*
var socket = Ti.Network.Socket.createTCP({
host: 'pastebin.com', port: 80,
connected: function (e) {
Ti.API.info('socket connected');
// receive callback
Ti.Stream.pump(e.socket, function (e) {
alert(e.buffer.toString());
}, 1024, true);
// send GET request
Ti.Stream.write(socket, Ti.createBuffer({
value: 'GET /raw/eF5dK0xU HTTP/1.1\r\nHost: pastebin.com\r\nConnection: close\r\n\r\n'
}), function (e) {
Ti.API.info('socket sent GET');
});
}
});
socket.connect();
Attachments
File | Date | Size |
---|---|---|
wp_ss_20170120_0002.png | 2017-01-20T22:57:56.000+0000 | 134382 |
master: https://github.com/appcelerator/titanium_mobile_windows/pull/807
Hello I need to develop a Windows Phone app that performs communication via TCP socket. Specifically, it is an extension of an already developed apps for iOS and Android platforms with Titanium SDK. Seeing that the development of the TCP part is found only in the 6.1.0.x SDK version I have updated Appcelerator SDK and Studio to the latest versions. The TCP client implementation is present and working but I encountered some problems with sending messages, specifically it seems that the second message sent creates an error that crashes the application. I quote here the system information, the error log and test the application code. The TCP server is a simple nodejs echo script that responds with the message received. *Platform Info* OS: Windows 10 Pro Emulator: Mobile Emulator 10.0.14393.0 720p 5 inch 1GB Studio: 4.8.0.201611011053 appc 6.0.0-68 Titanium SDK 6.1.0.v20161113203131 *Studio Console Log* {noformat} -- Start application log ----------------------------------------------------- [INFO] [TEST] open connection [INFO] [TEST] connected [INFO] : Finished launching the application [INFO] [TEST] try to send [INFO] [TEST] sent [INFO] [TEST] received: 0 0 0 0 14 a0 [INFO] [TEST] try to send [ERROR] : ----- Titanium Javascript Runtime Error ----- [ERROR] : In undefined: undefined,undefined [ERROR] : Message: Uncaught Error: undefined [INFO] : Disconnected from app -- End application log ------------------------------------------------------- {noformat} *Test Code*
Verified feature with the test case provided by [~gmathews] in https://github.com/appcelerator/titanium_mobile_windows/pull/807. Screenshot shows the success message on the windows phone !wp_ss_20170120_0002.png|thumbnail! Code from the console:
*Environment*