Esempio n. 1
0
        public GALILEO_RETURN_CODE ConnectIOT(string targetID, int timeout, string password, Action <GALILEO_RETURN_CODE, String> onConnect = null, Action <GALILEO_RETURN_CODE, String> onDisconnect = null)
        {
            byte[]               targetIDBytes  = Encoding.ASCII.GetBytes(targetID);
            byte[]               passwordBytes  = Encoding.ASCII.GetBytes(password);
            OnConnectDelegate    onConnectCB    = null;
            OnDisconnectDelegate onDisconnectCB = null;

            if (onConnect != null)
            {
                onConnectCB = (status, id, length) =>
                {
                    byte[] result = new byte[length];
                    Marshal.Copy(id, result, 0, (int)length);
                    onConnect?.Invoke(status, Encoding.ASCII.GetString(result, 0, (int)length));
                };
            }
            if (onDisconnect != null)
            {
                onDisconnectCB = (status, id, length) =>
                {
                    byte[] result = new byte[length];
                    Marshal.Copy(id, result, 0, (int)length);
                    onDisconnect?.Invoke(status, Encoding.ASCII.GetString(result, 0, (int)length));
                };
            }
            return(GalileoFunctions.ConnectIOT(instance, targetIDBytes, targetIDBytes.Length, timeout, passwordBytes, passwordBytes.Length, onConnectCB, onDisconnectCB));
        }
Esempio n. 2
0
        public AsynchSocketManager(OnConnectDelegate OnConnect,
            OnDisconnectDelegate OnDisconnect,
            OnReceiveDelegate OnReceive)
        {
            // copy the delegates
            this.OnReceive = OnReceive;
            this.OnConnect = OnConnect;
            this.OnDisconnect = OnDisconnect;

            Id++; // increment our "global" id - could use 'real' quid's here...
            MyId = Id; // save the value locally
            StartTime = DateTime.Now.Ticks;
        }
Esempio n. 3
0
 public GALILEO_RETURN_CODE Connect(String targetID, bool autoConnect, int timeout, Action <GALILEO_RETURN_CODE, String> onConnect = null, Action <GALILEO_RETURN_CODE, String> onDisconnect = null)
 {
     byte[] targetIDBytes = Encoding.ASCII.GetBytes(targetID);
     if (onConnect != null)
     {
         onConnectCB = (status, id, length) =>
         {
             byte[] result = new byte[length];
             Marshal.Copy(id, result, 0, (int)length);
             onConnect?.Invoke(status, Encoding.ASCII.GetString(result, 0, (int)length));
         };
     }
     if (onDisconnect != null)
     {
         onDisconnectCB = (status, id, length) =>
         {
             byte[] result = new byte[length];
             Marshal.Copy(id, result, 0, (int)length);
             onDisconnect?.Invoke(status, Encoding.ASCII.GetString(result, 0, (int)length));
         };
     }
     return(GalileoFunctions.Connect(instance, Encoding.ASCII.GetBytes(targetID), targetIDBytes.Length, autoConnect, timeout, onConnectCB, onDisconnectCB));
 }
Esempio n. 4
0
 private void OnConnectMainThread()
 {
     // InvokeRequired required compares the thread ID of the
     // calling thread to the thread ID of the creating thread.
     // If these threads are different, it returns true.
     if (StatusLabel.InvokeRequired)
     {
         OnConnectDelegate d = new OnConnectDelegate(OnConnectMainThread);
         this.Invoke(d, null);
     }
     else
     {
         ConfigBoard();
         System.Threading.Thread.Sleep(400);
         CheckItemsOnPins();
         System.Threading.Thread.Sleep(400);
         foreach (var slot in _slots)
         {
             slot.OnWrite();
         }
         _dataSender.Add(0xD, 0xFF, 1);
         _dataSender.Send();
     }
 }
 internal static extern GALILEO_RETURN_CODE ConnectIOT(IntPtr sdk, byte[] targetID, long length, int timeout, byte[] password, long passLength, OnConnectDelegate onConnect, OnDisconnectDelegate OnDisconnect);
 internal static extern GALILEO_RETURN_CODE Connect(IntPtr sdk, byte[] targetID, long length, bool auto_connect, int timeout, OnConnectDelegate onConnect, OnDisconnectDelegate OnDisconnect);
Esempio n. 7
0
 private static extern int open_websocket(IntPtr websocketHandle, [MarshalAs(UnmanagedType.LPStr)] string uri, OnConnectDelegate onConnect, OnMessageDelegate onMessage, OnErrorDelegate onError, OnCloseDelegate onClose);
Esempio n. 8
0
 public static bool OnConnectCallbackFunction(IntPtr callback)
 {
     onConnectDelegate = (OnConnectDelegate)Marshal.GetDelegateForFunctionPointer(callback, typeof(OnConnectDelegate));
     return(true);
 }