Esempio n. 1
0
        private void native_listen_cb(IntPtr ziti_connection, int status)
        {
            ZitiConnection conn = new ZitiConnection(this, zitiContext, "this is context in my connection");

            this.conn = conn;
            listenCallback(conn, (ZitiStatus)status);
        }
Esempio n. 2
0
        /// <summary>
        /// This is the function used to initiate the chain of callbacks that will allow the user of the
        /// sdk to actually establish connectivity.
        ///
        /// Two callbacks must be provided in this function which will allows the callee to control the
        /// data flow. <see cref="onConnected"/> will be called first and only once. After which <see cref="onData"/>
        /// may be called repeatedly.
        /// </summary>
        /// <param name="onConnected">A callback which is called after the Dial function completes. This callback
        /// will contain the result of the invocation. It is highly recommend to verify the result of the function.</param>
        /// <param name="onData">A callback called whenever data arrives on the connection</param>
        public void Dial(OnZitiConnected onConnected, OnZitiDataReceived onData)
        {
            this.onConnected = onConnected;
            this.onData      = onData;
            ZitiConnection conn = new ZitiConnection(this, zitiContext, "this is context in my connection");

            this.conn = conn;
            Native.API.ziti_dial(conn.nativeConnection, Name, conn_cb, data_cb);
        }
Esempio n. 3
0
        private void native_on_client_cb(IntPtr ziti_connection_server, IntPtr ziti_connection_client, int status)
        {
            ZitiConnection svr = new ZitiConnection(this, zitiContext, "this is context in my connection");

            svr.nativeConnection = ziti_connection_server;
            ZitiConnection client = new ZitiConnection(this, zitiContext, "this is context in my connection");

            client.nativeConnection = ziti_connection_client;
            onClientConnected(svr, client, (ZitiStatus)status);
        }
Esempio n. 4
0
        /// <summary>
        /// Used to indicate that this program should listen for and accept connections from other identities.
        ///
        /// Any call to <see cref="Listen"/> must be configured to host the service using the Ziti Controller.
        ///
        /// Two callbacks are required to be supplied. <see cref="listenCallback"/> is called after the Listen
        /// function completes will contain the result of the invocation. It is highly recommend to verify the
        /// result of the function. <see cref="onClient"/> will be called any time another identity tries to
        /// <see cref="Dial(OnZitiConnected, OnZitiDataReceived)"/> this service.
        /// </summary>
        /// <param name="listenCallback"></param>
        /// <param name="onClient"></param>
        public void Listen(OnZitiListening listenCallback, OnZitiClientConnected onClient)
        {
            this.listenCallback = listenCallback;
            onClientConnected   = onClient;

            ZitiConnection conn = new ZitiConnection(this, zitiContext, "this is context in my connection");

            this.conn = conn;
            Native.API.ziti_listen(conn.nativeConnection, Name, native_listen_cb, native_on_client_cb);
        }
Esempio n. 5
0
 /// <summary>
 /// Creates a <see cref="ZitiStream"/> from the provided <see cref="ZitiConnection"/>
 /// </summary>
 /// <param name="conn">The <see cref="ZitiConnection"/> to create a <see cref="ZitiStream"/> from </param>
 public ZitiStream(ZitiConnection conn)
 {
     this.conn = conn;
     conn.MarkAsStream();
 }