implemented SPED method for Server, beginning to send data from Client
git-svn-id: svn://anubis/gvsu@41 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
222e23e868
commit
dd3204530f
@ -18,11 +18,15 @@ public class KaZaClient
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
m_socket = new Socket(server, KaZaServer.LISTEN_PORT);
|
m_socket = new Socket(server, KaZaServer.LISTEN_PORT);
|
||||||
|
DataOutputStream os = new DataOutputStream(
|
||||||
|
m_socket.getOutputStream());
|
||||||
|
os.writeBytes("HELO " + userName + "\n");
|
||||||
|
os.writeBytes("SPED " + kbps + "\n");
|
||||||
|
// TODO: publish file list
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: publish our name and file list
|
|
||||||
Thread fsThread = new Thread(new FileServer(LISTEN_PORT, m_sharedFolder));
|
Thread fsThread = new Thread(new FileServer(LISTEN_PORT, m_sharedFolder));
|
||||||
m_connected = true;
|
m_connected = true;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public class KaZaServer implements Runnable
|
|||||||
{
|
{
|
||||||
s = new Socket(peerName, LISTEN_PORT);
|
s = new Socket(peerName, LISTEN_PORT);
|
||||||
DataOutputStream os = new DataOutputStream(s.getOutputStream());
|
DataOutputStream os = new DataOutputStream(s.getOutputStream());
|
||||||
os.writeBytes("USER KaZaServer\n");
|
os.writeBytes("HELO KaZaServer\n");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -72,6 +72,7 @@ public class KaZaServer implements Runnable
|
|||||||
private class ClientInfo
|
private class ClientInfo
|
||||||
{
|
{
|
||||||
String userName = "Anonymous";
|
String userName = "Anonymous";
|
||||||
|
int speed = 1500;
|
||||||
HashMap<String, String> files = new HashMap<String, String>();
|
HashMap<String, String> files = new HashMap<String, String>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,6 +126,18 @@ public class KaZaServer implements Runnable
|
|||||||
m_clientInfo.userName = inLine.substring(5);
|
m_clientInfo.userName = inLine.substring(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (opCode.equals("SPED"))
|
||||||
|
{
|
||||||
|
/* user is telling us their connection speed */
|
||||||
|
if (tokens.hasMoreTokens())
|
||||||
|
{
|
||||||
|
int speed = Integer.parseInt(tokens.nextToken());
|
||||||
|
synchronized (m_clientData)
|
||||||
|
{
|
||||||
|
m_clientInfo.speed = speed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (opCode.equals("DESC"))
|
else if (opCode.equals("DESC"))
|
||||||
{
|
{
|
||||||
/* user is giving us a description of a file */
|
/* user is giving us a description of a file */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user