채팅서버[JAVA]
본 자료는 2페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
해당 자료는 2페이지 까지만 미리보기를 제공합니다.
2페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

채팅서버[JAVA]에 대한 보고서 자료입니다.

본문내용

if(obj == loginButton) {
id = idInput.getText();
label2.setText("대화명 : " + id);
clayout.show(tab, "logout");
connectServer();
} else if(obj == logoutButton) {
// 로그아웃 메시지 전송
msgOut.setText("");
outMsg.println(id + "/" + "logout");
// 대화 창 클리어
// 로그인 패널로 전환
clayout.show(tab, "login");
outMsg.close();
try {
inMsg.close();
socket.close();
} catch(IOException e) {
e.printStackTrace();
}
status = false;
}
else if(obj == msgInput) {//메세지를 입력할 때
//***************서버로 id, 메시지, 리스트의 인덱스값을 보내줌***************
outMsg.println(id + "/" + msgInput.getText() + "/" + listIndex);
// 입력 창 클리어
msgInput.setText("");
}
}
/////////////////////////////////////////********** JList에 ListSelectionListener추가하기위해 구현
public void valueChanged(ListSelectionEvent e) {
//JList에 ListSelectionListener의 valueChanged메소드 구현
listIndex = chatList.getAnchorSelectionIndex(); //마지막에 선택된 채팅리스트의 인덱스값을 얻음
}
//////////////////////////////////////////////////////
public void run() {
// 수신 메시지를 처리하는 변수
String msg;
String[] rmsg;
status = true;
while(status) {
try {
// 메시지 수신과 파싱
msg = inMsg.readLine();
rmsg = msg.split("/");
//**********채팅 리스트를 JList에 추가 하기 위한 코딩**********
chatl= new String[rmsg.length-1];
chatl[0] = "모든 채팅"; //채팅리스트의 처음 값은 모든 채팅
for(int i=2 ; i chatl[i-1] = rmsg[i]; //서버에서 보내주는 모든 id값 채팅리스트에 저장
chatList.setListData(chatl); // JList에 chatl배열로 세팅
///////////////////////////////////////////////////
// JTextArea에 수신된 메시지 추가
msgOut.append(rmsg[0] + ">"+rmsg[1] + "\n");
// 커서를 현재 대화 메시지에 표시
msgOut.setCaretPosition(msgOut.getDocument().getLength());
} catch(IOException e) {
// e.printStackTrace();
status = false;
}
}
System.out.println("[MultiChatClient]" + thread.getName() + "종료됨");
}
public static void main(String[] args) {
MultiChatClient mcc = new MultiChatClient("127.0.0.1");
}
}
  • 가격500
  • 페이지수8페이지
  • 등록일2016.01.13
  • 저작시기2011.1
  • 파일형식한글(hwp)
  • 자료번호#992186
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니