Exemple #1
0
        /// <summary>
        /// Writes the message using the given writer.
        /// </summary>
        /// <param name="writer"></param>
        internal void Write(RnetStreamWriter writer)
        {
            Contract.Requires<ArgumentNullException>(writer != null);

            writer.BeginMessage(TargetDeviceId, SourceDeviceId, MessageType);
            WriteBody(writer);
            writer.EndMessage();
        }
Exemple #2
0
 internal protected override void WriteBody(RnetStreamWriter writer)
 {
     TargetPath.Write(writer);
     SourcePath.Write(writer);
     writer.WriteUInt16((ushort)Event);
     writer.WriteUInt16(Timestamp);
     writer.WriteUInt16(Data);
     writer.WriteByte((byte)Priority);
 }
Exemple #3
0
 internal protected override void WriteBody(RnetStreamWriter writer)
 {
     TargetPath.Write(writer);
     SourcePath.Write(writer);
     writer.WriteUInt16(PacketNumber);
     writer.WriteUInt16(PacketCount);
     writer.WriteUInt16((ushort)Data.Length);
     for (int i = 0; i < Data.Length; i++)
         writer.WriteByte(Data[i]);
 }
Exemple #4
0
        /// <summary>
        /// Opens the connection.
        /// </summary>
        public async Task Open(CancellationToken cancellationToken)
        {
            if (State != RnetConnectionState.Closed)
                throw new RnetConnectionException("Connection is not closed.");

            // establish connection
            await Connect(cancellationToken);

            // obtain reader
            reader = GetReader();
            if (reader == null)
                throw new RnetException("Unable to obtain RnetReader.");

            // obtain writer
            writer = GetWriter();
            if (writer == null)
                throw new RnetException("Unable to obtain RnetWriter.");

            OnStateChanged(new RnetConnectionStateEventArgs(State));
        }
Exemple #5
0
 internal protected override void WriteBody(RnetStreamWriter writer)
 {
     writer.WriteByte((byte)HandshakeType);
 }
Exemple #6
0
 /// <summary>
 /// Writes the body of the message.
 /// </summary>
 /// <param name="writer"></param>
 internal protected abstract void WriteBody(RnetStreamWriter writer);
 internal protected override void WriteBody(RnetStreamWriter writer)
 {
     TargetPath.Write(writer);
     SourcePath.Write(writer);
     writer.WriteByte((byte)Type);
 }
Exemple #8
0
 internal protected override void WriteBody(RnetStreamWriter writer)
 {
     throw new NotImplementedException();
 }
Exemple #9
0
        /// <summary>
        /// Closes the connection.
        /// </summary>
        public async Task Close(CancellationToken cancellationToken)
        {
            Contract.Requires<RnetConnectionException>(State == RnetConnectionState.Open, "Connection is not open.");
            Contract.Ensures(reader == null);
            Contract.Ensures(writer == null);

            // disconnect
            await Disconnect(cancellationToken);
            reader = null;
            writer = null;

            OnStateChanged(new RnetConnectionStateEventArgs(State));
        }