위와 같이 써줬더니 서버가 터졌다. 번거롭지만 +로 연결해서 아래와 같이 써주자.
펑!
그리고 아래와 같이 써 주자.
이 데이터는 진수님이 슬랙에 공유해주신 걸 기반으로 변환하였다.
import java.io.OutputStream;
import java.net.Socket;
import org.apache.jmeter.util.JMeterUtils;
// 서버 정보
String serverName = "127.0.0.1";
int port = 6666;
// 전송할 바이너리 데이터
byte[] loginData = {0x00, 0x03, 0x05, 0x31, 0x2e, 0x30, 0x2e, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x1a, 0x16, 0x0a, 0x09, 0x71, 0x77, 0x40,
0x71, 0x77, 0x2e, 0x63, 0x6f, 0x6d, 0x12, 0x09, 0x71, 0x77, 0x40, 0x71, 0x77, 0x2e, 0x63, 0x6f, 0x6d};
byte[] loginData2 = {0x00, 0x03, 0x05, 0x31, 0x2e, 0x30, 0x2e, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x1a, 0x16, 0x0a, 0x09, 0x77, 0x65, 0x40,
0x77, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x12, 0x09, 0x77, 0x65, 0x40, 0x77, 0x65, 0x2e, 0x63, 0x6f, 0x6d};
byte[] createRoomData = {0x00, 0x05, 0x05, 0x31, 0x2e, 0x30, 0x2e, 0x30, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x21, 0x2a, 0x1f, 0x0a, 0x1b, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0x21, 0x20, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd, 0xef, 0xbf, 0xbd,
0x21, 0x10, 0x07};
byte[] joinRoomData = {0x00, 0x09, 0x05, 0x31, 0x2e, 0x30, 0x2e, 0x30, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x4a, 0x02, 0x08, 0x01};
byte[] readyForGameData = {0x00, 0x11, 0x05, 0x31, 0x2e, 0x30, 0x2e, 0x30, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x8a, 0x01, 0x00};
byte[] gameStartData = {0x00, 0x14, 0x05, 0x31, 0x2e, 0x30, 0x2e, 0x30, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, 0xa2, 0x01, 0x00};
byte[] updatePositionData = {0x00, 0x17, 0x05, 0x31, 0x2e, 0x30, 0x2e, 0x30, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x15, 0xba, 0x01, 0x12, 0x09, 0x00, 0x00, 0x00,
0x20, 0x76, 0x1b, 0x0f, 0x40, 0x11, 0x00, 0x00, 0x00, 0x40, 0x31, 0x2d, 0x14, 0x40};
// 기존 소켓 연결 유지
Socket socket = (Socket) JMeterUtils.getJMeterProperties().get("testSocket");
if (socket == null || socket.isClosed()) {
socket = new Socket(serverName, port);
JMeterUtils.getJMeterProperties().put("testSocket", socket);
}
// 소켓 연결 및 데이터 전송
OutputStream out = socket.getOutputStream();
//out.write(loginData);
//out.write(loginData2);
//out.write(createRoomData);
//out.write(joinRoomData);
//out.write(readyForGameData);
//out.write(gameStartData);
out.write(updatePositionData);
out.flush();
// 소켓 종료하지 않음
// out.close();
// socket.close();
import promptSync from 'prompt-sync'
const prompt = promptSync();
const input = prompt("값을 입력해주세요: ")
const beanshell = '0x'
const answer = []
const splitedWord = input.split(" ")
splitedWord.forEach((value, index) => {
index === splitedWord.length - 1 ? answer.push(beanshell.concat(value)) : answer.push(beanshell.concat(value, ','))
})
console.log(...answer)
console.log(' ')
console.log(' ')
저 promptSync를 쓰려면 yarn add prompt-sync
로 디펜던시를 추가해줘야 한다.
// 로그인 - 패킷타입 3
<Buffer 00 03 05 31 2e 30 2e 30 00 00 00 01 00 00 00 1d 1a 1b 0a 11 6c 69 68 61 32 37 40 6c 69 68 61 32 37 2e 63 6f 6d 12 06 6c 69 68 61 32 37>
// 방 참가 - 패킷타입 11
<Buffer 00 0b 05 31 2e 30 2e 30 00 00 00 03 00 00 00 02 5a 00>
// 게임 준비 - 패킷타입 17
<Buffer 00 11 05 31 2e 30 2e 30 00 00 00 1a 00 00 00 03 8a 01 00>
// 게임 시작 - 패킷타입 20
<Buffer 00 14 05 31 2e 30 2e 30 00 00 00 1b 00 00 00 03 a2 01 00>
// 게임 내 이동
<Buffer 00 17 05 31 2e 30 2e 30 00 00 00 0e 00 00 00 15 ba 01 12 09 00 00 00 20 f8 1e 34 40 11 00 00 00 00 95 43 24 40>
<Buffer 00 17 05 31 2e 30 2e 30 00 00 00 0f 00 00 00 15 ba 01 12 09 00 00 00 20 89 c0 33 40 11 00 00 00 00 57 a6 23 40>
<Buffer 00 17 05 31 2e 30 2e 30 00 00 00 0c 00 00 00 15 ba 01 12 09 00 00 00 a0 9e ac 34 40 11 00 00 00 00 72 2f 25 40>
<Buffer 00 17 05 31 2e 30 2e 30 00 00 00 0d 00 00 00 15 ba 01 12 09 00 00 00 60 cb 65 34 40 11 00 00 00 80 83 b9 24 40>
<Buffer 00 17 05 31 2e 30 2e 30 00 00 00 04 00 00 00 15 ba 01 12 09 00 00 00 20 6a a4 37 40 11 00 00 00 60 3e 77 25 40>
<Buffer 00 17 05 31 2e 30 2e 30 00 00 00 05 00 00 00 15 ba 01 12 09 00 00 00 a0 44 4a 37 40 11 00 00 00 00 90 9d 25 40>
// 로그인 - 패킷타입 3
<Buffer 00 03 05 31 2e 30 2e 30 00 00 00 01 00 00 00 1d 1a 1b 0a 11 6c 69 68 61 32 38 40 6c 69 68 61 32 38 2e 63 6f 6d 12 06
6c 69 68 61 32 38>
// 방 목록 불러오기 - 패킷타입 7
<Buffer 00 07 05 31 2e 30 2e 30 00 00 00 02 00 00 00 02 3a 00>
// 게임 내 이동
<Buffer 00 17 05 31 2e 30 2e 30 00 00 00 a8 00 00 00 15 ba 01 12 09 00 00 00 e0 8d 37 2a 40 11 00 00 00 80 5e 87 f6 bf>
<Buffer 00 17 05 31 2e 30 2e 30 00 00 00 a9 00 00 00 15 ba 01 12 09 00 00 00 60 1d 42 29 40 11 00 00 00 00 b6 eb f6 bf>
<Buffer 00 17 05 31 2e 30 2e 30 00 00 00 ab 00 00 00 15 ba 01 12 09 00 00 00 a0 f4 d1 27 40 11 00 00 00 40 39 82 f7 bf>
<Buffer 00 17 05 31 2e 30 2e 30 00 00 00 ad 00 00 00 15 ba 01 12 09 00 00 00 c0 6f 24 26 40 11 00 00 00 60 d3 31 f8 bf>
<Buffer 00 17 05 31 2e 30 2e 30 00 00 00 ae 00 00 00 15 ba 01 12 09 00 00 00 60 5b 6c 25 40 11 00 00 00 80 16 7d f8 bf>