2016-02-12 05:36:19 -08:00
|
|
|
type Ecore_Con_Dns_Cb: __undefined_type;
|
|
|
|
|
2014-08-22 09:31:33 -07:00
|
|
|
abstract Ecore.Con.Base (Eo.Base) {
|
|
|
|
legacy_prefix: ecore_con;
|
2014-08-22 03:11:41 -07:00
|
|
|
eo_prefix: ecore_con_obj;
|
|
|
|
data: null;
|
2015-05-07 08:36:45 -07:00
|
|
|
methods {
|
|
|
|
@property ip {
|
2015-06-19 07:18:38 -07:00
|
|
|
[[Control the IP address of a server that has been connected to.
|
|
|
|
|
|
|
|
The param is a pointer to an internal string that contains the IP
|
|
|
|
address of the connected server in the form "XXX.YYY.ZZZ.AAA" IP
|
|
|
|
notation. This string should not be modified or trusted to stay
|
|
|
|
valid after deletion for the svr object. If no IP is known
|
|
|
|
null is returned.
|
|
|
|
]]
|
2014-08-22 03:11:41 -07:00
|
|
|
get {
|
|
|
|
legacy: null;
|
|
|
|
}
|
|
|
|
values {
|
2015-06-19 07:18:38 -07:00
|
|
|
ip: const(char)*; [[The IP address]]
|
2014-08-22 03:11:41 -07:00
|
|
|
}
|
|
|
|
}
|
2015-05-07 08:36:45 -07:00
|
|
|
@property uptime {
|
2015-06-19 07:18:38 -07:00
|
|
|
[[Check how long the object has been connected
|
|
|
|
|
|
|
|
This function is used to find out how long a client has been
|
|
|
|
connected for.
|
|
|
|
]]
|
2014-08-22 03:11:41 -07:00
|
|
|
get {
|
|
|
|
legacy: null;
|
|
|
|
}
|
|
|
|
values {
|
2015-06-19 07:18:38 -07:00
|
|
|
uptime: double; [[The total time, in seconds, that the object has been connected.]]
|
2014-08-22 03:11:41 -07:00
|
|
|
}
|
|
|
|
}
|
2015-05-07 08:36:45 -07:00
|
|
|
@property port {
|
2015-06-19 07:18:38 -07:00
|
|
|
[[Return the port that the obj is connected to]]
|
2014-08-28 06:17:16 -07:00
|
|
|
set {
|
|
|
|
legacy: null;
|
|
|
|
}
|
2014-08-22 03:11:41 -07:00
|
|
|
get {
|
|
|
|
legacy: null;
|
|
|
|
}
|
|
|
|
values {
|
2015-06-19 07:18:38 -07:00
|
|
|
port: int; [[The The port that obj is connected to, or -1 on error.]]
|
2014-08-22 03:11:41 -07:00
|
|
|
}
|
|
|
|
}
|
2015-05-07 08:36:45 -07:00
|
|
|
@property fd {
|
2015-06-19 07:18:38 -07:00
|
|
|
[[Get the fd that the server is connected to
|
|
|
|
|
|
|
|
This function returns the fd which is used by the underlying server
|
|
|
|
connection. It should not be tampered with unless you REALLY know
|
|
|
|
what you are doing.
|
|
|
|
|
|
|
|
Note: This function is only valid for servers created with
|
2015-07-08 07:12:32 -07:00
|
|
|
\@ref ecore_con_server_connect.
|
2015-06-19 07:18:38 -07:00
|
|
|
|
|
|
|
Warning: Seriously. Don't use this unless you know what you are doing.
|
|
|
|
|
|
|
|
@since 1.1
|
|
|
|
]]
|
2014-08-22 03:11:41 -07:00
|
|
|
get {
|
|
|
|
legacy: null;
|
|
|
|
}
|
|
|
|
values {
|
2015-06-19 07:18:38 -07:00
|
|
|
fd: int; [[The fd, or -1 on failure.]]
|
2014-08-22 03:11:41 -07:00
|
|
|
}
|
|
|
|
}
|
2015-05-07 08:36:45 -07:00
|
|
|
@property connected {
|
2015-06-19 07:18:38 -07:00
|
|
|
[[Returns whether the client is still connected]]
|
2014-08-22 03:11:41 -07:00
|
|
|
get {
|
|
|
|
legacy: null;
|
|
|
|
}
|
|
|
|
values {
|
2015-06-19 07:18:38 -07:00
|
|
|
connected: bool; [[Returns true if connected, false otherwise.]]
|
2014-08-22 03:11:41 -07:00
|
|
|
}
|
|
|
|
}
|
2015-05-07 08:36:45 -07:00
|
|
|
@property timeout {
|
2015-06-19 07:18:38 -07:00
|
|
|
[[Control the default time after which an inactive client will be
|
|
|
|
disconnected.
|
|
|
|
|
|
|
|
This function is used by the server to set the default idle timeout
|
|
|
|
on clients. If the any of the clients becomes idle for a time higher
|
|
|
|
than this value, it will be disconnected. A value of < 1 disables
|
|
|
|
the idle timeout.
|
|
|
|
|
2015-07-08 07:12:32 -07:00
|
|
|
This timeout is not affected by the one set by @.timeout.set. A
|
|
|
|
client will be disconnected whenever the client or the server
|
|
|
|
timeout is reached. That means, the lower timeout value will be
|
|
|
|
used for that client if @.timeout.set is used on it.
|
2015-06-19 07:18:38 -07:00
|
|
|
]]
|
2014-08-22 03:11:41 -07:00
|
|
|
set {
|
|
|
|
legacy: null;
|
|
|
|
}
|
|
|
|
get {
|
|
|
|
legacy: null;
|
|
|
|
}
|
|
|
|
values {
|
2015-06-19 07:18:38 -07:00
|
|
|
timeout: double; [[The timeout, in seconds, to disconnect after.]]
|
2014-08-22 03:11:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
flush {
|
2015-06-19 07:18:38 -07:00
|
|
|
[[Flushes all pending data to the given server.
|
|
|
|
|
|
|
|
This function will block until all data is sent to the server.
|
|
|
|
]]
|
2014-08-22 03:11:41 -07:00
|
|
|
legacy: null;
|
|
|
|
}
|
|
|
|
send {
|
2015-06-19 07:18:38 -07:00
|
|
|
[[Sends the given data to the given server.
|
|
|
|
|
|
|
|
This function will send the given data to the server as soon as the
|
|
|
|
program is back to the main loop. Thus, this function returns
|
|
|
|
immediately (non-blocking). If the data needs to be sent now, call
|
2015-07-08 07:12:32 -07:00
|
|
|
\@ref ecore_con_server_flush after this one.
|
2015-06-19 07:18:38 -07:00
|
|
|
]]
|
2014-08-22 03:11:41 -07:00
|
|
|
legacy: null;
|
|
|
|
|
|
|
|
params {
|
2015-06-19 07:18:38 -07:00
|
|
|
data: const(void)*; [[The given data]]
|
|
|
|
size: int; [[Length of the data, in bytes.]]
|
2014-08-22 03:11:41 -07:00
|
|
|
}
|
2015-06-19 07:18:38 -07:00
|
|
|
return: int; [[The number of bytes sent. 0 will be returned if there
|
|
|
|
is an error.]]
|
2014-08-22 03:11:41 -07:00
|
|
|
}
|
|
|
|
lookup @class {
|
2015-06-19 07:18:38 -07:00
|
|
|
[[Do an asynchronous DNS lookup.
|
|
|
|
|
|
|
|
This function performs a DNS lookup on the hostname specified by name,
|
|
|
|
then calls done_cb with the result and the data given as parameter.
|
|
|
|
The result will be given to the done_cb as follows:
|
|
|
|
|
|
|
|
canonname - the canonical name of the address, ip - the resolved ip
|
|
|
|
address, addr - a pointer to the socket address, addrlen - the length
|
2015-07-08 07:12:32 -07:00
|
|
|
of the socket address, in bytes, data - the data pointer given as
|
|
|
|
parameter.
|
2015-06-19 07:18:38 -07:00
|
|
|
]]
|
2014-08-22 03:11:41 -07:00
|
|
|
params {
|
2015-06-19 07:18:38 -07:00
|
|
|
name: const(char)* @nonull; [[IP address or server name to translate.]]
|
|
|
|
done_cb: Ecore_Con_Dns_Cb; [[Callback to notify when done.]]
|
|
|
|
data: const(void)*; [[User data to be given to done_cb.]]
|
2014-08-22 03:11:41 -07:00
|
|
|
}
|
2015-06-19 07:18:38 -07:00
|
|
|
return: bool; [[true if the request did not fail to be set up, false otherwise.]]
|
2014-08-22 03:11:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
implements {
|
2014-08-29 03:40:29 -07:00
|
|
|
@virtual .ip.get;
|
|
|
|
@virtual .uptime.get;
|
|
|
|
@virtual .port.set;
|
|
|
|
@virtual .port.get;
|
|
|
|
@virtual .fd.get;
|
|
|
|
@virtual .connected.get;
|
|
|
|
@virtual .timeout.set;
|
|
|
|
@virtual .timeout.get;
|
|
|
|
@virtual .flush;
|
|
|
|
@virtual .send;
|
2014-08-22 03:11:41 -07:00
|
|
|
}
|
2014-08-22 06:33:26 -07:00
|
|
|
events {
|
|
|
|
data,received: Ecore_Con_Event_Data_Received;
|
|
|
|
connection,upgraded;
|
|
|
|
connection,error: const(char) *;
|
|
|
|
}
|
2014-08-22 03:11:41 -07:00
|
|
|
}
|
2014-08-22 05:14:59 -07:00
|
|
|
|
2014-08-22 06:33:26 -07:00
|
|
|
/* FIXME: Should actually be a binbuf. */
|
2015-05-12 08:15:29 -07:00
|
|
|
struct Ecore_Con_Event_Data_Received {
|
2015-06-11 08:51:43 -07:00
|
|
|
data: void *; [[The data thet got sent.]]
|
|
|
|
size: int; [[The length of the data sent.]]
|
2015-05-12 08:15:29 -07:00
|
|
|
}
|
2014-08-22 06:33:26 -07:00
|
|
|
|
2014-11-27 09:13:20 -08:00
|
|
|
/* TODO
|
2014-08-28 04:00:31 -07:00
|
|
|
* Add events (to all of the ecore con stuff, e.g url).
|
|
|
|
* Make server the father of the client - make sure I don't leak references.
|
|
|
|
*
|
2014-08-28 06:17:16 -07:00
|
|
|
* Still need to add constructor client, and most likely migrate ecore_con_eet.
|
2014-08-28 04:00:31 -07:00
|
|
|
*
|
|
|
|
* Split server to two classes, listener and connector (or w/e).
|
2014-08-28 06:17:16 -07:00
|
|
|
*
|
|
|
|
* Mark the constructing properties all around.
|
2014-08-22 05:14:59 -07:00
|
|
|
*/
|