summaryrefslogtreecommitdiff
path: root/vendor/packaged/thrift/src/Server/TServerTransport.php
blob: 15a27afa8ada47b86e1755fca8944073f2dffb40 (plain)
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
<?php

namespace Thrift\Server;

use Thrift\Exception\TTransportException;

/**
 * Generic class for Server agent.
 *
 * @package thrift.transport
 */
abstract class TServerTransport
{
    /**
     * List for new clients
     *
     * @abstract
     * @return void
     */
    abstract public function listen();

    /**
     * Close the server
     *
     * @abstract
     * @return void
     */
    abstract public function close();

    /**
     * Subclasses should use this to implement
     * accept.
     *
     * @abstract
     * @return TTransport
     */
    abstract protected function acceptImpl();

    /**
     * Uses the accept implemtation. If null is returned, an
     * exception is thrown.
     *
     * @throws TTransportException
     * @return TTransport
     */
    public function accept()
    {
        $transport = $this->acceptImpl();

        if ($transport == null) {
            throw new TTransportException("accept() may not return NULL");
        }

        return $transport;
    }
}