Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIMOB-10137: BlackBerry: Implement Ti.Network.Socket and Ti.Network.Socket.TCP [part2] #134

Merged

Conversation

alexandergalstyan
Copy link

Reviewers: DavidL

Changelog:

  • Implement listen, accept methods
  • Implement state, listenQueueSize, connected, accepted, error properties
  • Handling exception cases.

NOTE: [Client part] Use local tcp server to check the functionality, with both ip address and hostname. Was used TCPMonitor plugin for Eclipse.
NOTE: [Server part] Use hostname and ip address of simulator. Connect to it using telnet.

NOTE: Some parts not fully tested yet and not fully implemented.

Test cases:

  • Use the snippets attached to JIRA to test current functionality.

// Network.Socket.TCP snippet

var win1 = Titanium.UI.createWindow({
backgroundColor:'#F00'
});

/*
var socket = Ti.Network.Socket.createTCP({
host: 'alexg',
port: 8080,
connected : function(e) {
Ti.API.info('Client socket connected! Socket: ' + e.socket.port);
}
});

socket.connect();
*/

//Create a socket and listen for incoming connections
var listenSocket = Ti.Network.Socket.createTCP({
// Simulator IP address
host : '192.168.226.134',
port : 40404
});

// Starts the socket listening for connections, does not accept them
listenSocket.listen();
Ti.API.info("Listening now...");

// Tells socket to accept the next inbound connection. listenSocket.accepted gets
// called when a connection is accepted via accept()
Ti.API.info("Calling accept.");
listenSocket.accept({
timeout : 10000
});

var button = Titanium.UI.createButton({
title: 'Stop',
top: 10,
width: 200,
height: 100
});

button.addEventListener('click',function(e)
{
alert('Hello');
});

win1.add(button);

// open window
win1.open();

…ocket.TCP [part2]

Reviewers: DavidL

Changelog:
- Implement listen, accept methods
- Implement state, listenQueueSize, connected, accepted, error properties
- Handling exception cases.

NOTE: [Client part] Use local tcp server to check the functionality, with both ip address and hostname. Was used TCPMonitor plugin for Eclipse.
NOTE: [Server part] Use hostname and ip address of simulator. Connect to it using telnet.

NOTE: Some parts not fully tested yet and not fully implemented.

Test cases:
- Use the snippets attached to JIRA to test current functionality.

// Network.Socket.TCP snippet

var win1 = Titanium.UI.createWindow({
    backgroundColor:'#F00'
});

/*
var socket = Ti.Network.Socket.createTCP({
	host: 'alexg',
	port: 8080,
	connected : function(e) {
            Ti.API.info('Client socket connected! Socket: ' + e.socket.port);
    }
});

socket.connect();
*/

//Create a socket and listen for incoming connections
var listenSocket = Ti.Network.Socket.createTCP({
	// Simulator IP address
    host : '192.168.226.134',
    port : 40404
});

// Starts the socket listening for connections, does not accept them
listenSocket.listen();
Ti.API.info("Listening now...");

// Tells socket to accept the next inbound connection. listenSocket.accepted gets
// called when a connection is accepted via accept()
Ti.API.info("Calling accept.");
listenSocket.accept({
    timeout : 10000
});

var button = Titanium.UI.createButton({
   title: 'Stop',
   top: 10,
   width: 200,
   height: 100
});

button.addEventListener('click',function(e)
{
   alert('Hello');
});

win1.add(button);

// open window
win1.open();
@@ -42,7 +42,8 @@
N_MESSAGESTRINGS_CONST_DEF(char*, Unknown_key_value_received, "Unknown key:value received");
N_MESSAGESTRINGS_CONST_DEF(char*, Unknown_value_received, "Unknown value received");
N_MESSAGESTRINGS_CONST_DEF(char*, Unsupported_event_name_, "Unsupported event name ");

N_MESSAGESTRINGS_CONST_DEF(char*, Invalid_hostname_or_port, "Invalid host name or port");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep this alphabetical

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@dlifshitz-maca
Copy link

