当前位置: 首页>>代码示例>>C#>>正文


C# Connection.LoadIDL方法代码示例

本文整理汇总了C#中System.Net.Connection.LoadIDL方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.LoadIDL方法的具体用法?C# Connection.LoadIDL怎么用?C# Connection.LoadIDL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Connection的用法示例。


在下文中一共展示了Connection.LoadIDL方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OpenConnection

        /// <summary>
        /// Opens a connection to a server specified in the config file retrived from <paramref name="configURI"/>.
        /// Fragment part of the <paramref name="configURI"/> may be used to select the server by its index, e.g.
        /// <c>"http://www.example.org/config.json#3"</c>. If no fragment is provided, or index is invalid, first server
        /// with supported protocol is chosen. Upon connection <paramref name="onConnected"/> is called with the
        /// constructed Connection object.
        /// </summary>
        /// <param name="configURI">
        /// URI where config is to be found. Data URIs starting with <c>"data:text/json;base64,"</c> are supported.
        /// </param>
        /// <param name="onConnected">Handler to be invoked when connection is established.</param>
        public void OpenConnection(string configURI, Action<Connection> onConnected)
        {
            string fragment = "";
            Config ServerConfiguration = RetrieveConfig(configURI, out fragment);
            ServiceDescription server = SelectServer(fragment, ServerConfiguration);

            string protocolName = server.protocol.name;
            string transportName = server.transport.name;
            string transportUrl = server.transport.url;
            string host;
            int port;
            GetHostAndPortFromUrl(transportUrl, out host, out port);
            ITransportConnectionFactory transportConnectionFactory = TransportRegistry.Instance
                .GetTransport(transportName)
                .TransportConnectionFactory;
            IProtocol protocol = protocolRegistry.GetProtocol(protocolName);
            ITransportConnection transportConnection = transportConnectionFactory.OpenConnection(host, port, this, onConnected);
            transportConnection.Opened += (sender, e) =>
            {
                Connection establishedConnection = new Connection(transportConnection, protocol);
                establishedConnection.LoadIDL(ServerConfiguration);
                onConnected(establishedConnection);
            };
        }
开发者ID:tospie,项目名称:SINFONI,代码行数:35,代码来源:Context.cs

示例2: StartServer

        /// <summary>
        /// Creates a server specified in the config file retrieved from <paramref name="configURI"/>. Fragment part of
        /// the <paramref name="configURI"/> may be used to select the server by its index, e.g.
        /// <c>"http://www.example.org/config.json#3"</c>. If no fragment is provided, or index is invalid, first server
        /// with supported protocol is chosen. For each connected client <paramref name="onNewClient"/> is called with
        /// constructed Connection object.
        /// </summary>
        /// <remarks>
        /// Note that <paramref name="onNewClient"/> may be executed on a different thread than the one you are calling
        /// from, depending on the implementation of the protocol specified in the config file.
        /// </remarks>
        public ServiceDescription StartServer(string uri, int port, string transportName, string protocolName,
            Config ServerConfig, Action<Connection> onNewClient)
        {
            IProtocol protocol = protocolRegistry.GetProtocol(protocolName);
            ITransportConnectionFactory transportConnectionFactory = TransportRegistry.Instance
                .GetTransport(transportName)
                .TransportConnectionFactory;
            ITransportListener transportListener = transportConnectionFactory.StartConnectionListener(uri, port);
            transportListener.NewClientConnected += (object sender, NewConnectionEventArgs e) =>
            {
                Connection newConnection = new Connection(e.Connection, protocol);
                newConnection.LoadIDL(ServerConfig);
                onNewClient(newConnection);
            };

            var server = new ServiceDescription();
            server.protocol = new ProtocolConfig
            {
                name = protocolName
            };
            server.transport = new TransportConfig
            {
                name = transportName,
                url = transportName + "://" + uri  + ":" +port
            };
            server.implementedServices = "*";
            return server;
        }
开发者ID:tospie,项目名称:SINFONI,代码行数:39,代码来源:Context.cs


注:本文中的System.Net.Connection.LoadIDL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。