public PacketWriter(RemoteClient client)
        {
            PacketQueue = new Queue<Packet>();

            _client = client;
            CanWrite = true;
        }
        void Client_ClientLeft(object sender, ClientConnectionEventArgs e)
        {
            if ( e.RemoteClient == _client ) {
                _client = null;
            }

            Logger.Log ( "Client disconnected" );
        }
 void Client_ClientJoined(object sender, ClientConnectionEventArgs e)
 {
     if ( _client == null ) {
         _client = e.RemoteClient;
     } else {
         e.RemoteClient.Disconnect();
         return;
     }
     //TODO: fix
     //Logger.Log("Client connected (" + ((IPEndPoint)e.TcpRemoteClient.TcpClient.Client.RemoteEndPoint).Address + ")");
 }
        public override void ReadPacket(RemoteClient c)
        {
            Control = (ControlType)c.ReadShort();
            Value = -1;
            switch (Control)
            {
                case ControlType.Play:
                    ValueString = c.ReadString();
                    break;
                case ControlType.Rewind:
                case ControlType.Forward:
                    Value = c.ReadInt();
                    break;

            }
        }
 public override void WritePacket(RemoteClient c)
 {
     c.WriteString(Message);
 }
 public override void ReadPacket(RemoteClient c)
 {
     Message = c.ReadString();
 }
 public override void WritePacket(RemoteClient c)
 {
 }
 public override void ReadPacket(RemoteClient c)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PacketReader"/> class.
 /// </summary>
 /// <param name="client">The socket.</param>
 public PacketReader(RemoteClient client)
 {
     CanRead = true;
     _client = client;
 }
示例#10
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;
 }
示例#11
0
 internal static void OnPacketSent(RemoteClient c, Packet p)
 {
     if (PacketSent != null)
     {
         PacketSent(null, new PacketEventArgs(c, p));
     }
 }
示例#12
0
 internal static void OnPacketRecieved(RemoteClient c, Packet p)
 {
     if (PacketRecieved != null)
     {
         PacketRecieved(null, new PacketEventArgs(c, p));
     }
 }
示例#13
0
 /// <summary>
 /// Writes the packet to the client stream.
 /// </summary>
 /// <remarks>This is where you would actually write data to the stream</remarks>
 public abstract void WritePacket(RemoteClient c);
示例#14
0
 /// <summary>
 /// Reads the packet. The "Data" property MUST be set or problems will occur.
 /// </summary>
 /// <param name="c">The client stream to read from.</param>
 public abstract void ReadPacket(RemoteClient c);
 /// <summary>
 /// Initializes a new instance of the <see cref="ClientConnectionEventArgs"/> class.
 /// </summary>
 /// <param name="client">The client.</param>
 public ClientConnectionEventArgs(RemoteClient client)
 {
     RemoteClient = client;
 }
 public override void WritePacket(RemoteClient c)
 {
     throw new IOException("Is a read-only packet"); //For now
 }