-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
113 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
test/Unosquare.Labs.EmbedIO.Tests/TestObjects/TestLocalSessionController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
namespace Unosquare.Labs.EmbedIO.Tests.TestObjects | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Unosquare.Labs.EmbedIO.Modules; | ||
#if NET46 | ||
using System.Net; | ||
#else | ||
using Net; | ||
#endif | ||
|
||
public class TestLocalSessionController : WebApiController | ||
{ | ||
public const string DeleteSession = "deletesession"; | ||
public const string PutData = "putdata"; | ||
public const string GetData = "getdata"; | ||
public const string MyData = "MyData"; | ||
|
||
[WebApiHandler(HttpVerbs.Get, "/deletesession")] | ||
public bool DeleteSessionC(WebServer server, HttpListenerContext context) | ||
{ | ||
server.DeleteSession(context); | ||
|
||
return context.JsonResponse("Deleted"); | ||
} | ||
|
||
[WebApiHandler(HttpVerbs.Get, "/putdata")] | ||
public bool PutDataSession(WebServer server, HttpListenerContext context) | ||
{ | ||
server.GetSession(context).Data.TryAdd("sessionData", MyData); | ||
|
||
return context.JsonResponse(server.GetSession(context).Data["sessionData"].ToString()); | ||
} | ||
|
||
[WebApiHandler(HttpVerbs.Get, "/getdata")] | ||
public bool GetDataSession(WebServer server, HttpListenerContext context) | ||
{ | ||
object _data = null; | ||
if (server.GetSession(context).Data.TryGetValue("sessionData", out _data)) | ||
return context.JsonResponse(server.GetSession(context).Data["sessionData"].ToString()); | ||
else | ||
return context.JsonResponse(""); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters