void Packet_PacketRecieved(object sender, Packet.PacketEventArgs e)
 {
     var packet = e.Packet;
     if (packet is Packets.PacketLockDesktop)
     {
         RunCommand("rundll32.exe user32.dll, LockWorkStation");
     }
     else if (packet is Packets.PacketSleep)
     {
         RunCommand("rundll32.exe powrprof.dll,SetSuspendState 0,1,0");
     }
     else if (packet is Packets.PacketHibernate)
     {
         RunCommand("rundll32.exe PowrProf.dll,SetSuspendState");
     }
     else if (packet is Packets.PacketShutdown)
     {
         RunCommand("Shutdown.exe -s -t 00");
     }
     else if (packet is Packets.PacketRestart)
     {
         RunCommand("Shutdown.exe -r -t 00");
     }
     else if (packet is Packets.PacketMessageBox)
     {
         var messagePacket = packet as Packets.PacketMessageBox;
         RunCommand("Msg * \"" + messagePacket.Message + "\"");
     }
 }
Exemplo n.º 2
0
        static void Packet_PacketRecieved(object sender, Packet.PacketEventArgs e)
        {
            if (e.Packet is PacketMessage)
            {
                var msg = (PacketMessage) e.Packet;

                Logger.Log("(Client) " + msg.Message);
            }
            else if (e.Packet is PacketCommand)
            {
                var cmd = (PacketCommand) e.Packet;

                Logger.Log("Running command (" + cmd.Command + ")");

                try
                {
                    var objThread = new Thread(RunCommand) { IsBackground = true, Priority = ThreadPriority.AboveNormal };
                    objThread.Start(cmd.Command);
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex);
                }
            }
            else if (e.Packet is PacketBeep)
            {
                Console.Beep(new Random().Next(2000, 3000), 500);
            }
        }
        void PacketRecieved( object sender, Packet.PacketEventArgs args )
        {
            if ( args.Packet is PacketControl ) {
                PacketControl ctrl = args.Packet as PacketControl;

                if ( mPlayer != null ) {
                    mPlayer.Dispatcher.BeginInvoke ( new Action ( () => {
                        switch ( ctrl.Control ) {
                            case ControlType.Play:
                                mPlayer.Source = new Uri ( ctrl.ValueString );
                                mPlayer.Play ();
                                break;
                            case ControlType.Pause:
                                if ( mPlayer.HasVideo && mPlayer.CanPause ) {
                                    mPlayer.Pause ();
                                }
                                break;
                            case ControlType.FullScreen:

                                if ( _defaultContent == null ) {
                                    _defaultContent = Content;
                                }

                                if ( mPlayer.Equals(Content) ) {
                                    this.Background = Brushes.Transparent;
                                    this.Content = _defaultContent;
                                } else {
                                    this.Background = Brushes.Black;
                                    this.Content = mPlayer;
                                }
                                break;
                        }
                    } ) );
                }
            } else if ( args.Packet is PacketVideo ) {
                PacketVideo pack = args.Packet as PacketVideo;
                Logger.Log ( "Recieved video request" );
                if ( pack.VideoID == -1 ) {

                    var ar = new VideoDiscoverer ( DiscoverType.Downloads );
                    new Thread ( ar.Discover ).Start ();
                    ar.VideoDiscovered += AddVideos;

                    lstVideos.Dispatcher.Invoke ( new Action ( () => lstVideos.Items.Clear () ) );
                }
            }
        }
 /// <summary>
 /// Enqueues the packet.
 /// </summary>
 /// <param name="packet">The packet.</param>
 /// <returns>The packet's place in the write queue.</returns>
 public int EnqueuePacket(Packet packet)
 {
     if (packet == null) throw new NullReferenceException("Packet must be initialized and filled");
     PacketQueue.Enqueue(packet);
     return PacketQueue.Count;
 }
 protected virtual void SendPacket(Packet packet)
 {
     _client.WriteByte(packet.PacketId);
     packet.WritePacket(_client);
 }
 /// <summary>
 /// Writes the packet now, instead of inserting it in the queue.
 /// </summary>
 /// <param name="packet">The packet to write.</param>
 public void WritePacketNow(Packet packet)
 {
     SendPacket(packet);
     Packet.OnPacketSent(_client, packet);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Registers the packet.
 /// </summary>
 /// <param name="packet">The packet.</param>
 public static void RegisterPacket(Packet packet)
 {
     RegisterPacket(packet.GetType(), packet.PacketId);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PacketEventArgs"/> class.
 /// </summary>
 /// <param name="client">The client</param>
 /// <param name="packet">The packet.</param>
 public PacketEventArgs(RemoteClient client, Packet packet)
 {
     RemoteClient = client;
     Packet = packet;
 }
Exemplo n.º 9
0
 internal static void OnPacketSent(RemoteClient c, Packet p)
 {
     if (PacketSent != null)
     {
         PacketSent(null, new PacketEventArgs(c, p));
     }
 }
Exemplo n.º 10
0
 internal static void OnPacketRecieved(RemoteClient c, Packet p)
 {
     if (PacketRecieved != null)
     {
         PacketRecieved(null, new PacketEventArgs(c, p));
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// Unregisters the packet.
 /// </summary>
 /// <param name="packet">The packet.</param>
 public static void UnregisterPacket(Packet packet)
 {
     UnregisterPacket(packet.GetType());
 }