src/sync.h
author Volker Birk <vb@pep-project.org>
Tue, 03 May 2016 16:04:21 +0200
changeset 574 3c21749a79a6
parent 573 28b0d3154f0f
child 597 560c0caf14ef
permissions -rw-r--r--
reuse sendBeacon() for sendHandshakeRequest()
vb@572
     1
#pragma once
vb@572
     2
vb@572
     3
#include "message.h"
vb@572
     4
vb@572
     5
vb@572
     6
// this module is for being used WITHOUT the Transport API in transport.h
vb@572
     7
// DO NOT USE IT WHEN USING Transport API!
vb@572
     8
vb@572
     9
vb@572
    10
#ifdef __cplusplus
vb@572
    11
extern "C" {
vb@572
    12
#endif
vb@572
    13
vb@572
    14
// sendBeacon() - send a beacon message
vb@572
    15
//
vb@572
    16
//  parameters:
vb@572
    17
//      beacon (in)     message struct with beacon message to send
vb@572
    18
//
vb@572
    19
//  return value:
vb@572
    20
//      must return PEP_STATUS_OK or any other value on error
vb@572
    21
vb@572
    22
typedef PEP_STATUS (*sendBeacon_t)(message beacon);
vb@572
    23
vb@572
    24
vb@572
    25
typedef enum _sync_handshake_result {
vb@572
    26
    SYNC_HANDSHAKE_CANCEL = -1,
vb@572
    27
    SYNC_HANDSHAKE_ACCEPTED = 0,
vb@572
    28
    SYNC_HANDSHAKE_REJECTED = 1
vb@572
    29
} sync_handshake_result;
vb@572
    30
vb@572
    31
// showHandshake() - do a handshake and deliver the result
vb@572
    32
//
vb@572
    33
//  parameters:
vb@572
    34
//      self (in)       own identity
vb@572
    35
//      partner (in)    identity of partner
vb@572
    36
//
vb@572
    37
//  return value:
vb@572
    38
//      result of handshake
vb@572
    39
vb@572
    40
typedef sync_handshake_result (*showHandshake_t)(
vb@572
    41
        pEp_identity self,
vb@572
    42
        pEp_identity partner
vb@572
    43
    );
vb@572
    44
vb@572
    45
vb@572
    46
// register_sync_callbacks() - register adapter's callbacks
vb@572
    47
//
vb@572
    48
//  parameters:
vb@572
    49
//      sendBeacon (in)             callback for sending beacon
vb@572
    50
//      showHandshake (in)          callback for doing the handshake
vb@572
    51
//
vb@572
    52
//  return value:
vb@572
    53
//      PEP_STATUS_OK or any other value on errror
vb@573
    54
//
vb@573
    55
//  caveat:
vb@573
    56
//      call that BEFORE you're using any other part of the engine
vb@572
    57
vb@572
    58
DYNAMIC_API PEP_STATUS register_sync_callbacks(
vb@572
    59
        sendBeacon_t sendBeacon,
vb@572
    60
        showHandshake_t showHandshake
vb@572
    61
    );
vb@572
    62
vb@572
    63
vb@572
    64
// unregister_sync_callbacks() - unregister adapter's callbacks
vb@572
    65
vb@573
    66
DYNAMIC_API void unregister_sync_callbacks();
vb@572
    67
vb@572
    68
vb@572
    69
#ifdef __cplusplus
vb@572
    70
}
vb@572
    71
#endif
vb@572
    72