本文整理汇总了C#中ConnectionStatus类的典型用法代码示例。如果您正苦于以下问题:C# ConnectionStatus类的具体用法?C# ConnectionStatus怎么用?C# ConnectionStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionStatus类属于命名空间,在下文中一共展示了ConnectionStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetResult
public void SetResult(ConnectionStatus status)
{
if (!_enabled)
return;
this._result = status;
this._stopwatch.Stop();
}
示例2: ClientStream
/// <summary>
/// Public constructor for createing a Client object
/// </summary>
/// <param name="iSocket">Socket associated with the Client object</param>
/// <param name="iClientStreamIndex">Index number of the associated Client object</param>
public ClientStream(Socket iSocket, int iClientStreamIndex)
{
Socket = iSocket;
Index = iClientStreamIndex;
ConnectionStatus = ConnectionStatus.Pending;
OnClientConnect();
}
示例3: lokunclientform
public lokunclientform()
{
InitializeComponent();
lokun = Lokun.instance;
connected = ConnectionStatus.NotRunning;
chkAutostart.Checked = lokun.Autostart;
btnDownload.Enabled = false;
switch(lokun.UserRoutingSetting)
{
case RoutingSetting.Everything:
rdTunnelEverything.Checked = true;
break;
case RoutingSetting.ExcludeISNets:
rdExcludeIcelandic.Checked = true;
break;
case RoutingSetting.OnlyISNets:
rdOnlyIcelandic.Checked = true;
break;
}
StartStopSetUI(lokun.OpenVPNServiceIsRunning);
var username = lokun.GetCurrentUsername();
if (username != null)
{
txtUsername.Text = username;
txtPassword.Text = "hunter2";
//ststrpLabel.Text = "Current account: " + username;
}
}
示例4: NetworkConnection
/// <summary>
/// Initializes a new instance of the <see cref="ProScanMobile.NetworkConnection"/> class.
/// </summary>
/// <description>
/// Creates a new _tcpSocket and tries to connect to Host/Port
/// </description>
/// <param name="host">Host</param>
/// <param name="port">Port</param>
public NetworkConnection(string host, int port)
{
_connectDone.Reset ();
try
{
IPHostEntry ipHostInfo = Dns.GetHostEntry (host);
IPAddress ipAddress = ipHostInfo.AddressList [0];
IPEndPoint remoteEP = new IPEndPoint (ipAddress, port);
_tcpSocket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_tcpSocket.Blocking = true;
var result = _tcpSocket.BeginConnect (remoteEP, null, null);
bool success = result.AsyncWaitHandle.WaitOne (5000, true);
if (success) {
_tcpSocket.EndConnect (result);
_connectionStatus = ConnectionStatus.Connected;
_connectionStatusMessage = "Connected.";
} else {
_tcpSocket.Close ();
_connectionStatus = ConnectionStatus.Error;
_connectionStatusMessage = "Connection timed out.";
}
} catch {
_connectionStatus = ConnectionStatus.Error;
_connectionStatusMessage = string.Format("An error occured connecting to {0} on port {1}.", host, port);
_connectDone.Set();
return;
} finally {
_connectDone.Set ();
}
}
示例5: Update
public void Update()
{
if (_connectStarted.Elapsed.TotalSeconds > 120)
{
if (_bot != null)
_bot.Disconnect();
Status = ConnectionStatus.Disconnected;
}
if (Status != ConnectionStatus.Disconnected)
return;
_hasConnected = false;
_connectStarted.Restart();
Program.Logger.Info("Connecting");
_bot = new SteamBot(Program.Settings.Username, Program.Settings.Password, Program.Settings.AuthCode);
_bot.OnConnected += sender =>
{
_hasConnected = true;
_connectStarted.Stop();
_bot.DisplayName = Program.Settings.PersonaName;
_bot.PersonaState = EPersonaState.Online;
Status = ConnectionStatus.Connected;
Program.Logger.Info("Connected");
};
_bot.OnDisconnected += (sender, reason) =>
{
if (reason == SteamBotDisconnectReason.SteamGuard)
Thread.Sleep(TimeSpan.FromMinutes(2)); // TODO: need a better way of entering steamguard auth
if (_hasConnected)
{
Program.Logger.InfoFormat("Disconnected {0}", reason);
_hasConnected = false;
}
Status = ConnectionStatus.Disconnected;
};
_bot.OnFriendRequest += (sender, user) => _bot.AddFriend(user.Id);
_bot.OnPrivateEnter += (sender, chat) =>
{
chat.OnMessage += (chatSender, messageSender, message) =>
Command.Handle(new CommandTarget(chatSender, messageSender), message, "");
};
_bot.OnChatInvite += (sender, chat, @by) =>
{
if (chat.Id.IsIndividualAccount)
_bot.Join(chat.Id);
};
_bot.Connect();
Status = ConnectionStatus.Connecting;
}
示例6: btnCheckConnection_Click
private async void btnCheckConnection_Click(object sender, EventArgs e)
{
lblCheckConnection.Text = "Checking...";
lblCheckConnection.Refresh();
connected = await lokun.FullyCheckConnectionStatusAsync();
if (connected == ConnectionStatus.EverythingTunneled)
{
lblCheckConnection.Text = "Tunnel active";
}
else if (connected == ConnectionStatus.ConnectedWithoutDGW)
{
lblCheckConnection.Text = "Tunnel idle";
}
else if (connected == ConnectionStatus.RunningNotConnected)
{
lblCheckConnection.Text = "Tunnel not in use";
}
else if (connected == ConnectionStatus.OpenVPNNotInstalled)
{
lblCheckConnection.Text = "Error: OpenVPN missing";
}
else
{
lblCheckConnection.Text = "Tunnel down";
}
lblCheckConnection.Refresh();
}
示例7: Connect
public void Connect(HTransportOptions options)
{
this.connStatus = ConnectionStatus.CONNECTING;
this.options = options;
//TODO init the connection timeout value!!
connTimeout = new TimeSpan(0, 0, 0, 0, options.Timeout);
string endpointHost = options.EndpointHost;
int endpointPort = options.EndpointPort;
string endpointPath = options.EndpointPath;
string endpointAdress = ToEndpointAdress(endpointHost, endpointPort, endpointPath);
connTimeoutTimer = ThreadPoolTimer.CreateTimer(timeout_Elapsed, connTimeout);
socketIO = new Client(endpointAdress);
socketIO.Message += socketIO_Message;
socketIO.SocketConnectionClosed += socketIO_SocketConnectionClosed;
socketIO.Error += socketIO_Error;
socketIO.On("connect", (message) =>
{
if (this.options.AuthCb != null)
this.options.AuthCb(options.Login, Login);
else
Login(options.Login, options.Password);
});
socketIO.ConnectAsync();
}
示例8: OnConnectionStatus_callback
private void OnConnectionStatus_callback(object sender, ConnectionStatus status, ref RspUserLoginField userLogin, int size1)
{
if (null != OnConnectionStatus)
{
OnConnectionStatus(this, new OnConnectionStatusEventArgs(status, ref userLogin, size1));
}
}
示例9: DisplayStatus
public void DisplayStatus(ConnectionStatus status)
{
_notificator.Visibility = Visibility.Visible;
_notificator.Source = new BitmapImage(new Uri("ms-appx:///Assets/"+status+".png"));
_timer.Start();
}
示例10: NetworkStatus
public NetworkStatus(ConnectionStatus connectionStatus, ConnectionProtocolType protocolType, TCPRole tcpRole, int clientCount, string classroomName)
{
this.ConnectionStatus = connectionStatus;
this.ProtocolType = protocolType;
this.TCPRole = tcpRole;
this.ClientCount = clientCount;
this.ClassroomName = classroomName;
}
示例11: AbortedAuthentication
protected internal AuthenticationResult AbortedAuthentication(string message, ConnectionStatus status = ConnectionStatus.Faulted)
{
return new AuthenticationResult
{
Status = status,
Message = message,
};
}
示例12: ServerInfo
/// <summary>
/// Public constructor for createing a Server object
/// </summary>
/// <param name="iSocket">Socket associated with Server object</param>
/// <param name="iServerInfoIndex">Index number of the associated Server object</param>
public ServerInfo(Socket iSocket, int iServerInfoIndex, ConnectionInfo iConnectionInfo, ConnectionMode iConnectionMode)
{
Socket = iSocket;
Index = iServerInfoIndex;
ConnectionInfo = iConnectionInfo;
ConnectionMode = iConnectionMode;
ConnectionStatus = ConnectionStatus.Pending;
OnServerConnect();
}
示例13: Update
public void Update()
{
if (_connectStarted.Elapsed.TotalSeconds > 120)
{
if (_bot != null)
_bot.Disconnect();
Status = ConnectionStatus.Disconnected;
}
if (Status != ConnectionStatus.Disconnected)
return;
_hasConnected = false;
_connectStarted.Restart();
Program.Logger.Info("Connecting");
_bot = new Bot(Program.Settings.Username, Program.Settings.Password);
_bot.OnConnected += sender =>
{
_hasConnected = true;
_connectStarted.Stop();
_bot.PersonaName = Program.Settings.PersonaName;
_bot.PersonaState = EPersonaState.Online;
Status = ConnectionStatus.Connected;
Program.Logger.Info("Connected");
};
_bot.OnDisconnected += (sender, reason) =>
{
if (_hasConnected)
{
Program.Logger.Info("Disconnected");
_hasConnected = false;
}
Status = ConnectionStatus.Disconnected;
};
_bot.OnFriendRequest += (sender, user) => _bot.AddFriend(user.Id);
_bot.OnPrivateEnter += (sender, chat) =>
{
chat.OnMessage += (chatSender, messageSender, message) =>
Command.Handle(new CommandTarget(chatSender, messageSender.Id), message, "");
};
_bot.OnChatInvite += (sender, chat, @by) =>
{
if (chat.Id.IsIndividualAccount)
_bot.Join(chat.Id);
};
_bot.Connect();
Status = ConnectionStatus.Connecting;
}
示例14: OnConnect_3
//public fnOnRtnForQuoteRsp OnRtnForQuoteRsp
//{
// set
// {
// OnRtnForQuoteRsp_1 = value;
// OnRtnForQuoteRsp_2 = OnRtnForQuoteRsp_3;
// MdApi.CTP_RegOnRtnForQuoteRsp(_MsgQueue.Queue, OnRtnForQuoteRsp_2);
// }
//}
//private void OnRtnForQuoteRsp_3(IntPtr pMdUserApi, ref CThostFtdcForQuoteRspField pForQuoteRsp)
//{
// OnRtnForQuoteRsp_1(this, pMdUserApi, ref pForQuoteRsp);
//}
protected override void OnConnect_3(IntPtr pApi, ref CThostFtdcRspUserLoginField pRspUserLogin, ConnectionStatus result)
{
IsConnected = false;
if (result == ConnectionStatus.Logined)
{
IsConnected = true;
}
OnConnect_1(this, pApi, ref pRspUserLogin, result);
}
示例15: ClientStatusUpdate
public void ClientStatusUpdate(ConnectionStatus cs, string msg)
{
if (cs == ConnectionStatus.Connected)
{
RunOnUiThread(() => Toast.MakeText(this, "Connected to Server", ToastLength.Short).Show());
}
else
{
RunOnUiThread(() => Toast.MakeText(this, "Could not connect to server", ToastLength.Short).Show());
}
}