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