/// <summary> /// Creates the SIF_Protocol object that will be included with a SIF_Register /// message sent to the zone associated with this Transport.</Summary> /// <remarks> /// The base class implementation creates an empty SIF_Protocol with zero /// or more SIF_Property elements according to the parameters that have been /// defined by the client via setParameter. Derived classes should therefore /// call the superclass implementation first, then add to the resulting /// SIF_Protocol element as needed. /// </remarks> /// <param name="zone"></param> /// <returns></returns> public override SIF_Protocol MakeSIF_Protocol(IZone zone) { SIF_Protocol proto = new SIF_Protocol(); fTransport.ConfigureSIF_Protocol(proto, zone); return(proto); }
public void ConfigureSIF_Protocol(SIF_Protocol proto, IZone zone) { proto.Type = Protocol.ToUpperInvariant(); proto.SetSecure(Secure ? YesNo.YES : YesNo.NO); String host = getPushHostName(); int port = ((HttpProperties)fProps).PushPort; if (port == -1) { port = this.Port; } UriBuilder builder = new UriBuilder(); builder.Scheme = this.Protocol; builder.Host = host.Trim(); builder.Port = port; builder.Path = "/zone/" + zone.ZoneId + "/"; proto.SIF_URL = builder.Uri.AbsoluteUri; }
/** * SIF_Register */ public SIF_Ack SifRegister(IZone zone) { ZoneImpl AdkZone = (ZoneImpl)zone; AgentProperties props = zone.Properties; SifVersion effectiveZISVersion = AdkZone.HighestEffectiveZISVersion; SIF_Register msg = new SIF_Register(effectiveZISVersion); msg.SIF_MaxBufferSize = props.MaxBufferSize; msg.SIF_Mode = props.MessagingMode == AgentMessagingMode.Pull ? "Pull" : "Push"; // Set the agent's name and version Agent agent = zone.Agent; msg.SIF_Name = agent.Name; String vendor = props.AgentVendor; if (vendor != null) { msg.SIF_NodeVendor = vendor; } String version = props.AgentVersion; if (version != null) { msg.SIF_NodeVersion = version; } SIF_Application applicationInfo = new SIF_Application(); String appName = props.ApplicationName; if (appName != null) { applicationInfo.SIF_Product = appName; } String appVersion = props.ApplicationVersion; if (appVersion != null) { applicationInfo.SIF_Version = appVersion; } String appVendor = props.ApplicationVendor; if (appVendor != null) { applicationInfo.SIF_Vendor = appVendor; } if (applicationInfo.FieldCount > 0) { // All three fields under SIF_Application are required by the // SIF_Specification. Determine if any are missing. If so, // create the field with an empty value if (applicationInfo.SIF_Product == null) { applicationInfo.SIF_Product = string.Empty; } if (applicationInfo.SIF_Version == null) { applicationInfo.SIF_Version = string.Empty; } if (applicationInfo.SIF_Vendor == null) { applicationInfo.SIF_Vendor = string.Empty; } msg.SIF_Application = applicationInfo; } String propVal = props.AgentIconUrl; if (propVal != null) { msg.SIF_Icon = propVal; } // // SIF_Version handling: // // * If the "Adk.provisioning.zisVersion" property is set to > SIF 1.1 // (the default), use SIF 1.1+ registration where multiple SIF_Version // elements are included in the SIF_Register message. Otherwise use // SIF 1.0 registration where only a single SIF_Version is included in // the SIF_Register message. // // For SIF 1.1 registrations: // // * If the "Adk.sifRegister.sifVersions" System property is set, // enumerate its comma-delimited list of SIF_Version values and use // those instead of building a list. This is primarily used for // testing wildcards (which the Adk doesn't normally use) or when an // agent wants to connect to a ZIS where wildcarding works better for // some reason. // // * Otherwise, build a list of SIF_Versions: Set the first SIF_Version // element to the version initialized by the Adk, then add a SIF_Version // element for each additional version of SIF supported by the Adk // String forced = zone.Properties.OverrideSifVersions; if (forced != null) { ((ZoneImpl)zone).Log.Debug("Using custom SIF_Register/SIF_Version: " + forced); foreach (String token in forced.Split(',')) { msg.AddSIF_Version(new SIF_Version(token.Trim())); } } else { SifVersion zisVer = SifVersion.Parse(zone.Properties.ZisVersion); if (zisVer.CompareTo(SifVersion.SIF11) >= 0) { // Add the Adk version first. This is the "default" // agent version, which has special meaning to the // ZIS msg.AddSIF_Version(new SIF_Version(effectiveZISVersion)); // TT 2007 // If the Adk Version is set to 1.1 or 1.5r1, only send those two // versions in the SIF_Register message. The downside to this is // that we can't connect to a 2.0 ZIS using SIF 1.5r1 and still // receive 2.0 events. However, this seems to be the best approach // because it ensures greater compatibility with older ZIS's that will // otherwise fail if they get a 2.0 version in the SIF_Register message SifVersion[] supported = Adk.SupportedSIFVersions; for (int i = 0; i < supported.Length; i++) { // Exclude the version added above if (supported[i].CompareTo(effectiveZISVersion) < 0) { msg.AddSIF_Version(new SIF_Version(supported[i])); } } } else { msg.AddSIF_Version(new SIF_Version(Adk.SifVersion)); } } // // Set the SIF_Protocol object as supplied by the Transport. Depending // on the transport protocol and the messaging mode employed by the // zone we may or may not get a SIF_Protocol object back // SIF_Protocol po = ((ZoneImpl)zone).ProtocolHandler.MakeSIF_Protocol(zone); if (po != null) { msg.SIF_Protocol = po; } return(AdkZone.Dispatcher.send(msg)); }