Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

LibHTTP4.HttpLink


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
/*******************************************************************************
	HttpLink                                                                    <br />
	The actual internet link of the HttpSock object. Because connection timeouts
	can't be handled properly from within the TCPLink this object is used
	internally <br />

	Dcoumentation and Information:
		http://wiki.beyondunreal.com/wiki/LibHTTP                               <br />
																				<br />
	Authors:    Michiel 'El Muerte' Hendriks <elmuerte@drunksnipers.com>  <br />
																				<br />
	Copyright  2004 Michiel "El Muerte" Hendriks                                <br />
	Released under the Lesser Open Unreal Mod License                           <br />
	http://wiki.beyondunreal.com/wiki/LesserOpenUnrealModLicense

	<!-- $Id: HttpLink.uc,v 1.7 2005/08/13 14:57:33 elmuerte Exp $ -->
*******************************************************************************/

class HttpLink extends IpDrv.TcpLink;

/** the owning HttpSock */
var protected HttpSock HttpSock;

/** set the socket component */
function setSocket(HttpSock Sock)
{
	if (HttpSock != none) return;
	HttpSock = Sock;
}

/** call this to destroy the socket */
function Shutdown()
{
	HttpSock = none;
	Destroy();
}

/** @ignore */
event Resolved( IpAddr Addr )
{
	if (HttpSock == none) return;
	HttpSock.InternalResolved(Addr);
}

/** @ignore */
event ResolveFailed()
{
	if (HttpSock == none) return;
	HttpSock.ResolveFailed();
}

/** @ignore */
event Opened()
{
	if (HttpSock == none) return;
	HttpSock.Opened();
}

/** @ignore */
event ReceivedText( string Line )
{
	if (HttpSock == none) return;
	HttpSock.ReceivedText(Line);
}

/** @ignore */
event Closed()
{
	local string data;
	if (HttpSock == none) return;
	if (ReceiveMode == RMODE_Manual && IsDataPending())
	{    // should never happen, but just in case
		ReadText(data);
		HttpSock.ReceivedText(data);
	}
	HttpSock.ReceivedText(chr(10)); // to flush buffered data
	HttpSock.Closed();
}

event Tick(float delta)
{
	super.Tick(delta);
	if (ReceiveMode != RMODE_Manual) return;
	if (!IsConnected()) return;
	FastTransfer();
}

/** will be called when ReceiveMode is RMODE_Manual (e.g. TM_Fast) */
protected function FastTransfer()
{
	local string data;
	local int MaxIt, CurCount, i;
	if (HttpSock == none) return;

	CurCount = 0;
	MaxIt = HttpSock.iMaxIterationsPerTick;
	while (IsDataPending())
	{
		if (MaxIt <= 0)
		{
			HttpSock.Logf("Reached maximum iteration count", class'HttpUtil'.default.LOGINFO, HttpSock.iMaxIterationsPerTick);
			break;
		}
		if (CurCount > HttpSock.iMaxBytesPerTick)
		{
			HttpSock.Logf("Reached maximum bytes per tick", class'HttpUtil'.default.LOGINFO, CurCount, HttpSock.iMaxBytesPerTick);
			break;
		}
		i = ReadText(data);
		if (i == 0) MaxIt--;
		else {
			CurCount += i;
			HttpSock.ReceivedText(data);
		}
	}
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mo 15.8.2005 10:51:40.000 - Creation time: Do 14.8.2014 09:58:40.612 - Created with UnCodeX