コード例 #1
0
        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
            });
        }
コード例 #3
0
ファイル: Server Form.cs プロジェクト: NickJorens/.NET-Server
 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()));
     }
 }
コード例 #4
0
        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
            });
        }
コード例 #5
0
        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;
            }
            }
        }
コード例 #6
0
ファイル: Server Form.cs プロジェクト: NickJorens/.NET-Server
        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);
            }
        }
コード例 #7
0
ファイル: Server Form.cs プロジェクト: NickJorens/.NET-Server
        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;
                }
            }
        }
コード例 #8
0
        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;
            }
            }
        }
コード例 #9
0
ファイル: ClientEventArgs.cs プロジェクト: yougayuki/NetDist
 public ClientEventArgs(ClientEventType eventType, Guid clientId)
 {
     EventType = eventType;
     ClientId  = clientId;
 }
コード例 #10
0
ファイル: Protocol.cs プロジェクト: EBassie/Potato
 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()
         });
     }
 }
コード例 #11
0
 public ClientEvent(ITcpSocket socket, ClientEventType clientEventType, byte[] data = null)
 {
     Socket          = socket;
     ClientEventType = clientEventType;
     Data            = data;
 }
コード例 #12
0
 //病人状态,可为null
 //private PatientStatus _patientstatus;
 public ClientEventArg(string ClientID, ClientEventType eventType)
 {
     _clientID  = ClientID;
     _eventType = eventType;
 }
コード例 #13
0
ファイル: NetCore.cs プロジェクト: riskawarrior/linefight
 /// <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;
 }
コード例 #14
0
 public ClientEvent(ClientIdentifier identifier, ClientEventType type)
 {
     _identifier = identifier;
     _type       = type;
 }