WebSocketMessageProperty.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // <copyright>
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. // </copyright>
  4. namespace System.ServiceModel.Channels
  5. {
  6. using System.Collections.ObjectModel;
  7. using System.Net.Http;
  8. using System.Net.WebSockets;
  9. public sealed class WebSocketMessageProperty
  10. {
  11. public const string Name = "WebSocketMessageProperty";
  12. WebSocketContext context;
  13. string subProtocol;
  14. WebSocketMessageType messageType;
  15. ReadOnlyDictionary<string, object> properties;
  16. public WebSocketMessageProperty()
  17. {
  18. this.messageType = WebSocketDefaults.DefaultWebSocketMessageType;
  19. }
  20. internal WebSocketMessageProperty(WebSocketContext context, string subProtocol, WebSocketMessageType incomingMessageType, ReadOnlyDictionary<string, object> properties)
  21. {
  22. this.context = context;
  23. this.subProtocol = subProtocol;
  24. this.messageType = incomingMessageType;
  25. this.properties = properties;
  26. }
  27. public WebSocketContext WebSocketContext
  28. {
  29. get { return this.context; }
  30. }
  31. public string SubProtocol
  32. {
  33. get { return this.subProtocol; }
  34. }
  35. public WebSocketMessageType MessageType
  36. {
  37. get { return this.messageType; }
  38. set { this.messageType = value; }
  39. }
  40. public ReadOnlyDictionary<string, object> OpeningHandshakeProperties
  41. {
  42. get
  43. {
  44. if (this.properties == null)
  45. {
  46. throw FxTrace.Exception.AsError(new InvalidOperationException(SR.GetString(
  47. SR.WebSocketOpeningHandshakePropertiesNotAvailable,
  48. "RequestMessage",
  49. typeof(HttpResponseMessage).Name,
  50. typeof(DelegatingHandler).Name)));
  51. }
  52. return this.properties;
  53. }
  54. }
  55. }
  56. }