예제 #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));
        }
예제 #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;
        }
예제 #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));
 }
예제 #4
0
        /// <summary>
        /// Connect to TN3270 server using the connection details specified.
        /// </summary>
        /// <remarks>
        /// You should set the Audit property to an instance of an object that implements
        /// the IAudit interface if you want to see any debugging information from this function
        /// call.
        /// </remarks>
        /// <param name="host">Host name or IP address. Mandatory</param>
        /// <param name="port">TCP/IP port to connect to (default TN3270 port is 23)</param>
        /// <param name="lu">TN3270E LU to connect to. Specify null for no LU.</param>
        public void Connect(string host, int port, string lu)
        {
            if (this.currentConnection != null)
            {
                this.currentConnection.Disconnect();
                this.currentConnection.CursorLocationChanged -= currentConnection_CursorLocationChanged;
            }

            try
            {
                semaphore.Reset();

                this.currentConnection       = null;
                this.currentConnection       = new TN3270API();
                this.currentConnection.Debug = debug;
                this.currentConnection.RunScriptRequested    += new RunScriptDelegate(currentConnection_RunScriptEvent);
                this.currentConnection.CursorLocationChanged += currentConnection_CursorLocationChanged;
                this.currentConnection.Disconnected          += apiOnDisconnectDelegate;

                this.apiOnDisconnectDelegate = new OnDisconnectDelegate(currentConnection_OnDisconnect);

                //
                // Debug out our current state
                //
                if (sout != null)
                {
                    sout.WriteLine("Open3270 emulator version " + Assembly.GetAssembly(typeof(Open3270.TNEmulator)).GetName().Version + " (c) 2004-2017 Mike Warriner and many others");
#if false
                    sout.WriteLine("(c) 2004-2006 Mike Warriner ([email protected]). All rights reserved");
                    sout.WriteLine("");
                    sout.WriteLine("This is free software; you can redistribute it and/or modify it");
                    sout.WriteLine("under the terms of the GNU Lesser General Public License as");
                    sout.WriteLine("published by the Free Software Foundation; either version 2.1 of");
                    sout.WriteLine("the License, or (at your option) any later version.");
                    sout.WriteLine("");
                    sout.WriteLine("This software is distributed in the hope that it will be useful,");
                    sout.WriteLine("but WITHOUT ANY WARRANTY; without even the implied warranty of");
                    sout.WriteLine("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU");
                    sout.WriteLine("Lesser General Public License for more details.");
                    sout.WriteLine("");
                    sout.WriteLine("You should have received a copy of the GNU Lesser General Public");
                    sout.WriteLine("License along with this software; if not, write to the Free");
                    sout.WriteLine("Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA");
                    sout.WriteLine("02110-1301 USA, or see the FSF site: http://www.fsf.org.");
                    sout.WriteLine("");
#endif

                    if (firstTime)
                    {
                        firstTime = false;
                    }
                    if (Debug)
                    {
                        Config.Dump(sout);
                        sout.WriteLine("Connect to host \"" + host + "\"");
                        sout.WriteLine("           port \"" + port + "\"");
                        sout.WriteLine("           LU   \"" + lu + "\"");
                        sout.WriteLine("     Local IP   \"" + _localIP + "\"");
                    }
                }
                else
                {
                }

                currentConnection.UseSSL = this.mUseSSL;


                /// Modified CFCJR Feb/29/2008 to support local IP endpoint
                if (!string.IsNullOrEmpty(_localIP))
                {
                    currentConnection.Connect(this.sout, _localIP, host, port, this.mConnectionConfiguration);
                }
                else
                {
                    currentConnection.Connect(this.sout, host, port, lu, this.mConnectionConfiguration);
                }

                currentConnection.WaitForConnect(-1);
                DisposeOfCurrentScreenXML();
                currentScreenXML = null;
                // Force refresh
                // GetScreenAsXML();
            }
            catch (Exception)
            {
                currentConnection = null;
                throw;
            }

            // These don't close the connection
            try
            {
                this.mScreenName = "Start";
                Refresh(true, 10000);
                if (sout != null && Debug == true)
                {
                    sout.WriteLine("Debug::Connected");
                }
                //mScreenProcessor.Update_Screen(currentScreenXML, true);
            }
            catch (Exception)
            {
                throw;
            }
            return;
        }
예제 #5
0
        /// <summary>
        /// Connect to TN3270 server using the connection details specified.
        /// </summary>
        /// <remarks>
        /// You should set the Audit property to an instance of an object that implements
        /// the IAudit interface if you want to see any debugging information from this function
        /// call.
        /// </remarks>
        /// <param name="host">Host name or IP address. Mandatory</param>
        /// <param name="port">TCP/IP port to connect to (default TN3270 port is 23)</param>
        /// <param name="lu">TN3270E LU to connect to. Specify null for no LU.</param>
        public void Connect(string host, int port, string lu)
        {
            if (currentConnection != null)
            {
                currentConnection.Disconnect();
            }
            //
            //
            try
            {
                mre.Reset();

                currentConnection                 = null;
                currentConnection                 = new TN3270API();
                currentConnection.Debug           = mDebug;
                currentConnection.RunScriptEvent += new RunScriptDelegate(currentConnection_RunScriptEvent);
                apiOnDisconnectDelegate           = new OnDisconnectDelegate(currentConnection_OnDisconnect);
                currentConnection.OnDisconnect   += apiOnDisconnectDelegate;
                //
                // Debug out our current state
                //
                if (sout != null)
                {
                    sout.WriteLine("Open3270 emulator version " + Assembly.GetAssembly(typeof(Open3270.TNEmulator)).GetName().Version);
                    sout.WriteLine("(c) 2004-2006 Mike Warriner ([email protected]). All rights reserved");
                    sout.WriteLine("");
                    //
                    if (mFirstTime)
                    {
                        mFirstTime = false;
                    }
                    if (Debug)
                    {
                        Config.Dump(sout);
                        sout.WriteLine("Connect to host \"" + host + "\"");
                        sout.WriteLine("           port \"" + port + "\"");
                        sout.WriteLine("           LU   \"" + lu + "\"");
                        sout.WriteLine("     Local IP   \"" + _localIP + "\"");
                    }
                }
                else
                {
                }
                //
                currentConnection.UseSSL = this.mUseSSL;
                //
                /// Modified CFCJR Feb/29/2008 to support local IP endpoint
                if (!string.IsNullOrEmpty(_localIP))
                {
                    currentConnection.Connect(this.sout, _localIP, host, port, this.mConnectionConfiguration);
                }
                else
                {
                    currentConnection.Connect(this.sout, host, port, lu, this.mConnectionConfiguration);
                }
                //
                //
                //
                currentConnection.WaitForConnect(-1);
                DisposeOfCurrentScreenXML();
                _currentScreenXML = null;                 // force refresh // GetScreenAsXML();
            }
            catch (Exception)
            {
                currentConnection = null;
                throw;
            }
            // these don't close the connection
            try
            {
                this.mScreenName = "Start";
                Refresh(true, 40000);
                if (sout != null && Debug == true)
                {
                    sout.WriteLine("Debug::Connected");
                }
                //mScreenProcessor.Update_Screen(currentScreenXML, true);
            }
            catch (Exception)
            {
                throw;
            }
            return;
        }
 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);
예제 #8
0
 public static bool OnDisconnectCallbackFunction(IntPtr callback)
 {
     onDisconnectDelegate = (OnDisconnectDelegate)Marshal.GetDelegateForFunctionPointer(callback, typeof(OnDisconnectDelegate));
     return(true);
 }