private readonly HeartBeatManager _hbManager = new HeartBeatManager(); //心跳管理对象 /// <summary> /// 定阅事件 /// </summary> /// <param name="type">事件类型</param> /// <param name="handler">事件处理方法</param> public void AddClientEventHandler(ClientEventType type, EventHandler <ClientEventArg> handler) { switch (type) { case ClientEventType.MissHeartBeat: { _hbManager.AddMissingHBHandler(handler); break; } //case ClientEventType.HeartBeat: // { // _hbManager.AddHBHandler(handler); // break; // } case ClientEventType.Disconnect: { _hbManager.AddDisconnectHandler(handler); break; } case ClientEventType.None: break; case ClientEventType.HeartBeat: break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } }
void INetEventListener.OnPeerDisconnected(NetPeer peer, DisconnectInfo disconnectInfo) { ClientEventType disconnectType = disconnectInfo.Reason == DisconnectReason.DisconnectPeerCalled ? ClientEventType.ConnectionClosed : ClientEventType.ConnectionLost; this.clientEvents.Enqueue(new ClientEvent { EventType = disconnectType }); }
void _server_ClientDisconnected(Client client, ClientEventType type) { if (InvokeRequired) { Invoke(new ClientDelegate(_server_ClientDisconnected), new object[] { client, type }); } else { lvConnections.Items.Remove(lvConnections.FindItemWithText(client.Guid.ToString())); } }
void INetEventListener.OnPeerDisconnected(NetPeer peer, DisconnectInfo disconnectInfo) { UnityEngine.Debug.Log("ClientTransport: OnPeerDisconnected - " + disconnectInfo.Reason); ClientEventType disconnectType = disconnectInfo.Reason == DisconnectReason.DisconnectPeerCalled ? ClientEventType.ConnectionClosed : ClientEventType.ConnectionLost; this.clientEvents.Enqueue(new ClientEvent { EventType = disconnectType }); }
private HeartBeatManager _hbManager = new HeartBeatManager(); //心跳管理对象 /// <summary> /// 定阅事件 /// </summary> /// <param name="type">事件类型</param> /// <param name="handler">事件处理方法</param> public void AddClientEventHandler(ClientEventType type, EventHandler <ClientEventArg> handler) { switch (type) { case ClientEventType.MissHeartBeat: { _hbManager.AddMissingHBHandler(handler); break; } case ClientEventType.HeartBeat: { _hbManager.AddHBHandler(handler); break; } } }
void _server_ClientConnected(Client client, ClientEventType type) { if (InvokeRequired) { Invoke(new ClientDelegate(_server_ClientConnected), new object[] { client, type }); } else { var liv = new ListViewItem(client.Guid.ToString()) { Name = client.Guid.ToString() }; liv.SubItems.AddRange(new[] { client.ConnectionDateTime.ToString(CultureInfo.InvariantCulture), client.LastPacketReceived.ToString(CultureInfo.InvariantCulture), "" }); lvConnections.Items.Add(liv); } }
void _server_ClientUpdated(Client client, ClientEventType type) { if (InvokeRequired) { Invoke(new ClientDelegate(_server_ClientUpdated), new object[] { client, type }); } else { switch (type) { case ClientEventType.UpdatedCountry: lvConnections.Items[client.Guid.ToString()].SubItems[lvConnections.Columns.IndexOf(chCountry)].Text = client.Country; break; } } }
private HeartBeatManager _hbManager = new HeartBeatManager(); //心跳管理对象 /// <summary> /// 定阅事件 /// </summary> /// <param name="type">事件类型</param> /// <param name="handler">事件处理方法</param> public void AddClientEventHandler(ClientEventType type, EventHandler <ClientEventArg> handler) { switch (type) { case ClientEventType.MissHeartBeat: { _hbManager.AddMissingHBHandler(handler); break; } //case ClientEventType.HeartBeat: // { // _hbManager.AddHBHandler(handler); // break; // } case ClientEventType.Disconnect: { _hbManager.AddDisconnectHandler(handler); break; } } }
public ClientEventArgs(ClientEventType eventType, Guid clientId) { EventType = eventType; ClientId = clientId; }
protected void OnClientEvent(ClientEventType eventType, IClientEventData now = null, IClientEventData then = null) { var handler = this.ClientEvent; if (handler != null) { handler(this, new ClientEventArgs() { EventType = eventType, ConnectionState = this.Client.ConnectionState, Now = now ?? new ClientEventData(), Then = then ?? new ClientEventData() }); } }
public ClientEvent(ITcpSocket socket, ClientEventType clientEventType, byte[] data = null) { Socket = socket; ClientEventType = clientEventType; Data = data; }
//病人状态,可为null //private PatientStatus _patientstatus; public ClientEventArg(string ClientID, ClientEventType eventType) { _clientID = ClientID; _eventType = eventType; }
/// <summary> /// Konstruktor /// Eltárolja a kliens eseményt és a felhasználónevet, akihez az esemény tartozik /// </summary> /// <param name="ev">Kliens esemény</param> /// <param name="username">Felhasználónév</param> public NetClientEvent(ClientEventType ev, string username) { this.ev = ev; this.username = username; }
public ClientEvent(ClientIdentifier identifier, ClientEventType type) { _identifier = identifier; _type = type; }