Example #1
0
 internal static IReadOnlyWebSocketMessage Convert(Spi.Entities.WebSocket.IReadOnlyWebSocketMessage source)
 => new ReadOnlyWebSocketMessage
 {
     Source           = source,
     HandshakeSession = ReadOnlySession.Convert(source.HandshakeSession),
     Opcode           = (WebSocketOpcode)source.Opcode,
 };
Example #2
0
        public void SessionTest()
        {
            var requestLineSource =
                @"GET / HTTP/1.1
";

            Nekoxy2.ApplicationLayer.Entities.Http.HttpRequestLine.TryParse(requestLineSource, out var line);
            var requestHeaderSource =
                @"Host: example.com

";

            Nekoxy2.ApplicationLayer.Entities.Http.HttpHeaders.TryParse(requestHeaderSource, out var requestHeaders);

            var spiRequest = new Nekoxy2.ApplicationLayer.Entities.Http.HttpRequest(line, requestHeaders, new byte[0], Nekoxy2.ApplicationLayer.Entities.Http.HttpHeaders.Empty);

            var statusLineSource =
                @"HTTP/1.1 200 OK
";

            Nekoxy2.ApplicationLayer.Entities.Http.HttpStatusLine.TryParse(statusLineSource, out var statusLine);
            var responseHeaderSource =
                @"Content-Length: 8

";

            Nekoxy2.ApplicationLayer.Entities.Http.HttpHeaders.TryParse(responseHeaderSource, out var responseHeaders);
            var responseBodySource = "hogefuga";

            var spiResponse = new Nekoxy2.ApplicationLayer.Entities.Http.HttpResponse(statusLine, responseHeaders, Encoding.ASCII.GetBytes(responseBodySource), Nekoxy2.ApplicationLayer.Entities.Http.HttpHeaders.Empty);

            var spiSession  = new Nekoxy2.ApplicationLayer.Entities.Http.Session(spiRequest, spiResponse);
            var apiSession  = ReadOnlySession.Convert(spiSession);
            var apiSession2 = ReadOnlySession.Convert(spiSession);

            apiSession.ToString().Is(spiSession.ToString());
            apiSession.GetHashCode().Is(apiSession2.GetHashCode());
            apiSession.Equals(apiSession2).IsTrue();

            (apiSession is Spi.Entities.Http.IReadOnlySession).IsTrue();
            (apiSession is Nekoxy2.Entities.Http.IReadOnlySession).IsTrue();
            apiSession.Source.Is(spiSession);
        }