/// <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(); }
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); }
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]); }
/// <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)); }
internal protected override void WriteBody(RnetStreamWriter writer) { writer.WriteByte((byte)HandshakeType); }
/// <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); }
internal protected override void WriteBody(RnetStreamWriter writer) { throw new NotImplementedException(); }
/// <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)); }