添加了register的处理

This commit is contained in:
Kirigaya Kazuto 2017-03-08 21:14:22 +08:00
parent 821e0f97c0
commit 7919d1d3e2

View File

@ -1,9 +1,8 @@
import java.sql.*;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_ADDPeer;
import java.io.*;
import java.net.*;
import com.google.gson.Gson;
class Handle implements Runnable
{
@ -26,12 +25,59 @@ class Handle implements Runnable
os=s.getOutputStream();
pw=new PrintWriter(os);
String str;
while(!((str=br.readLine())==null))
while(true)
{
System.out.println("Receive Message: "+str);
String str=br.readLine();
if(str==null)
{
break;
}
Gson gson=new Gson();
AppJsonData data=null;
try
{
data=gson.fromJson(str, AppJsonData.class);
}
catch(Exception e)
{
System.out.println("Receive a incorrect json string.");
continue;
}
System.out.println("AppJsonData:"+data.getType());
switch(data.getType())
{
case "register":
{
RegisterData reg=null;
try
{
reg=gson.fromJson(str, RegisterData.class);
}
catch(Exception e)
{
System.out.println("Incorrect Register Data");
break;
}
int ret=BookFloatingServer.Register(reg.getEmail(), reg.getPass(), reg.getNickname(), reg.getSchool());
System.out.println("Register Finished. Ret("+ret+")");
pw.write("{'ret':'"+ret+"'}");
}
break;
case "login":
break;
case "getpart":
break;
case "getfull":
break;
case "upload":
break;
}
}
String reply="Connection is OK";
pw.write(reply);
pw.flush();