-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgraded solution, updated fwk, refactored Resolve, moved ProxyDummyE…
…cho out of the Logic file and implemented a (shy) CONNECT.
- Loading branch information
ignacio
committed
Oct 22, 2014
1 parent
61cbe8c
commit 93c66ec
Showing
11 changed files
with
223 additions
and
94 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
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,3 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration> |
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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="log4net" version="2.0.3" targetFramework="net45" /> | ||
</packages> |
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,63 @@ | ||
namespace TrotiNet | ||
{ | ||
|
||
/// <summary> | ||
/// Dummy proxy that simply echoes back what it gets from the browser | ||
/// </summary> | ||
/// Used for TCP testing. | ||
public class ProxyDummyEcho : AbstractProxyLogic | ||
{ | ||
bool bPrintEchoPrefix; | ||
|
||
/// <summary> | ||
/// Instantiate a dummy proxy that echoes what it reads on the | ||
/// socket back to it | ||
/// </summary> | ||
/// <param name="socketBP">Client socket</param> | ||
/// <param name="PrintEchoPrefix">If true, the proxy will add an | ||
/// "Echo" prefix for each message</param> | ||
public ProxyDummyEcho(HttpSocket socketBP, bool PrintEchoPrefix) : | ||
base(socketBP) | ||
{ | ||
bPrintEchoPrefix = PrintEchoPrefix; | ||
} | ||
|
||
/// <summary> | ||
/// Static constructor with <c>PrintEchoPrefix = true</c> | ||
/// </summary> | ||
static public AbstractProxyLogic CreateEchoProxy(HttpSocket socketBP) | ||
{ | ||
return new ProxyDummyEcho(socketBP, true); | ||
} | ||
|
||
/// <summary> | ||
/// Static constructor with <c>PrintEchoPrefix = false</c> | ||
/// </summary> | ||
static public AbstractProxyLogic CreateMirrorProxy(HttpSocket socketBP) | ||
{ | ||
return new ProxyDummyEcho(socketBP, false); | ||
} | ||
|
||
/// <summary> | ||
/// Dummy logic loop, for test purposes | ||
/// </summary> | ||
override public bool LogicLoop() | ||
{ | ||
uint r = SocketBP.ReadBinary(); | ||
if (r == 0) | ||
// Connection closed | ||
return false; | ||
|
||
string s = System.Text.ASCIIEncoding.ASCII.GetString( | ||
SocketBP.Buffer, 0, (int)r); | ||
if (bPrintEchoPrefix) | ||
SocketBP.WriteBinary(System.Text.ASCIIEncoding. | ||
ASCII.GetBytes("Echo: ")); | ||
SocketBP.WriteBinary(SocketBP.Buffer, r); | ||
|
||
if (s.StartsWith("x")) | ||
return false; | ||
return true; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.