Reviewed.

…ocket.TCP [part2] ver2

Changelog:
- Address comments.
- Update apidoc.

NOTE: [Client part] Use local tcp server to check the functionality, with both ip address and hostname. Was used TCPMonitor plugin for Eclipse.
NOTE: [Server part] Use hostname and ip address of simulator. Connect to it using telnet.

Test cases:
- Use the snippets attached to JIRA to test current functionality.
@alexandergalstyan
Copy link
Author

Updated

@dlifshitz-maca
Copy link

Reviewed.

…ocket.TCP [part2] ver3

Changelog:
- Address comments.
- Code refactoring.

NOTE: [Client part] Use local tcp server to check the functionality, with both ip address and hostname. Was used TCPMonitor plugin for Eclipse.
NOTE: [Server part] Use hostname and ip address of simulator. Connect to it using telnet.

Test cases:
- Use the snippets attached to JIRA to test current functionality.
@alexandergalstyan
Copy link
Author

Updated.

@@ -37,6 +37,7 @@ class TiV8EventContainer : public TiEventContainer
virtual void setDataProperty(const char* propertyName, float value);
virtual void setComplexDataProperty(const char* complexPropertyName, const char* propertyName, const char* value);
virtual void setV8ValueProperty(const char* propertyName, v8::Handle<v8::Value> data);
virtual v8::Handle<v8::Value> getDataProperty(const char* propertyName);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be getV8ValueProperty

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@dlifshitz-maca
Copy link

Reviewed. I'll need your help to set up an environment to fully test with.
Still not quite like addEventListener, but I guess it will do.

…ocket.TCP [part2] ver4

Changelog:
- Address comments.
- Code refactoring.
- Implement write, read methods.

NOTE: [Client part] Use local tcp server to check the functionality, with both ip address and hostname. Was used TCPMonitor plugin for Eclipse.
NOTE: [Server part] Use hostname and ip address of simulator. Connect to it using telnet.

Test cases:
- Use the snippets attached to JIRA to test current functionality.
- app.js updated.
@alexandergalstyan
Copy link
Author

Updated

eventContainer_->fireEvent();

// Disconnect current slot from signal
QObject::disconnect(owner_->tcpServer_, SIGNAL(newConnection()), owner_->eventHandler_, SLOT(accepted()));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done first.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@dlifshitz-maca
Copy link

Reviewed.

…ocket.TCP [part2] ver5

Changelog:
- Address comments.

NOTE: [Client part] Use local tcp server to check the functionality, with both ip address and hostname. Was used TCPMonitor plugin for Eclipse.
NOTE: [Server part] Use hostname and ip address of simulator. Connect to it using telnet.

Test cases:
- Use the snippets attached to JIRA to test current functionality.
- app.js updated.
@alexandergalstyan
Copy link
Author

Updated

{
Q_OBJECT
public:
explicit TCPSocketEventHandler(TiEventContainer* eventContainer, NativeTCPSocketObject* owner)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like how github changed the sorting of additional comments so I think you missed this one. I'll repost it:
Please add an assert too and get rid of the if (owner_) checks

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@dlifshitz-maca
Copy link

Approved with comments.

…ocket.TCP [part2] ver6

Changelog:
- Address comments.

NOTE: [Client part] Use local tcp server to check the functionality, with both ip address and hostname. Was used TCPMonitor plugin for Eclipse.
NOTE: [Server part] Use hostname and ip address of simulator. Connect to it using telnet.

Test cases:
- Use the snippets attached to JIRA to test current functionality.
- app.js updated.
alexandergalstyan added a commit that referenced this pull request Aug 23, 2012
TIMOB-10137: BlackBerry: Implement Ti.Network.Socket and Ti.Network.Socket.TCP [part2]
@alexandergalstyan alexandergalstyan merged commit 8458edf into Macadamian:blackberry Aug 23, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants