示例#1
0
        public void Disconnect()
        {
            using (socketSyncLock.Lock())
            {
                SendCommand(CommandFormatter.GetDisconnectCommand());

                try
                {
#if NET45
                    socket.Disconnect(false);
#endif
#if NETSTANDARD1_6
                    socket.Shutdown(SocketShutdown.Both);
#endif
                }
                catch (Exception e)
                {
                    log.Error().Print(e, $"Failed to safely disconnect from IQConnect ({socketConnectionType})");
                }
            }
        }
示例#2
0
        public bool Connect()
        {
            try
            {
                using (socketSyncLock.Lock())
                {
                    socket.Connect(endPoint);
                }

                OnConnected();
                WaitForData();
            }
            catch (Exception e)
            {
                log.Error().Print(e, $"Failed to connect to IQConnect ({socketConnectionType})");
                return(false);
            }

            SendCommand(CommandFormatter.GetConnectCommand(socketConnectionType));
            return(true);
        }