private static void OpenConnectionFinal(ConnectionInfo ConnectionInfo, ConnectionInfo.Force Force, Form ConForm) { try { if (ConnectionInfo.Hostname == "" && ConnectionInfo.Protocol != ProtocolType.IntApp) { MessageCollector.AddMessage(MessageClass.WarningMsg, Language.strConnectionOpenFailedNoHostname); return; } StartPreConnectionExternalApp(ConnectionInfo); if ((Force & ConnectionInfo.Force.DoNotJump) != ConnectionInfo.Force.DoNotJump) { if (SwitchToOpenConnection(ConnectionInfo)) { return; } } ProtocolFactory protocolFactory = new ProtocolFactory(); ProtocolBase newProtocol = protocolFactory.CreateProtocol(ConnectionInfo); string connectionPanel = SetConnectionPanel(ConnectionInfo, Force); Form connectionForm = SetConnectionForm(ConForm, connectionPanel); Control connectionContainer = SetConnectionContainer(ConnectionInfo, connectionForm); SetConnectionFormEventHandlers(newProtocol, connectionForm); SetConnectionEventHandlers(newProtocol); BuildConnectionInterfaceController(ConnectionInfo, newProtocol, connectionContainer); newProtocol.Force = Force; if (newProtocol.Initialize() == false) { newProtocol.Close(); return; } if (newProtocol.Connect() == false) { newProtocol.Close(); return; } ConnectionInfo.OpenConnections.Add(newProtocol); SetTreeNodeImages(ConnectionInfo); frmMain.Default.SelectedConnection = ConnectionInfo; } catch (Exception ex) { MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionOpenFailed + Environment.NewLine + ex.Message); } }
/// <summary> /// Closes the specified protocol allowing for command packet transmission. /// </summary> /// <param name="protocolId">A UInt16 that specifies the unique protocol /// identifier.</param> public void Close(ushort protocolId) { ProtocolBase p = null; lock (protocolImplementations) { if (protocolImplementations.ContainsKey(protocolId)) { p = protocolImplementations[protocolId]; protocolImplementations.Remove(protocolId); } } if (p != null) { p.Close(); } }