현재 회원가입관련된 클래스와 클라이언트 클래스 내에 logincheck라는 메서드가 있습니다.
회원가입에 버튼안에 아이디,이름,비번,주소,번호 순서로 있고 그걸 버튼을 눌럿을때 등록됨과 동시에
클라이언트테스트의 logincheck 메서드를 통해 보내지도록 하는것인데요.
현재 작성한것에 문제가있어서...틀린부분좀 바로 잡아주셨으면해서 글 올려봅니다.
- NewMember.class ( 회원가입 클래스입니당 )
package com.example.buyer;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import com.example.searchmarketa.R;
import com.example.searchmarketb.ClientTest;
public class NewMember extends Activity {
//회원가입 구매자정보
EditText buyerid,buyername,buyerpass,buyeradd,buyernum;
Button buyersign;
ClientTest Client;
//회원 데이터
String BuyDate;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String temp = getIntent().getStringExtra("value");
requestWindowFeature(Window.FEATURE_NO_TITLE);
Client = new ClientTest();
Client.start();
buyerid = (EditText)findViewById(R.id.buyerid);
buyername = (EditText)findViewById(R.id.buyername);
buyerpass = (EditText)findViewById(R.id.buyerpass);
buyeradd = (EditText)findViewById(R.id.buyeradd);
buyernum = (EditText)findViewById(R.id.buyernum);
if(temp.equals("true")){
setContentView(R.layout.newbuyer);
buyersign = (Button)findViewById(R.id.buyersign);
buyersign.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String date1 = new String();
String date2 = new String();
String date3 = new String(); < - 이 굵은 부분들이 버튼안에 데이터를 넣으려고 하는거고용...
String date4 = new String();
String date5 = new String();
boolean bool = false;
DateInfo DateIn = new DateInfo(date1, date2, bool);
Client.loginCheck(date1, date2, bool);
NewMember.this.finish();
}
});
}
else if(temp.equals("buyer")) setContentView(R.layout.newseller);
}
class DateInfo{
String buyerId = buyerid.getText().toString();
String buyerName = buyername.getText().toString();
boolean B_SCheck = false;
/*String buyerPass = buyerpass.getText().toString();
String buyerAdd = buyeradd.getText().toString();
String buyerNum = buyernum.getText().toString();*/
public DateInfo(String buyerid, String buyername,boolean B_Scheck){
buyerId = buyerid;
buyerName = buyername;
B_SCheck = B_Scheck;
/*buyerPass = buyerpass;
buyerAdd = buyeradd;
buyerNum = buyernum;*/
}
public String getBuyerId()
{
return buyerId;
}
public String getBuyerName()
{
return buyerName;
}
public boolean getB_SCheck()
{
return B_SCheck;
}
/*public String getBuyerPass()
{
return buyerPass;
}
public String getBuyerAdd()
{
return buyerAdd;
}
public String getBuyerNum()
{
return buyerNum;
}*/
}
---------------
-ClientTest.class 클라이언트 부분입니당.
package com.example.searchmarketb;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
public class ClientTest implements Runnable {
Socket socket;
String ip = "**.***.**.**";
// String ip = "**.**.**.**";
int port = ****;
BufferedReader in;
PrintWriter out;
Thread thread;
public ClientTest() {
try {
socket = new Socket(ip, port);
out = new PrintWriter(new OutputStreamWriter(
socket.getOutputStream()));
in = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
System.out.println("접속성공");
} catch (IOException e) {
System.out.println("접속실패");
e.printStackTrace();
}
}
public void loginCheck(String id, String password, boolean B_SCheck) {
// LOGIN|juda1|wnek|1
String msg = null;
if (B_SCheck == true)
msg = "LOGIN|" + id + "/" + password + "/1";
else if (B_SCheck == false)
msg = "LOGIN|" + id + "/" + password + "/0";
try {
if (msg != null) {
out.println(msg);
out.flush();
}
} catch (Exception e) {
System.out.println("오류");
}
}
public void start() {
if (thread == null) {
thread = new Thread(this);
}
thread.start();
}
@Override
public void run() {
int i = 1;
System.out.println("쓰레드가동");
try {
while (true) {
System.out.println(i + "try시작");
String line = in.readLine();
if (!line.equals("") && !line.equals(null)) {
System.out.println("서버로부터 메시지 :" + line);
}
System.out.println(i + "try완료");
i++;
}
} catch (Exception e) {
System.out.println(i + "try실패");
e.printStackTrace();
}
}
public void disconnect() throws IOException {
try {
out.flush();
in.close();
out.close();
socket.close();
} catch (IOException e) {
System.out.println(e.toString());
} finally {
out.flush();
in.close();
out.close();
socket.close();
}
}
}
여기까지입니당...도와주세요!!