private static WebSocketMessageType GetWebSocketMessageType(Message message)
        {
            WebSocketMessageType outgoingMessageType = WebSocketDefaults.DefaultWebSocketMessageType;

            if (WebSocketMessageProperty.TryGet(message.Properties, out WebSocketMessageProperty webSocketMessageProperty))
            {
                outgoingMessageType = webSocketMessageProperty.MessageType;
            }

            return(outgoingMessageType);
        }
        internal static bool TryGet(MessageProperties properties, out WebSocketMessageProperty property)
        {
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(properties));
            }

            property = null;
            if (properties.TryGetValue(Name, out object foundProperty))
            {
                property = (WebSocketMessageProperty)foundProperty;
                return(true);
            }
            return(false);
        }
            private void AddMessageProperties(MessageProperties messageProperties, WebSocketMessageType incomingMessageType)
            {
                Fx.Assert(messageProperties != null, "messageProperties should not be null.");
                WebSocketMessageProperty messageProperty = new WebSocketMessageProperty(
                    _context,
                    _webSocket.SubProtocol,
                    incomingMessageType,
                    _properties);

                messageProperties.Add(WebSocketMessageProperty.Name, messageProperty);

                if (RemoteEndpointMessageProperty != null)
                {
                    messageProperties.Add(RemoteEndpointMessageProperty.Name, RemoteEndpointMessageProperty);
                }

                if (_handshakeSecurityMessageProperty != null)
                {
                    messageProperties.Security = (SecurityMessageProperty)_handshakeSecurityMessageProperty.CreateCopy();
                }
            }