/// <summary> /// /// </summary> private void registerPeerChannel(string id) { XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas(); quotas.MaxArrayLength = int.MaxValue; quotas.MaxBytesPerRead = int.MaxValue; quotas.MaxDepth = int.MaxValue; quotas.MaxNameTableCharCount = int.MaxValue; quotas.MaxStringContentLength = int.MaxValue; NetPeerTcpBinding myBinding = new NetPeerTcpBinding(); myBinding.ReaderQuotas = quotas; myBinding.Resolver.Mode = System.ServiceModel.PeerResolvers.PeerResolverMode.Pnrp; if (parameters.UseTLS) { myBinding.Security.Mode = SecurityMode.Transport; myBinding.Security.Transport.CredentialType = PeerTransportCredentialType.Password; } else { myBinding.Security.Mode = SecurityMode.None; } // if the listening address is specified, use it if (parameters.Ip != null) { this.doInfo(this, new ScallopInfoEventArgs("Ignored listening address")); /* this.doInfo(this, new ScallopInfoEventArgs("Listening on ip " + parameters.Ip.ToString())); myBinding.ListenIPAddress = parameters.Ip; */ } EndpointAddress myAddress = new EndpointAddress("net.p2p://Scallop_" + this.Version + "_" + parameters.NetworkName + "/"); this.factory = new DuplexChannelFactory<IPeerChannelChannel>(new InstanceContext(this), myBinding, myAddress); this.factory.Faulted += this.factory_faulted; this.factory.Closed += this.factory_faulted; if (parameters.UseTLS) this.factory.Credentials.Peer.MeshPassword = parameters.TLSPassword; this.chan = factory.CreateChannel(); ScallopMessageFilter msgFilter = new ScallopMessageFilter(id); peer = chan.GetProperty<PeerNode>(); peer.Offline += new EventHandler(peer_Offline); peer.Online += new EventHandler(peer_Online); peer.MessagePropagationFilter = msgFilter; this.chan.Open(); this.chan.PCJoin(this.id); this.registered = true; this.id = id; //if(peer.IsOnline) // this.doStateChanged(this, new ScallopNetworkStatusChangedEventArgs(ScallopNetworkState.Online, null, "Online")); }
/// <summary> /// /// </summary> private void registerPeerChannel(string id) { XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas(); quotas.MaxArrayLength = int.MaxValue; quotas.MaxBytesPerRead = int.MaxValue; quotas.MaxDepth = int.MaxValue; quotas.MaxNameTableCharCount = int.MaxValue; quotas.MaxStringContentLength = int.MaxValue; NetPeerTcpBinding myBinding = new NetPeerTcpBinding(); myBinding.ReaderQuotas = quotas; myBinding.Resolver.Mode = System.ServiceModel.PeerResolvers.PeerResolverMode.Pnrp; if (parameters.UseTLS) { myBinding.Security.Mode = SecurityMode.Transport; myBinding.Security.Transport.CredentialType = PeerTransportCredentialType.Password; } else { myBinding.Security.Mode = SecurityMode.None; } // if the listening address is specified, use it if (parameters.Ip != null) { this.doInfo(this, new ScallopInfoEventArgs("Ignored listening address")); /* * this.doInfo(this, new ScallopInfoEventArgs("Listening on ip " + parameters.Ip.ToString())); * myBinding.ListenIPAddress = parameters.Ip; */ } EndpointAddress myAddress = new EndpointAddress("net.p2p://Scallop_" + this.Version + "_" + parameters.NetworkName + "/"); this.factory = new DuplexChannelFactory <IPeerChannelChannel>(new InstanceContext(this), myBinding, myAddress); this.factory.Faulted += this.factory_faulted; this.factory.Closed += this.factory_faulted; if (parameters.UseTLS) { this.factory.Credentials.Peer.MeshPassword = parameters.TLSPassword; } this.chan = factory.CreateChannel(); ScallopMessageFilter msgFilter = new ScallopMessageFilter(id); peer = chan.GetProperty <PeerNode>(); peer.Offline += new EventHandler(peer_Offline); peer.Online += new EventHandler(peer_Online); peer.MessagePropagationFilter = msgFilter; this.chan.Open(); this.chan.PCJoin(this.id); this.registered = true; this.id = id; //if(peer.IsOnline) // this.doStateChanged(this, new ScallopNetworkStatusChangedEventArgs(ScallopNetworkState.Online, null, "Online")); }