public static void OpenBootStrapHttpClients() { try { StringBuilder sb = new StringBuilder(); sb.AppendLine("Initializing: Opening Bootstrap client "); sb.AppendLine("Client Is " + VMuktiAPI.VMuktiInfo.BootStrapIPs[0]); sb.AppendLine(sb1.ToString()); ClsLogging.WriteToTresslog(sb); chHttpBootStrapService = (IHTTPBootStrapService)objHttpBootStrap.OpenClient<IHTTPBootStrapChannel>("http://" + VMuktiAPI.VMuktiInfo.BootStrapIPs[0] + ":80/HttpBootStrap"); clsBootStrapInfo objBootStrapInfo = null; objBootStrapInfo = App.chHttpBootStrapService.svcHttpBSJoin("", null); VMuktiAPI.VMuktiInfo.MainConnectionString = objBootStrapInfo.ConnectionString; switch (objBootStrapInfo.AuthType) { case "SIPAuthentication": VMuktiAPI.VMuktiInfo.CurrentPeer.CurrAuthType = AuthType.SIPAuthentication; break; case "SQLAuthentication": VMuktiAPI.VMuktiInfo.CurrentPeer.CurrAuthType = AuthType.SQLAuthentication; break; default: VMuktiAPI.VMuktiInfo.CurrentPeer.CurrAuthType = AuthType.NotDecided; break; } // ** Client Open Sucessfully StringBuilder sb3 = new StringBuilder(); sb3.AppendLine("Initializing: Client Open Sucessfully "); sb3.AppendLine("BootStrap Client Is: " + VMuktiAPI.VMuktiInfo.BootStrapIPs[0]); //sb3.AppendLine("Main Connection string is : " + VMuktiAPI.VMuktiInfo.MainConnectionString); sb3.AppendLine("Authentation type is : " + objBootStrapInfo.AuthType); sb3.AppendLine(sb1.ToString()); //ClsLogging.WriteToTresslog(sb3); bool isSuperNode = false; if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.NodeWithHttp || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.NodeWithNetP2P) { isSuperNode = false; } else if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.BootStrap || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.SuperNode) { isSuperNode = true; } if (VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName == null || VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName == string.Empty) { VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName = VMuktiAPI.VMuktiInfo.CurrentPeer.CurrentMachineIP; } while (true) { FileStream fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory.ToString() + "\\DomainStatus.txt", FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite); StreamReader sReader = new StreamReader(fs); string strStatus = sReader.ReadToEnd(); sReader.Close(); fs.Close(); if (strStatus == "Initializing") { clsSuperNodeDataContract objSuperNodeDataContract = App.chHttpBootStrapService.svcHttpBsGetSuperNodeIP(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName, VMuktiAPI.VMuktiInfo.CurrentPeer.CurrentMachineIP, isSuperNode); VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP = objSuperNodeDataContract.SuperNodeIP; if (VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP == null || VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP == string.Empty) { //ClsException.WriteToLogFile("Somehow supernode is not available so assigning bootstrap IP"); VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP = VMuktiAPI.VMuktiInfo.BootStrapIPs[0]; } //ClsException.WriteToLogFile("My SuperNode IP is :: " + VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP); OpenSuperNodeClients(); break; } } } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "OpenBootStrapHttpClients()", "App.xaml.cs"); } }
public static void OpenBootStrapHttpClient() { try { chHttpBootStrapService = (IHTTPBootStrapService)objHttpBootStrap.OpenClient<IHTTPBootStrapChannel>("http://" + VMuktiAPI.VMuktiInfo.BootStrapIPs[0] + ":80/HttpBootStrap"); clsBootStrapInfo objBootStrapInfo = null; objBootStrapInfo = App.chHttpBootStrapService.svcHttpBSJoin("", null); switch (objBootStrapInfo.AuthType) { case "SIPAuthentication": VMuktiAPI.VMuktiInfo.CurrentPeer.CurrAuthType = AuthType.SIPAuthentication; break; case "SQLAuthentication": VMuktiAPI.VMuktiInfo.CurrentPeer.CurrAuthType = AuthType.SQLAuthentication; break; default: VMuktiAPI.VMuktiInfo.CurrentPeer.CurrAuthType = AuthType.NotDecided; break; } bool isSuperNode = false; if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.BootStrap || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.SuperNode) { isSuperNode = true; } else { isSuperNode = false; } if (VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName == null || VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName == string.Empty) { VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName = VMuktiAPI.VMuktiInfo.CurrentPeer.CurrentMachineIP; } clsSuperNodeDataContract objSuperNodeDataContract = App.chHttpBootStrapService.svcHttpBsGetSuperNodeIP(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName, VMuktiAPI.VMuktiInfo.CurrentPeer.CurrentMachineIP, isSuperNode); VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP = objSuperNodeDataContract.SuperNodeIP; if (VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP == null || VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP == string.Empty) { ClsException.WriteToLogFile("Somehow supernode is not available so assigning bootstrap IP"); VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP = VMuktiAPI.VMuktiInfo.BootStrapIPs[0]; } ClsException.WriteToLogFile("My SuperNode IP is :: " + VMuktiAPI.VMuktiInfo.CurrentPeer.SuperNodeIP); } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "OpenBootStrapHttpClient", "App.xaml.cs"); } }
private void Dispose(bool disposing) { if (!this.disposed) { if (disposing) { try { if (chHttpBootStrapService != null) { chHttpBootStrapService = null; } if (objHttpBootStrap != null) { objHttpBootStrap = null; } if (App.chNetP2PSuperNodeChannel != null) { ((NetPeerClient)App.objNetP2PSuperNode).CloseClient<INetP2PSuperNodeChannel>(); App.chNetP2PSuperNodeChannel = null; } if (App.objNetP2PSuperNode != null) { App.objNetP2PSuperNode = null; } if (chHttpSuperNodeService != null) { chHttpSuperNodeService = null; } if (objHttpSuperNode != null) { objHttpSuperNode = null; } if (objNetP2PSuperNode != null) { objNetP2PSuperNode = null; } if (chNetP2PSuperNodeChannel != null) { chNetP2PSuperNodeChannel = null; } if (DomainSetUp != null) { DomainSetUp = null; } if (thBootStrapDomain != null) { thBootStrapDomain = null; } if (thSuperNodeDomain != null) { thSuperNodeDomain = null; } } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "Dispose()", "App.xaml.cs"); } } disposed = true; } GC.SuppressFinalize(this); }