summaryrefslogtreecommitdiff
path: root/src/lib/ecore_con/efl_net_dialer_simple.eo
blob: e1e6522f6878417758fe5f2aed71ace1abafc1d3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
class Efl.Net.Dialer_Simple (Efl.Net.Socket_Simple, Efl.Net.Dialer) {
    [[Connects to a remote server offering an easy to use, buffered I/O.

      The simple dialer is based on @Efl.Net.Socket_Simple, which
      encapsulates an actual @Efl.Net.Socket and uses it with an
      @Efl.Io.Buffered_Stream. This creates an input @Efl.Io.Queue,
      an output @Efl.Io.Queue. Both of these are linked using a receiver
      and a sender @Efl.Io.Copier.

      The idea is that unlike the traditional @Efl.Net.Socket which
      attempts to write directly to the socket and thus may take less data
      than requested, this one will keep the pending data in its own
      buffer, feeding it to the actual socket when
      @Efl.Io.Writer.can_write occurs. This makes its operation much simpler
      as @Efl.Io.Writer.write will always take the full data -- allows
      "write and forget", if unlimited (see
      @Efl.Io.Buffered_Stream.max_queue_size_output).

      Reading is also much simpler since received data is kept in an
      @Efl.Io.Queue, thus its size can be queried with
      @Efl.Io.Buffered_Stream.pending_read and read with
      @Efl.Io.Reader.read or peeked with
      @Efl.Io.Buffered_Stream.slice, then discarded with
      @Efl.Io.Buffered_Stream.discard or
      @Efl.Io.Buffered_Stream.clear.

      When waiting for a complete message, you can then just peek at its
      contents. If it's incomplete do nothing, if complete then either
      @Efl.Io.Reader.read to get a copy or manipulate a read-only
      reference from @Efl.Io.Buffered_Stream.slice and then
      @Efl.Io.Buffered_Stream.discard

      The actual dialer is created using the class given as the
      constructor property @.inner_class and can be retrieved with
      @Efl.Io.Buffered_Stream.inner_io. This should be used with
      care, like extra configuration before @Efl.Net.Dialer.dial is
      called.

      If your object class requires some constructor-only properties
      to be set prior to @Efl.Object.finalize, then use
      @Efl.Io.Buffered_Stream.inner_io directly providing an already
      created dialer.

      @since 1.19
    ]]

    methods {
        @property inner_class {
            [[The class used to create @Efl.Io.Buffered_Stream.inner_io if none was provided.

              This class could be set at construction time and will be
              used to create the inner socket during
              @Efl.Object.finalize.

              It is a helper for users, removing the burden to
              manually create and specify a dialer object.
            ]]
            get {
                [[The internal class used to create the inner dialer.]]
            }
            set {
                [[Constructor-only property to define the class used to create the inner dialer.]]
            }
            values {
                klass: const(Efl.Class); [[The class]]
            }
        }
    }

    implements {
        Efl.Object.finalize;
        Efl.Object.destructor;
        Efl.Io.Buffered_Stream.inner_io { set; }
        Efl.Net.Dialer.dial;
        Efl.Net.Dialer.address_dial { get; }
        Efl.Net.Dialer.connected { get; }
        Efl.Net.Dialer.proxy { get; set; }
        Efl.Net.Dialer.timeout_dial { get; set; }
        Efl.Io.Buffered_Stream.timeout_inactivity { get; set; }
        Efl.Io.Buffered_Stream.max_queue_size_input { get; set; }
        Efl.Io.Buffered_Stream.max_queue_size_output { get; set; }
        Efl.Io.Buffered_Stream.read_chunk_size { get; set; }
        Efl.Io.Buffered_Stream.line_delimiter { get; set; }
    }
}