basex.Session #24

Closed
opened 2017-08-29 09:22:01 +01:00 by tcdaly · 3 comments
tcdaly commented 2017-08-29 09:22:01 +01:00 (Migrated from github.com)

Hello,
In
var session=basex.Session(host, port, username, password)
is basex.Session a synchronous function? Can it be assumed that the session was created successfully if no socketError event is emitted?
Thanks.

Hello, In `var session=basex.Session(host, port, username, password)` is basex.Session a synchronous function? Can it be assumed that the session was created successfully if no socketError event is emitted? Thanks.
apb2006 commented 2017-08-29 10:07:52 +01:00 (Migrated from github.com)

The Session function only starts the connection process by calling net.createConnection. The rest is asynchronous. Each Session has a state

var states = {
    DISCONNECTED: 0,
    CONNECTING: 1,
    AUTHORIZE: 2,
    CONNECTED: 3,
    CLOSING: 4
};

Immediately after a session object is created with no error it is in state CONNECTING

The `Session` function only starts the connection process by calling [net.createConnection](https://nodejs.org/api/net.html#net_net_createconnection_port_host_connectlistener). The rest is asynchronous. Each `Session` has a state ``` var states = { DISCONNECTED: 0, CONNECTING: 1, AUTHORIZE: 2, CONNECTED: 3, CLOSING: 4 }; ``` Immediately after a session object is created with no error it is in state CONNECTING
tcdaly commented 2017-08-29 10:11:59 +01:00 (Migrated from github.com)

Thank you. Is there a way then that my application can be informed when the connection has been made successfully?

Thank you. Is there a way then that my application can be informed when the connection has been made successfully?
apb2006 commented 2017-08-29 10:22:55 +01:00 (Migrated from github.com)

The session will emit a "connect" event https://github.com/apb2006/basex-node/blob/master/index.js#L127

The session will emit a "connect" event https://github.com/apb2006/basex-node/blob/master/index.js#L127
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
quodatum/basex-node#24
No description provided.