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


C# SslStream.Flush方法代码示例

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


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

示例1: PerformTls

    private void PerformTls()
    {
        // Create an SSL stream that will close the client's stream.
        SecureStream = new SslStream(
            Stream,
            true,
            new RemoteCertificateValidationCallback(ValidateServerCertificate));
        // The server name must match the name on the server certificate.
        try
        {
            SecureStream.AuthenticateAsClient(ServerName);
        }
        catch (AuthenticationException e)
        {
            Debug.LogError("Exception: " + e.Message);
            if (e.InnerException != null)
            {
                Debug.LogError("Inner exception: " + e.InnerException.Message);
            }
            // Console.WriteLine("Authentication failed - closing the connection.");
            Client.Close();
            return;
        }
        // Authenticated!
        string request = @"<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' to='xmpp.livecoding.tv' version='1.0'>";
        Debug.Log("Asking to open a new XMPP stream on authenticated SecureStream! " + request);
        byte[] message = Encoding.UTF8.GetBytes(request);
        // byte[] message = Convert.FromBase64String(@"<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' to='xmpp.livecoding.tv' version='1.0'>");

        // Set up new readers and writers.
        SecureStream.Write(message);
        SecureStream.Flush();
    }
开发者ID:GarthSmith,项目名称:10kBot,代码行数:33,代码来源:Livecoding.cs

示例2: WriteJSONMessage

 static void WriteJSONMessage(SslStream sslStream, JSONEvent eventObj)
 {
     string message = JsonConvert.SerializeObject(eventObj);
     //Console.WriteLine(message);
     byte[] msg = Encoding.UTF8.GetBytes(message);
     sslStream.Write(msg);
     sslStream.Flush();
 }
开发者ID:Tsarpf,项目名称:Mobile-MMO,代码行数:8,代码来源:SynchronousNetworkLoop.cs

示例3: SslStream_StreamToStream_Flush_Propagated

        public void SslStream_StreamToStream_Flush_Propagated()
        {
            VirtualNetwork network = new VirtualNetwork();

            using (var stream = new VirtualNetworkStream(network, isServer: false))
            using (var sslStream = new SslStream(stream, false, AllowAnyServerCertificate))
            {
                Assert.False(stream.HasBeenSyncFlushed);
                sslStream.Flush();
                Assert.True(stream.HasBeenSyncFlushed);
            }
        }
开发者ID:chcosta,项目名称:corefx,代码行数:12,代码来源:SslStreamStreamToStreamTest.cs


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