示例#1
0
        void OperationPacketReceived(object sender, uNet2.Packet.Events.OperationPacketEventArgs e)
        {
            if (e.Packet is SystemInformationPacket)
            {
                var packet = e.Packet as SystemInformationPacket;
                var peer   =
                    (e.Channel as TcpServerChannel).ConnectedPeers.FirstOrDefault(
                        p => p.Identity.Guid == e.Operation.ConnectionGuid);

                _connectionList = UiServiceProvider.GetService("ConnectionList") as ConnectionListService;
                var lvItm = new ConnectionListItem(peer, e.Channel as TcpServerChannel);
                lvItm.Text = peer.Endpoint.ToString();
                lvItm.SubItems.Add(packet.ComputerName);
                lvItm.SubItems.Add(packet.OperatingSystem);
                lvItm.SubItems.Add(packet.CountryCode);
                lvItm.SubItems.Add(packet.IsAdmin);
                lvItm.SubItems.Add(Math.Truncate(peer.PingDelay) + " ms");
                _connectionList.AddItem(lvItm);
            }
            e.Operation.CloseOperation();
        }
示例#2
0
 internal static void Raise(this OnOperationPacketReceived @event, object sender, OperationPacketEventArgs e)
 {
     if (@event != null)
     {
         @event(sender, e);
     }
 }