aboutsummaryrefslogtreecommitdiffstats
path: root/fnet/src/vespa/fnet/iserveradapter.h
blob: c58a3e7ebc2a493173e3c1472b358ce18e301652 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

/**
 * This class must be extended by the server application. It is needed
 * to let the application define the target packet handler for
 * incoming channels without creating a race condition.
 **/
class FNET_IServerAdapter
{
public:

    /**
     * Destructor.  No cleanup needed for base class.
     */
    virtual ~FNET_IServerAdapter(void) { }

    /**
     * This method is called by the network layer when opening a new
     * channel on a connection handled by this server adapter. The
     * implementation of this method must define the target packet
     * handler and the application context for the given channel. The
     * 'pcode' parameter indicates the type of the first packet to be
     * received on this channel.
     *
     * @return success(true)/fail(false)
     * @param channel the channel being initialized.
     * @param pcode the packet type of the first packet on the channel.
     **/
    virtual bool InitChannel(FNET_Channel *channel,
                             uint32_t pcode) = 0;
};