public frmP2PPortTestAppMainForm() { // This call is required by the Windows Form Designer. InitializeComponent(); // Add any initialization after the InitializeComponent() call. this._P2PPort = new P2PPort(this); this._P2PPort.NewClientConnection += this.NewClientConnection; this._P2PPort.ClientDisconnection += this.ClientDisconnection; }
internal LocalComponentCommunicationsHandler(object componentObject) { if (!(componentObject is CNDCommunicationsEnvironment.Interfaces.IUseCNDCommunicationsScheme)) { throw (new Exception("Can\'t create a communications handler for the specified object because it must implements the \'IUseCNDCommunicationsScheme\' interface")); } this._componentOwner = componentObject; this._p2pPort = new P2PPort(this, CNDCommunicationsEnvironmentDefinitions.INITIAL_TCP_PORT_FOR_CND_COMMS_ENVIRONMENT, CNDCommunicationsEnvironmentDefinitions.FINAL_TCP_PORT_FOR_CND_COMMS_ENVIRONMENT); this._p2pPort.NewClientConnection += this.ClientDisconnection; this._p2pPort.ClientDisconnection += this.ClientDisconnection; this._listeningPort = this._p2pPort.ListeningPortNumber; this._p2pPortOwnerName = ((CNDCommunicationsEnvironment.Interfaces.IUseCNDCommunicationsScheme) this._componentOwner).ComponentName; }
private CNDService() { this._remoteComponentLinkTable = new CNDRemoteComponentLinkHandlerTable(); this._remoteComponentLinkTable.LinkWithRemoteComponentHasBroken += this.LinkWithRemoteComponentHasBroken; //************************************************************************************ //CREATION THE DEFAULT P2P PORT OF THE SERVICE try { this._serviceP2PPort = new P2PPort(this, CNDServiceDefinitions.CND_SERVICE_DEFAULT_PORT); } catch (Exception ex) { string msg = " Error starting the default P2PPort of CND service : " + ex.Message; CustomEventLog.WriteEntry(EventLogEntryType.Warning, msg); this._serviceP2PPort = new P2PPort(this); msg = "The CND Service default P2PPort was started using a dinamic port number \'" + System.Convert.ToString(this._serviceP2PPort.ListeningPortNumber) + "\' out of the CND service range (" + System.Convert.ToString(CNDCommunicationsEnvironmentDefinitions.INITIAL_TCP_PORT_FOR_CND_COMMS_ENVIRONMENT) + "-" + System.Convert.ToString(CNDCommunicationsEnvironmentDefinitions.FINAL_TCP_PORT_FOR_CND_COMMS_ENVIRONMENT) + ")"; CustomEventLog.WriteEntry(EventLogEntryType.Warning, msg); } //************************************************************************************ //CREATION THE MULTICASTING DATA REPLICATOR SERVER try { this._MultiCastDataReplicationServer = new MultiCastDataReplicationServer(CNDServiceDefinitions.CND_SERVICE_MULTICAST_IP_ADDRESS, CNDServiceDefinitions.CND_SERVICE_MULTICAST_PORT); } catch (Exception ex) { string msg = " Error starting a multicast port for CND service : " + ex.Message; CustomEventLog.WriteEntry(EventLogEntryType.Warning, msg); this._MultiCastDataReplicationServer = new MultiCastDataReplicationServer(); msg = "The CND service Multicast Server was started using a dinamic port number \'" + System.Convert.ToString(this._MultiCastDataReplicationServer.MultiCastPortNumber) + "\' out of the CND service range (" + System.Convert.ToString(CNDCommunicationsEnvironmentDefinitions.INITIAL_TCP_PORT_FOR_CND_COMMS_ENVIRONMENT) + "-" + System.Convert.ToString(CNDCommunicationsEnvironmentDefinitions.FINAL_TCP_PORT_FOR_CND_COMMS_ENVIRONMENT) + ")"; CustomEventLog.WriteEntry(EventLogEntryType.Warning, msg); } this.LoadCNDTableFromFileOrCreateAndEmptyTableIfNotExists(); this._hostName = System.Net.Dns.GetHostName(); //crates the service parameters to publish throuGh the STXServiceDefinitionHandlerServer this._STXServicePArametersCont = new DiscoverableServiceDefinitionParametersContainer(); this._STXServicePArametersCont.AddParameter(CNDServiceDefinitions.CND_SERVICE_NAME, System.Convert.ToString(CNDServiceDefinitions.CNDSERVICE_PUBLIC_NAME)); this._STXServicePArametersCont.AddParameter(CNDServiceDefinitions.CND_SERVICE_HOSTNAME, System.Convert.ToString(this._hostName)); this._STXServicePArametersCont.AddParameter(CNDServiceDefinitions.CND_SERVICE_IP_ADDRESS, this._serviceP2PPort.IPAddress.ToString()); this._STXServicePArametersCont.AddParameter(CNDServiceDefinitions.CND_SERVICE_P2PPORT_PORTNUMBER, System.Convert.ToString(this._serviceP2PPort.ListeningPortNumber)); this._STXServicePArametersCont.AddParameter(CNDServiceDefinitions.CND_SERVICE_MULTICASTSERVER_IP_ADDRESS, System.Convert.ToString(this._MultiCastDataReplicationServer.MultiCastIPAddress)); this._STXServicePArametersCont.AddParameter(CNDServiceDefinitions.CND_SERVICE_MULTICASTSERVER_PORTNUMBER, System.Convert.ToString(this._MultiCastDataReplicationServer.MultiCastPortNumber)); this._STXServicePArametersCont.SaveToFile(CNDServiceDefinitions.CND_SERVICE_SERVICE_PARAMETERS_TABLE_FILENAME); this._serviceParametersTable = new DataTable("CND Service Parameters"); this._serviceParametersTable.Columns.Add("Parameter Name"); this._serviceParametersTable.Columns.Add("Parameter Value"); IEnumerator enumm = this._STXServicePArametersCont.ParametersTable.GetEnumerator(); string paramName = ""; string ParamValue = ""; DataRow paramRow = default(DataRow); while (enumm.MoveNext()) { paramName = System.Convert.ToString(((DictionaryEntry)enumm.Current).Key); ParamValue = System.Convert.ToString(((DictionaryEntry)enumm.Current).Value); paramRow = this._serviceParametersTable.NewRow(); paramRow[0] = paramName; paramRow[1] = ParamValue; this._serviceParametersTable.Rows.Add(paramRow); } //creates the service handler as singleton this._stxServiceHandler = new DiscoverableServiceDefinitionHandlingServer(DiscoverableServiceHandlingOperativeDefs.DiscoverableServiceMode.singletonInstanceNetworkService, CNDServiceDefinitions.CNDSERVICE_PUBLIC_NAME, this._STXServicePArametersCont); CustomEventLog.WriteEntry(EventLogEntryType.SuccessAudit, "CND Service started succesfully @ " + this._hostName + " on " + DateTime.Now.ToString()); }