本文整理汇总了C#中System.Net.Security.SslStream.IsNull方法的典型用法代码示例。如果您正苦于以下问题:C# SslStream.IsNull方法的具体用法?C# SslStream.IsNull怎么用?C# SslStream.IsNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Security.SslStream
的用法示例。
在下文中一共展示了SslStream.IsNull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Connection
private void Connection(bool nick = false)
{
try
{
NetworkQuit = false;
_cts = new CancellationTokenSource();
if(nick)
{
sMyNickInfo.ChangeNick(IRCConfig.List[_servername].NickName);
if(Rfc2812Util.IsServInLower(sMyNickInfo.NickStorage)) // NickName
{
sMyNickInfo.ChangeNick(); // NickName -> NickName2
if(Rfc2812Util.IsServInLower(sMyNickInfo.NickStorage)) // NickName2
{
sMyNickInfo.ChangeNick(); // NickName2 -> NickName3
if(Rfc2812Util.IsServInLower(sMyNickInfo.NickStorage)) // NickName3
sMyNickInfo.ChangeNick(); // NickName3 -> Other
}
Log.Warning("Network", sLConsole.GetString("This nick name ({0}) is used by a service bot. Your nick is automaticly changed to a placeholder one."), sMyNickInfo.NickStorage);
}
}
Log.Notice("Network", sLConsole.GetString("Connection type: {0}"), CType.ToString());
try
{
client = new TcpClient();
client.Connect(_server, _port);
}
catch(Exception)
{
Log.Error("Network", sLConsole.GetString("Fatal error was happened while established the connection!"));
return;
}
if(!client.IsNull() && client.Connected)
Log.Success("Network", sLConsole.GetString("Successfully established the connection!"));
else
{
Log.Error("Network", sLConsole.GetString("Error was happened while established the connection!"));
return;
}
if(CType == ConnectionType.Ssl)
{
SslStream networkStream = null;
try
{
networkStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback((s,ce,ca,p) => true), null);
networkStream.AuthenticateAsClient(_server);
}
catch(AuthenticationException e)
{
Log.Error("Network", sLConsole.GetString("Certificate not accepted, exception: {0}"), e.Message);
return;
}
catch(Exception e)
{
Log.Error("Network", sLConsole.GetString("Failure details: {0}"), e.Message);
return;
}
if(networkStream.IsNull())
return;
InitializeStream(networkStream);
}
else
InitializeStream(client.GetStream());
if(reader.IsNull() || INetwork.WriterList[_servername].IsNull())
return;
Connected = true;
sSender.RegisterConnection(IRCConfig.List[_servername].Password, sMyNickInfo.NickStorage, IRCConfig.List[_servername].UserName, IRCConfig.List[_servername].UserInfo);
Log.Notice("Network", sLConsole.GetString("Users' datas are sent."));
Online = false;
IsAllJoin = false;
_enabled = true;
KickPrivmsg = string.Empty;
ModePrivmsg = string.Empty;
ChannelPrivmsg = string.Empty;
NewNickPrivmsg = string.Empty;
UrlTitleEnabled = false;
sMyNickInfo.ChangeIdentifyStatus(false);
sMyNickInfo.ChangeVhostStatus(false);
}
catch(Exception e)
{
Online = false;
Connected = false;
Log.Error("Network", sLConsole.GetString("Failure details: {0}"), e.Message);
}
//.........这里部分代码省略.........