using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using WindowsPhone.Recipes.Push.Messasges.Properties;
namespace WindowsPhone.Recipes.Push.Messasges
{
///
/// Represents a raw push notification message.
///
///
/// If you do not wish to update the tile or send a toast notification, you can instead
/// send raw information to your application using a raw notification. If your application
/// is not currently running, the raw notification is discarded on the Microsoft Push
/// Notification Service and is not delivered to the device.
///
/// This class members are thread safe.
///
public sealed class RawPushNotificationMessage : PushNotificationMessage
{
#region Constants
/// Calculated raw message headers size.
/// This should ne updated if changing the protocol.
private const int RawMessageHeadersSize = 116;
/// Raw push notification message maximum payload size.
public const int MaxPayloadSize = MaxMessageSize - RawMessageHeadersSize;
#endregion
#region Properties
///
/// Gets or sets the message raw data bytes.
///
public byte[] RawData
{
get
{
return Payload;
}
set
{
Payload = value;
}
}
///
/// Raw push notification message class id.
///
protected override int NotificationClassId
{
get { return 3; }
}
#endregion
#region Ctor
///
/// Initializes a new instance of this type.
///
/// The send priority of this message in the MPNS.
public RawPushNotificationMessage(MessageSendPriority sendPriority = MessageSendPriority.Normal)
: base(sendPriority)
{
}
#endregion
#region Overrides
protected override void VerifyPayloadSize(byte[] payload)
{
if (payload.Length > MaxPayloadSize)
{
throw new ArgumentOutOfRangeException(string.Format(Resources.PayloadSizeIsTooBig, MaxPayloadSize));
}
}
#endregion
}
}