--- src/main/java/com/munjaon/client/server/packet/Bind.java
+++ src/main/java/com/munjaon/client/server/packet/Bind.java
... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 |
package com.munjaon.client.server.packet; |
| 2 | 2 |
|
| 3 |
+import java.io.UnsupportedEncodingException; |
|
| 3 | 4 |
import java.nio.ByteBuffer; |
| 4 | 5 |
import java.util.Arrays; |
| 5 | 6 |
|
... | ... | @@ -19,32 +20,32 @@ |
| 19 | 20 |
|
| 20 | 21 |
public static final String ENCRYPTION = "0"; |
| 21 | 22 |
|
| 22 |
- public static ByteBuffer makeBindBuffer(String id, String pwd) {
|
|
| 23 |
+ public static ByteBuffer makeBindBuffer(String id, String pwd) throws UnsupportedEncodingException {
|
|
| 23 | 24 |
ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH + BIND_BODY_LENGTH); |
| 24 | 25 |
Packet.setDefaultByte(buffer); |
| 25 | 26 |
Header.putHeader(buffer, Header.COMMAND_BIND, BIND_BODY_LENGTH); |
| 26 | 27 |
/* ID */ |
| 27 | 28 |
if (id != null) {
|
| 28 |
- buffer.put(BIND_ID_POSITION, id.getBytes()); |
|
| 29 |
+ buffer.put(BIND_ID_POSITION, id.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 29 | 30 |
} |
| 30 | 31 |
/* PWD */ |
| 31 | 32 |
if (pwd != null) {
|
| 32 |
- buffer.put(BIND_PWD_POSITION, pwd.getBytes()); |
|
| 33 |
+ buffer.put(BIND_PWD_POSITION, pwd.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 33 | 34 |
} |
| 34 | 35 |
/* ENCRYPTION */ |
| 35 |
- buffer.put(BIND_ENCRYPTION_POSITION, ENCRYPTION.getBytes()); |
|
| 36 |
+ buffer.put(BIND_ENCRYPTION_POSITION, ENCRYPTION.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 36 | 37 |
// buffer.limit(buffer.capacity()); |
| 37 | 38 |
|
| 38 | 39 |
return buffer; |
| 39 | 40 |
} |
| 40 | 41 |
|
| 41 |
- public static ByteBuffer makeBindAckBuffer(String resultCode) {
|
|
| 42 |
+ public static ByteBuffer makeBindAckBuffer(String resultCode) throws UnsupportedEncodingException {
|
|
| 42 | 43 |
ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH + BIND_ACK_BODY_LENGTH); |
| 43 | 44 |
Packet.setDefaultByte(buffer); |
| 44 | 45 |
Header.putHeader(buffer, Header.COMMAND_BIND_ACK, BIND_ACK_BODY_LENGTH); |
| 45 | 46 |
/* resultCode */ |
| 46 | 47 |
if (resultCode != null) {
|
| 47 |
- buffer.put(BIND_ACK_RESULT_CODE_POSITION, resultCode.getBytes()); |
|
| 48 |
+ buffer.put(BIND_ACK_RESULT_CODE_POSITION, resultCode.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 48 | 49 |
} |
| 49 | 50 |
|
| 50 | 51 |
return buffer; |
--- src/main/java/com/munjaon/client/server/packet/CommonMessage.java
+++ src/main/java/com/munjaon/client/server/packet/CommonMessage.java
... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 |
|
| 3 | 3 |
import com.munjaon.client.util.CommonUtil; |
| 4 | 4 |
|
| 5 |
+import java.io.UnsupportedEncodingException; |
|
| 5 | 6 |
import java.nio.ByteBuffer; |
| 6 | 7 |
import java.util.Arrays; |
| 7 | 8 |
|
... | ... | @@ -34,11 +35,11 @@ |
| 34 | 35 |
public static final int DELIVER_ACK_RESULT_LENGTH = 1; |
| 35 | 36 |
public static final int DELIVER_ACK_RESULT_POSITION = DELIVER_ACK_MESSAGE_ID_POSITION + DELIVER_ACK_MESSAGE_ID_LENGTH; |
| 36 | 37 |
|
| 37 |
- public static void putMessageIdForDeliver(ByteBuffer buffer, String messageId) {
|
|
| 38 |
+ public static void putMessageIdForDeliver(ByteBuffer buffer, String messageId) throws UnsupportedEncodingException {
|
|
| 38 | 39 |
if (buffer == null || messageId == null) {
|
| 39 | 40 |
return; |
| 40 | 41 |
} |
| 41 |
- buffer.put(DELIVER_MESSAGE_ID_POSITION, messageId.getBytes()); |
|
| 42 |
+ buffer.put(DELIVER_MESSAGE_ID_POSITION, messageId.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 42 | 43 |
} |
| 43 | 44 |
public static String getMessageIdForDeliver(ByteBuffer buffer) {
|
| 44 | 45 |
if (buffer == null) {
|
... | ... | @@ -52,12 +53,12 @@ |
| 52 | 53 |
return Packet.getString(destArray); |
| 53 | 54 |
} |
| 54 | 55 |
|
| 55 |
- public static void putSenderForDeliver(ByteBuffer buffer, String sender) {
|
|
| 56 |
+ public static void putSenderForDeliver(ByteBuffer buffer, String sender) throws UnsupportedEncodingException {
|
|
| 56 | 57 |
if (buffer == null || sender == null) {
|
| 57 | 58 |
return; |
| 58 | 59 |
} |
| 59 | 60 |
sender = CommonUtil.cutString(CommonUtil.doNumber(sender), DELIVER_SENDER_LENGTH); |
| 60 |
- buffer.put(DELIVER_SENDER_POSITION, sender.getBytes()); |
|
| 61 |
+ buffer.put(DELIVER_SENDER_POSITION, sender.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 61 | 62 |
} |
| 62 | 63 |
public static String getSenderForDeliver(ByteBuffer buffer) {
|
| 63 | 64 |
if (buffer == null) {
|
... | ... | @@ -71,12 +72,12 @@ |
| 71 | 72 |
return Packet.getString(destArray); |
| 72 | 73 |
} |
| 73 | 74 |
|
| 74 |
- public static void putReceiverForDeliver(ByteBuffer buffer, String receiver) {
|
|
| 75 |
+ public static void putReceiverForDeliver(ByteBuffer buffer, String receiver) throws UnsupportedEncodingException {
|
|
| 75 | 76 |
if (buffer == null || receiver == null) {
|
| 76 | 77 |
return; |
| 77 | 78 |
} |
| 78 | 79 |
receiver = CommonUtil.cutString(CommonUtil.doNumber(receiver), DELIVER_RECEIVER_LENGTH); |
| 79 |
- buffer.put(DELIVER_RECEIVER_POSITION, receiver.getBytes()); |
|
| 80 |
+ buffer.put(DELIVER_RECEIVER_POSITION, receiver.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 80 | 81 |
} |
| 81 | 82 |
public static String getReceiverForDeliver(ByteBuffer buffer) {
|
| 82 | 83 |
if (buffer == null) {
|
... | ... | @@ -90,11 +91,11 @@ |
| 90 | 91 |
return Packet.getString(destArray); |
| 91 | 92 |
} |
| 92 | 93 |
|
| 93 |
- public static void putReserveTimeForDeliver(ByteBuffer buffer, String reserveTime) {
|
|
| 94 |
+ public static void putReserveTimeForDeliver(ByteBuffer buffer, String reserveTime) throws UnsupportedEncodingException {
|
|
| 94 | 95 |
if (buffer == null || reserveTime == null) {
|
| 95 | 96 |
return; |
| 96 | 97 |
} |
| 97 |
- buffer.put(DELIVER_RESERVE_TIME_POSITION, reserveTime.getBytes()); |
|
| 98 |
+ buffer.put(DELIVER_RESERVE_TIME_POSITION, reserveTime.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 98 | 99 |
} |
| 99 | 100 |
public static String getReserveTimeForDeliver(ByteBuffer buffer) {
|
| 100 | 101 |
if (buffer == null) {
|
... | ... | @@ -108,11 +109,11 @@ |
| 108 | 109 |
return Packet.getString(destArray); |
| 109 | 110 |
} |
| 110 | 111 |
|
| 111 |
- public static void putRequestTimeForDeliver(ByteBuffer buffer, String requestTime) {
|
|
| 112 |
+ public static void putRequestTimeForDeliver(ByteBuffer buffer, String requestTime) throws UnsupportedEncodingException {
|
|
| 112 | 113 |
if (buffer == null || requestTime == null) {
|
| 113 | 114 |
return; |
| 114 | 115 |
} |
| 115 |
- buffer.put(DELIVER_REQUEST_TIME_POSITION, requestTime.getBytes()); |
|
| 116 |
+ buffer.put(DELIVER_REQUEST_TIME_POSITION, requestTime.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 116 | 117 |
} |
| 117 | 118 |
public static String getRequestTimeForDeliver(ByteBuffer buffer) {
|
| 118 | 119 |
if (buffer == null) {
|
... | ... | @@ -126,11 +127,11 @@ |
| 126 | 127 |
return Packet.getString(destArray); |
| 127 | 128 |
} |
| 128 | 129 |
|
| 129 |
- public static void putMsgTypeForDeliver(ByteBuffer buffer, String msgType) {
|
|
| 130 |
+ public static void putMsgTypeForDeliver(ByteBuffer buffer, String msgType) throws UnsupportedEncodingException {
|
|
| 130 | 131 |
if (buffer == null || msgType == null) {
|
| 131 | 132 |
return; |
| 132 | 133 |
} |
| 133 |
- buffer.put(DELIVER_MSG_TYPE_POSITION, msgType.getBytes()); |
|
| 134 |
+ buffer.put(DELIVER_MSG_TYPE_POSITION, msgType.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 134 | 135 |
} |
| 135 | 136 |
public static String getMsgTypeForDeliver(ByteBuffer buffer) {
|
| 136 | 137 |
if (buffer == null) {
|
... | ... | @@ -145,11 +146,11 @@ |
| 145 | 146 |
} |
| 146 | 147 |
|
| 147 | 148 |
|
| 148 |
- public static void putMessageIdForDeliverAck(ByteBuffer buffer, String messageId) {
|
|
| 149 |
+ public static void putMessageIdForDeliverAck(ByteBuffer buffer, String messageId) throws UnsupportedEncodingException {
|
|
| 149 | 150 |
if (buffer == null || messageId == null) {
|
| 150 | 151 |
return; |
| 151 | 152 |
} |
| 152 |
- buffer.put(DELIVER_ACK_MESSAGE_ID_POSITION, messageId.getBytes()); |
|
| 153 |
+ buffer.put(DELIVER_ACK_MESSAGE_ID_POSITION, messageId.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 153 | 154 |
} |
| 154 | 155 |
public static String getMessageIdForDeliverAck(ByteBuffer buffer) {
|
| 155 | 156 |
if (buffer == null) {
|
... | ... | @@ -163,11 +164,11 @@ |
| 163 | 164 |
return Packet.getString(destArray); |
| 164 | 165 |
} |
| 165 | 166 |
|
| 166 |
- public static void putResultForDeliverAck(ByteBuffer buffer, String result) {
|
|
| 167 |
+ public static void putResultForDeliverAck(ByteBuffer buffer, String result) throws UnsupportedEncodingException {
|
|
| 167 | 168 |
if (buffer == null || result == null) {
|
| 168 | 169 |
return; |
| 169 | 170 |
} |
| 170 |
- buffer.put(DELIVER_ACK_RESULT_POSITION, result.getBytes()); |
|
| 171 |
+ buffer.put(DELIVER_ACK_RESULT_POSITION, result.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 171 | 172 |
} |
| 172 | 173 |
public static String getResultForDeliverAck(ByteBuffer buffer) {
|
| 173 | 174 |
if (buffer == null) {
|
--- src/main/java/com/munjaon/client/server/packet/Header.java
+++ src/main/java/com/munjaon/client/server/packet/Header.java
... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 |
|
| 3 | 3 |
import com.munjaon.client.util.ByteUtil; |
| 4 | 4 |
|
| 5 |
+import java.io.UnsupportedEncodingException; |
|
| 5 | 6 |
import java.nio.ByteBuffer; |
| 6 | 7 |
import java.util.Arrays; |
| 7 | 8 |
|
... | ... | @@ -40,11 +41,11 @@ |
| 40 | 41 |
public static final int BODY_REPORT_LENGTH = 58; |
| 41 | 42 |
public static final int BODY_REPORT_ACK_LENGTH = 1; |
| 42 | 43 |
|
| 43 |
- public static void putVersion(final ByteBuffer buffer) {
|
|
| 44 |
+ public static void putVersion(final ByteBuffer buffer) throws UnsupportedEncodingException {
|
|
| 44 | 45 |
if (buffer == null) {
|
| 45 | 46 |
return; |
| 46 | 47 |
} |
| 47 |
- buffer.put(VERSION_POSITION, VERSION.getBytes()); |
|
| 48 |
+ buffer.put(VERSION_POSITION, VERSION.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 48 | 49 |
} |
| 49 | 50 |
public static String getVersion(final ByteBuffer buffer) {
|
| 50 | 51 |
if (buffer == null) {
|
... | ... | @@ -58,11 +59,11 @@ |
| 58 | 59 |
return Packet.getString(destArray); |
| 59 | 60 |
} |
| 60 | 61 |
|
| 61 |
- public static void putCommand(final ByteBuffer buffer, String command) {
|
|
| 62 |
+ public static void putCommand(final ByteBuffer buffer, String command) throws UnsupportedEncodingException {
|
|
| 62 | 63 |
if (buffer == null) {
|
| 63 | 64 |
return; |
| 64 | 65 |
} |
| 65 |
- buffer.put(COMMAND_POSITION, command.getBytes()); |
|
| 66 |
+ buffer.put(COMMAND_POSITION, command.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 66 | 67 |
} |
| 67 | 68 |
public static String getCommand(final ByteBuffer buffer) {
|
| 68 | 69 |
if (buffer == null) {
|
... | ... | @@ -76,7 +77,7 @@ |
| 76 | 77 |
return Packet.getString(destArray); |
| 77 | 78 |
} |
| 78 | 79 |
|
| 79 |
- public static void putBodyLength(final ByteBuffer buffer, int bodyLength) {
|
|
| 80 |
+ public static void putBodyLength(final ByteBuffer buffer, int bodyLength) throws UnsupportedEncodingException {
|
|
| 80 | 81 |
putBodyLength(buffer, Integer.toString(bodyLength)); |
| 81 | 82 |
} |
| 82 | 83 |
public static String getBodyLength(final ByteBuffer buffer) {
|
... | ... | @@ -91,18 +92,18 @@ |
| 91 | 92 |
return Packet.getString(destArray); |
| 92 | 93 |
} |
| 93 | 94 |
|
| 94 |
- public static void putBodyLength(final ByteBuffer buffer, String bodyLength) {
|
|
| 95 |
+ public static void putBodyLength(final ByteBuffer buffer, String bodyLength) throws UnsupportedEncodingException {
|
|
| 95 | 96 |
if (buffer == null) {
|
| 96 | 97 |
return; |
| 97 | 98 |
} |
| 98 |
- System.out.println(ByteUtil.byteToHex(bodyLength.getBytes(), true)); |
|
| 99 |
+// System.out.println(ByteUtil.byteToHex(bodyLength.getBytes(), true)); |
|
| 99 | 100 |
|
| 100 |
- buffer.put(BODY_POSITION, bodyLength.getBytes()); |
|
| 101 |
+ buffer.put(BODY_POSITION, bodyLength.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 101 | 102 |
} |
| 102 |
- public static void putHeader(final ByteBuffer buffer, String command, int bodyLength) {
|
|
| 103 |
+ public static void putHeader(final ByteBuffer buffer, String command, int bodyLength) throws UnsupportedEncodingException {
|
|
| 103 | 104 |
putHeader(buffer, command, Integer.toString(bodyLength)); |
| 104 | 105 |
} |
| 105 |
- public static void putHeader(final ByteBuffer buffer, String command, String bodyLength) {
|
|
| 106 |
+ public static void putHeader(final ByteBuffer buffer, String command, String bodyLength) throws UnsupportedEncodingException {
|
|
| 106 | 107 |
putVersion(buffer); |
| 107 | 108 |
putCommand(buffer, command); |
| 108 | 109 |
putBodyLength(buffer, bodyLength); |
--- src/main/java/com/munjaon/client/server/packet/KakaoMessage.java
+++ src/main/java/com/munjaon/client/server/packet/KakaoMessage.java
... | ... | @@ -5,6 +5,7 @@ |
| 5 | 5 |
|
| 6 | 6 |
import java.io.File; |
| 7 | 7 |
import java.io.IOException; |
| 8 |
+import java.io.UnsupportedEncodingException; |
|
| 8 | 9 |
import java.nio.ByteBuffer; |
| 9 | 10 |
import java.nio.file.Files; |
| 10 | 11 |
|
... | ... | @@ -34,12 +35,12 @@ |
| 34 | 35 |
public static final int DELIVER_KAKAO_TEMPLATE_CODE_LENGTH = 64; |
| 35 | 36 |
public static final int DELIVER_KAKAO_TEMPLATE_CODE_POSITION = DELIVER_KAKAO_SENDER_KEY_POSITION + DELIVER_KAKAO_SENDER_KEY_LENGTH; |
| 36 | 37 |
|
| 37 |
- public static void putSubjectForDeliver(ByteBuffer buffer, String subject) {
|
|
| 38 |
+ public static void putSubjectForDeliver(ByteBuffer buffer, String subject) throws UnsupportedEncodingException {
|
|
| 38 | 39 |
if (buffer == null || subject == null) {
|
| 39 | 40 |
return; |
| 40 | 41 |
} |
| 41 | 42 |
subject = CommonUtil.cutString(subject, DELIVER_SUBJECT_LENGTH); |
| 42 |
- buffer.put(DELIVER_SUBJECT_POSITION, subject.getBytes()); |
|
| 43 |
+ buffer.put(DELIVER_SUBJECT_POSITION, subject.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 43 | 44 |
} |
| 44 | 45 |
public static String getSubjectForDeliver(ByteBuffer buffer) {
|
| 45 | 46 |
if (buffer == null) {
|
... | ... | @@ -53,12 +54,12 @@ |
| 53 | 54 |
return Packet.getString(destArray); |
| 54 | 55 |
} |
| 55 | 56 |
|
| 56 |
- public static void putMessageForDeliver(ByteBuffer buffer, String message) {
|
|
| 57 |
+ public static void putMessageForDeliver(ByteBuffer buffer, String message) throws UnsupportedEncodingException {
|
|
| 57 | 58 |
if (buffer == null || message == null) {
|
| 58 | 59 |
return; |
| 59 | 60 |
} |
| 60 | 61 |
message = CommonUtil.cutString(message, DELIVER_MESSAGE_LENGTH); |
| 61 |
- buffer.put(DELIVER_MESSAGE_POSITION, message.getBytes()); |
|
| 62 |
+ buffer.put(DELIVER_MESSAGE_POSITION, message.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 62 | 63 |
} |
| 63 | 64 |
public static String getMessageForDeliver(ByteBuffer buffer) {
|
| 64 | 65 |
if (buffer == null) {
|
... | ... | @@ -71,12 +72,12 @@ |
| 71 | 72 |
|
| 72 | 73 |
return Packet.getString(destArray); |
| 73 | 74 |
} |
| 74 |
- public static void putKakaoSenderKeyForDeliver(ByteBuffer buffer, String kakaoSenderKey) {
|
|
| 75 |
+ public static void putKakaoSenderKeyForDeliver(ByteBuffer buffer, String kakaoSenderKey) throws UnsupportedEncodingException {
|
|
| 75 | 76 |
if (buffer == null || kakaoSenderKey == null) {
|
| 76 | 77 |
return; |
| 77 | 78 |
} |
| 78 | 79 |
kakaoSenderKey = CommonUtil.cutString(kakaoSenderKey, DELIVER_KAKAO_SENDER_KEY_LENGTH); |
| 79 |
- buffer.put(DELIVER_KAKAO_SENDER_KEY_POSITION, kakaoSenderKey.getBytes()); |
|
| 80 |
+ buffer.put(DELIVER_KAKAO_SENDER_KEY_POSITION, kakaoSenderKey.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 80 | 81 |
} |
| 81 | 82 |
public static String getKakaoSenderKeyForDeliver(ByteBuffer buffer) {
|
| 82 | 83 |
if (buffer == null) {
|
... | ... | @@ -89,12 +90,12 @@ |
| 89 | 90 |
|
| 90 | 91 |
return Packet.getString(destArray); |
| 91 | 92 |
} |
| 92 |
- public static void putKakaoTemplateCodeForDeliver(ByteBuffer buffer, String kakaoTemplateCode) {
|
|
| 93 |
+ public static void putKakaoTemplateCodeForDeliver(ByteBuffer buffer, String kakaoTemplateCode) throws UnsupportedEncodingException {
|
|
| 93 | 94 |
if (buffer == null || kakaoTemplateCode == null) {
|
| 94 | 95 |
return; |
| 95 | 96 |
} |
| 96 | 97 |
kakaoTemplateCode = CommonUtil.cutString(kakaoTemplateCode, DELIVER_KAKAO_TEMPLATE_CODE_LENGTH); |
| 97 |
- buffer.put(DELIVER_KAKAO_TEMPLATE_CODE_POSITION, kakaoTemplateCode.getBytes()); |
|
| 98 |
+ buffer.put(DELIVER_KAKAO_TEMPLATE_CODE_POSITION, kakaoTemplateCode.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 98 | 99 |
} |
| 99 | 100 |
public static String getKakaoTemplateCodeForDeliver(ByteBuffer buffer) {
|
| 100 | 101 |
if (buffer == null) {
|
... | ... | @@ -107,7 +108,7 @@ |
| 107 | 108 |
|
| 108 | 109 |
return Packet.getString(destArray); |
| 109 | 110 |
} |
| 110 |
- public static void makeDataForDeliver(ByteBuffer buffer, MunjaonMsg data) {
|
|
| 111 |
+ public static void makeDataForDeliver(ByteBuffer buffer, MunjaonMsg data) throws UnsupportedEncodingException {
|
|
| 111 | 112 |
if (buffer == null || data == null) {
|
| 112 | 113 |
return; |
| 113 | 114 |
} |
... | ... | @@ -133,7 +134,7 @@ |
| 133 | 134 |
putKakaoTemplateCodeForDeliver(buffer, data.getKakaoTemplateCode()); |
| 134 | 135 |
} |
| 135 | 136 |
|
| 136 |
- public static ByteBuffer makeJsonForDeliver(String path, String fileName) {
|
|
| 137 |
+ public static ByteBuffer makeJsonForDeliver(String path, String fileName) throws UnsupportedEncodingException {
|
|
| 137 | 138 |
if (path == null || fileName == null) {
|
| 138 | 139 |
return null; |
| 139 | 140 |
} |
... | ... | @@ -142,8 +143,8 @@ |
| 142 | 143 |
return null; |
| 143 | 144 |
} |
| 144 | 145 |
ByteBuffer fileHeadBuffer = ByteBuffer.allocate(MmsMessage.DELIVER_MMS_FILENAME_LENGTH + MmsMessage.DELIVER_MMS_FILESIZE_LENGTH); |
| 145 |
- fileHeadBuffer.put(DELIVER_JSON_FILENAME_POSITION, fileName.getBytes()); |
|
| 146 |
- fileHeadBuffer.put(DELIVER_JSON_FILESIZE_POSITION, String.valueOf(file.length()).getBytes()); |
|
| 146 |
+ fileHeadBuffer.put(DELIVER_JSON_FILENAME_POSITION, fileName.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 147 |
+ fileHeadBuffer.put(DELIVER_JSON_FILESIZE_POSITION, String.valueOf(file.length()).getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 147 | 148 |
ByteBuffer fileBodyBuffer = ByteBuffer.allocate((int) file.length()); |
| 148 | 149 |
ByteBuffer fileBuffer = null; |
| 149 | 150 |
try {
|
--- src/main/java/com/munjaon/client/server/packet/LinkCheck.java
+++ src/main/java/com/munjaon/client/server/packet/LinkCheck.java
... | ... | @@ -1,5 +1,6 @@ |
| 1 | 1 |
package com.munjaon.client.server.packet; |
| 2 | 2 |
|
| 3 |
+import java.io.UnsupportedEncodingException; |
|
| 3 | 4 |
import java.nio.ByteBuffer; |
| 4 | 5 |
|
| 5 | 6 |
public final class LinkCheck {
|
... | ... | @@ -11,20 +12,20 @@ |
| 11 | 12 |
public static String LINK_CHECK_VALUE = "100"; |
| 12 | 13 |
public static String LINK_CHECK_ACK_VALUE = "100"; |
| 13 | 14 |
|
| 14 |
- public static ByteBuffer makeLinkCheckBuffer() {
|
|
| 15 |
+ public static ByteBuffer makeLinkCheckBuffer() throws UnsupportedEncodingException {
|
|
| 15 | 16 |
ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH + LINK_CHECK_BODY_LENGTH); |
| 16 | 17 |
Packet.setDefaultByte(buffer); |
| 17 | 18 |
Header.putHeader(buffer, Header.COMMAND_LINK_CHECK, LINK_CHECK_BODY_LENGTH); |
| 18 |
- buffer.put(LINK_CHECK_BODY_POSITION, LINK_CHECK_VALUE.getBytes()); |
|
| 19 |
+ buffer.put(LINK_CHECK_BODY_POSITION, LINK_CHECK_VALUE.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 19 | 20 |
|
| 20 | 21 |
return buffer; |
| 21 | 22 |
} |
| 22 | 23 |
|
| 23 |
- public static ByteBuffer makeLinkCheckAckBuffer() {
|
|
| 24 |
+ public static ByteBuffer makeLinkCheckAckBuffer() throws UnsupportedEncodingException {
|
|
| 24 | 25 |
ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH + LINK_CHECK_ACK_BODY_LENGTH); |
| 25 | 26 |
Packet.setDefaultByte(buffer); |
| 26 | 27 |
Header.putHeader(buffer, Header.COMMAND_LINK_CHECK_ACK, LINK_CHECK_ACK_BODY_LENGTH); |
| 27 |
- buffer.put(LINK_CHECK_ACK_BODY_POSITION, LINK_CHECK_ACK_VALUE.getBytes()); |
|
| 28 |
+ buffer.put(LINK_CHECK_ACK_BODY_POSITION, LINK_CHECK_ACK_VALUE.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 28 | 29 |
|
| 29 | 30 |
return buffer; |
| 30 | 31 |
} |
--- src/main/java/com/munjaon/client/server/packet/LmsMessage.java
+++ src/main/java/com/munjaon/client/server/packet/LmsMessage.java
... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 |
import com.munjaon.client.model.MunjaonMsg; |
| 4 | 4 |
import com.munjaon.client.util.CommonUtil; |
| 5 | 5 |
|
| 6 |
+import java.io.UnsupportedEncodingException; |
|
| 6 | 7 |
import java.nio.ByteBuffer; |
| 7 | 8 |
|
| 8 | 9 |
public final class LmsMessage {
|
... | ... | @@ -17,12 +18,12 @@ |
| 17 | 18 |
public static final int DELIVER_MESSAGE_LENGTH = 2000; |
| 18 | 19 |
public static final int DELIVER_MESSAGE_POSITION = DELIVER_SUBJECT_POSITION + DELIVER_SUBJECT_LENGTH; |
| 19 | 20 |
|
| 20 |
- public static void putSubjectForDeliver(ByteBuffer buffer, String subject) {
|
|
| 21 |
+ public static void putSubjectForDeliver(ByteBuffer buffer, String subject) throws UnsupportedEncodingException {
|
|
| 21 | 22 |
if (buffer == null || subject == null) {
|
| 22 | 23 |
return; |
| 23 | 24 |
} |
| 24 | 25 |
subject = CommonUtil.cutString(subject, DELIVER_SUBJECT_LENGTH); |
| 25 |
- buffer.put(DELIVER_SUBJECT_POSITION, subject.getBytes()); |
|
| 26 |
+ buffer.put(DELIVER_SUBJECT_POSITION, subject.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 26 | 27 |
} |
| 27 | 28 |
public static String getSubjectForDeliver(ByteBuffer buffer) {
|
| 28 | 29 |
if (buffer == null) {
|
... | ... | @@ -36,12 +37,12 @@ |
| 36 | 37 |
return Packet.getString(destArray); |
| 37 | 38 |
} |
| 38 | 39 |
|
| 39 |
- public static void putMessageForDeliver(ByteBuffer buffer, String message) {
|
|
| 40 |
+ public static void putMessageForDeliver(ByteBuffer buffer, String message) throws UnsupportedEncodingException {
|
|
| 40 | 41 |
if (buffer == null || message == null) {
|
| 41 | 42 |
return; |
| 42 | 43 |
} |
| 43 | 44 |
message = CommonUtil.cutString(message, DELIVER_MESSAGE_LENGTH); |
| 44 |
- buffer.put(DELIVER_MESSAGE_POSITION, message.getBytes()); |
|
| 45 |
+ buffer.put(DELIVER_MESSAGE_POSITION, message.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 45 | 46 |
} |
| 46 | 47 |
public static String getMessageForDeliver(ByteBuffer buffer) {
|
| 47 | 48 |
if (buffer == null) {
|
... | ... | @@ -54,7 +55,7 @@ |
| 54 | 55 |
|
| 55 | 56 |
return Packet.getString(destArray); |
| 56 | 57 |
} |
| 57 |
- public static void makeDataForDeliver(ByteBuffer buffer, MunjaonMsg data) {
|
|
| 58 |
+ public static void makeDataForDeliver(ByteBuffer buffer, MunjaonMsg data) throws UnsupportedEncodingException {
|
|
| 58 | 59 |
if (buffer == null || data == null) {
|
| 59 | 60 |
return; |
| 60 | 61 |
} |
--- src/main/java/com/munjaon/client/server/packet/MmsMessage.java
+++ src/main/java/com/munjaon/client/server/packet/MmsMessage.java
... | ... | @@ -5,6 +5,7 @@ |
| 5 | 5 |
|
| 6 | 6 |
import java.io.File; |
| 7 | 7 |
import java.io.IOException; |
| 8 |
+import java.io.UnsupportedEncodingException; |
|
| 8 | 9 |
import java.nio.ByteBuffer; |
| 9 | 10 |
import java.nio.file.Files; |
| 10 | 11 |
|
... | ... | @@ -31,12 +32,12 @@ |
| 31 | 32 |
public static final int DELIVER_FILECOUNT_LENGTH = 1; |
| 32 | 33 |
public static final int DELIVER_FILECOUNT_POSITION = DELIVER_MESSAGE_POSITION + DELIVER_MESSAGE_LENGTH; |
| 33 | 34 |
|
| 34 |
- public static void putSubjectForDeliver(ByteBuffer buffer, String subject) {
|
|
| 35 |
+ public static void putSubjectForDeliver(ByteBuffer buffer, String subject) throws UnsupportedEncodingException {
|
|
| 35 | 36 |
if (buffer == null || subject == null) {
|
| 36 | 37 |
return; |
| 37 | 38 |
} |
| 38 | 39 |
subject = CommonUtil.cutString(subject, DELIVER_SUBJECT_LENGTH); |
| 39 |
- buffer.put(DELIVER_SUBJECT_POSITION, subject.getBytes()); |
|
| 40 |
+ buffer.put(DELIVER_SUBJECT_POSITION, subject.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 40 | 41 |
} |
| 41 | 42 |
public static String getSubjectForDeliver(ByteBuffer buffer) {
|
| 42 | 43 |
if (buffer == null) {
|
... | ... | @@ -50,12 +51,12 @@ |
| 50 | 51 |
return Packet.getString(destArray); |
| 51 | 52 |
} |
| 52 | 53 |
|
| 53 |
- public static void putMessageForDeliver(ByteBuffer buffer, String message) {
|
|
| 54 |
+ public static void putMessageForDeliver(ByteBuffer buffer, String message) throws UnsupportedEncodingException {
|
|
| 54 | 55 |
if (buffer == null || message == null) {
|
| 55 | 56 |
return; |
| 56 | 57 |
} |
| 57 | 58 |
message = CommonUtil.cutString(message, DELIVER_MESSAGE_LENGTH); |
| 58 |
- buffer.put(DELIVER_MESSAGE_POSITION, message.getBytes()); |
|
| 59 |
+ buffer.put(DELIVER_MESSAGE_POSITION, message.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 59 | 60 |
} |
| 60 | 61 |
public static String getMessageForDeliver(ByteBuffer buffer) {
|
| 61 | 62 |
if (buffer == null) {
|
... | ... | @@ -69,15 +70,15 @@ |
| 69 | 70 |
return Packet.getString(destArray); |
| 70 | 71 |
} |
| 71 | 72 |
|
| 72 |
- public static void putFileCountForDeliver(ByteBuffer buffer, int fileCount) {
|
|
| 73 |
+ public static void putFileCountForDeliver(ByteBuffer buffer, int fileCount) throws UnsupportedEncodingException {
|
|
| 73 | 74 |
putFileCountForDeliver(buffer, Integer.toString(fileCount)); |
| 74 | 75 |
} |
| 75 | 76 |
|
| 76 |
- public static void putFileCountForDeliver(ByteBuffer buffer, String fileCount) {
|
|
| 77 |
+ public static void putFileCountForDeliver(ByteBuffer buffer, String fileCount) throws UnsupportedEncodingException {
|
|
| 77 | 78 |
if (buffer == null || fileCount == null) {
|
| 78 | 79 |
return; |
| 79 | 80 |
} |
| 80 |
- buffer.put(DELIVER_FILECOUNT_POSITION, fileCount.getBytes()); |
|
| 81 |
+ buffer.put(DELIVER_FILECOUNT_POSITION, fileCount.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 81 | 82 |
} |
| 82 | 83 |
public static String getFileCountForDeliver(ByteBuffer buffer) {
|
| 83 | 84 |
if (buffer == null) {
|
... | ... | @@ -90,7 +91,7 @@ |
| 90 | 91 |
|
| 91 | 92 |
return Packet.getString(destArray); |
| 92 | 93 |
} |
| 93 |
- public static void makeDataForDeliver(ByteBuffer buffer, MunjaonMsg data) {
|
|
| 94 |
+ public static void makeDataForDeliver(ByteBuffer buffer, MunjaonMsg data) throws UnsupportedEncodingException {
|
|
| 94 | 95 |
if (buffer == null || data == null) {
|
| 95 | 96 |
return; |
| 96 | 97 |
} |
... | ... | @@ -114,7 +115,7 @@ |
| 114 | 115 |
putFileCountForDeliver(buffer, data.getFileCount()); |
| 115 | 116 |
} |
| 116 | 117 |
|
| 117 |
- public static ByteBuffer makeImageForDeliver(String path, String fileName) {
|
|
| 118 |
+ public static ByteBuffer makeImageForDeliver(String path, String fileName) throws UnsupportedEncodingException {
|
|
| 118 | 119 |
if (path == null || fileName == null) {
|
| 119 | 120 |
return null; |
| 120 | 121 |
} |
... | ... | @@ -123,8 +124,8 @@ |
| 123 | 124 |
return null; |
| 124 | 125 |
} |
| 125 | 126 |
ByteBuffer fileHeadBuffer = ByteBuffer.allocate(MmsMessage.DELIVER_MMS_FILENAME_LENGTH + MmsMessage.DELIVER_MMS_FILESIZE_LENGTH); |
| 126 |
- fileHeadBuffer.put(DELIVER_MMS_FILENAME_POSITION, fileName.getBytes()); |
|
| 127 |
- fileHeadBuffer.put(DELIVER_MMS_FILESIZE_POSITION, String.valueOf(file.length()).getBytes()); |
|
| 127 |
+ fileHeadBuffer.put(DELIVER_MMS_FILENAME_POSITION, fileName.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 128 |
+ fileHeadBuffer.put(DELIVER_MMS_FILESIZE_POSITION, String.valueOf(file.length()).getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 128 | 129 |
ByteBuffer fileBodyBuffer = ByteBuffer.allocate((int) file.length()); |
| 129 | 130 |
ByteBuffer fileBuffer = null; |
| 130 | 131 |
try {
|
--- src/main/java/com/munjaon/client/server/packet/Packet.java
+++ src/main/java/com/munjaon/client/server/packet/Packet.java
... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 |
import java.nio.ByteBuffer; |
| 4 | 4 |
|
| 5 | 5 |
public final class Packet {
|
| 6 |
+ public static final String AGENT_CHARACTER_SET = "EUC-KR"; |
|
| 6 | 7 |
public static final byte SET_DEFAULT_BYTE = (byte) 0x00; |
| 7 | 8 |
public static final long LINK_CHECK_CYCLE = 10000L; |
| 8 | 9 |
/* 패킷 만료 시간 체크 */ |
--- src/main/java/com/munjaon/client/server/packet/Report.java
+++ src/main/java/com/munjaon/client/server/packet/Report.java
... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 |
|
| 3 | 3 |
import com.munjaon.client.model.MunjaonMsg; |
| 4 | 4 |
|
| 5 |
+import java.io.UnsupportedEncodingException; |
|
| 5 | 6 |
import java.nio.ByteBuffer; |
| 6 | 7 |
|
| 7 | 8 |
public final class Report {
|
... | ... | @@ -22,7 +23,7 @@ |
| 22 | 23 |
public static final int REPORT_ACK_RESULT_CODE_LENGTH = 1; |
| 23 | 24 |
public static final int REPORT_ACK_RESULT_CODE_POSITION = Header.BODY_POSITION + Header.BODY_LENGTH; |
| 24 | 25 |
|
| 25 |
- public static ByteBuffer makeReport(MunjaonMsg msgData) {
|
|
| 26 |
+ public static ByteBuffer makeReport(MunjaonMsg msgData) throws UnsupportedEncodingException {
|
|
| 26 | 27 |
ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH + REPORT_BODY_LENGTH); |
| 27 | 28 |
Packet.setDefaultByte(buffer); |
| 28 | 29 |
Header.putHeader(buffer, Header.COMMAND_REPORT, REPORT_BODY_LENGTH); |
... | ... | @@ -54,12 +55,12 @@ |
| 54 | 55 |
return msgData; |
| 55 | 56 |
} |
| 56 | 57 |
|
| 57 |
- public static void makeReportForMsgId(final ByteBuffer buffer, final String msgId) {
|
|
| 58 |
+ public static void makeReportForMsgId(final ByteBuffer buffer, final String msgId) throws UnsupportedEncodingException {
|
|
| 58 | 59 |
if (buffer == null || msgId == null) {
|
| 59 | 60 |
return; |
| 60 | 61 |
} |
| 61 | 62 |
|
| 62 |
- buffer.put(REPORT_MSG_ID_POSITION, msgId.getBytes()); |
|
| 63 |
+ buffer.put(REPORT_MSG_ID_POSITION, msgId.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 63 | 64 |
} |
| 64 | 65 |
|
| 65 | 66 |
public static String getReportForMsgId(final ByteBuffer buffer) {
|
... | ... | @@ -74,12 +75,12 @@ |
| 74 | 75 |
return Packet.getString(destArray); |
| 75 | 76 |
} |
| 76 | 77 |
|
| 77 |
- public static void makeReportForAgentCode(final ByteBuffer buffer, final String agentCode) {
|
|
| 78 |
+ public static void makeReportForAgentCode(final ByteBuffer buffer, final String agentCode) throws UnsupportedEncodingException {
|
|
| 78 | 79 |
if (buffer == null || agentCode == null) {
|
| 79 | 80 |
return; |
| 80 | 81 |
} |
| 81 | 82 |
|
| 82 |
- buffer.put(REPORT_AGENT_CODE_POSITION, agentCode.getBytes()); |
|
| 83 |
+ buffer.put(REPORT_AGENT_CODE_POSITION, agentCode.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 83 | 84 |
} |
| 84 | 85 |
|
| 85 | 86 |
public static String getReportForAgentCode(final ByteBuffer buffer) {
|
... | ... | @@ -94,12 +95,12 @@ |
| 94 | 95 |
return Packet.getString(destArray); |
| 95 | 96 |
} |
| 96 | 97 |
|
| 97 |
- public static void makeReportForSendTime(final ByteBuffer buffer, final String sendTime) {
|
|
| 98 |
+ public static void makeReportForSendTime(final ByteBuffer buffer, final String sendTime) throws UnsupportedEncodingException {
|
|
| 98 | 99 |
if (buffer == null || sendTime == null) {
|
| 99 | 100 |
return; |
| 100 | 101 |
} |
| 101 | 102 |
|
| 102 |
- buffer.put(REPORT_SEND_TIME_POSITION, sendTime.getBytes()); |
|
| 103 |
+ buffer.put(REPORT_SEND_TIME_POSITION, sendTime.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 103 | 104 |
} |
| 104 | 105 |
|
| 105 | 106 |
public static String getReportForSendTime(final ByteBuffer buffer) {
|
... | ... | @@ -114,12 +115,12 @@ |
| 114 | 115 |
return Packet.getString(destArray); |
| 115 | 116 |
} |
| 116 | 117 |
|
| 117 |
- public static void makeReportForTelecom(final ByteBuffer buffer, final String telecom) {
|
|
| 118 |
+ public static void makeReportForTelecom(final ByteBuffer buffer, final String telecom) throws UnsupportedEncodingException {
|
|
| 118 | 119 |
if (buffer == null || telecom == null) {
|
| 119 | 120 |
return; |
| 120 | 121 |
} |
| 121 | 122 |
|
| 122 |
- buffer.put(REPORT_TELECOM_POSITION, telecom.getBytes()); |
|
| 123 |
+ buffer.put(REPORT_TELECOM_POSITION, telecom.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 123 | 124 |
} |
| 124 | 125 |
|
| 125 | 126 |
public static String getReportForTelecom(final ByteBuffer buffer) {
|
... | ... | @@ -134,12 +135,12 @@ |
| 134 | 135 |
return Packet.getString(destArray); |
| 135 | 136 |
} |
| 136 | 137 |
|
| 137 |
- public static void makeReportForResult(final ByteBuffer buffer, final String result) {
|
|
| 138 |
+ public static void makeReportForResult(final ByteBuffer buffer, final String result) throws UnsupportedEncodingException {
|
|
| 138 | 139 |
if (buffer == null || result == null) {
|
| 139 | 140 |
return; |
| 140 | 141 |
} |
| 141 | 142 |
|
| 142 |
- buffer.put(REPORT_RESULT_POSITION, result.getBytes()); |
|
| 143 |
+ buffer.put(REPORT_RESULT_POSITION, result.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 143 | 144 |
} |
| 144 | 145 |
|
| 145 | 146 |
public static String getReportForResult(final ByteBuffer buffer) {
|
... | ... | @@ -154,11 +155,11 @@ |
| 154 | 155 |
return Packet.getString(destArray); |
| 155 | 156 |
} |
| 156 | 157 |
|
| 157 |
- public static ByteBuffer makeReportAckBuffer() {
|
|
| 158 |
+ public static ByteBuffer makeReportAckBuffer() throws UnsupportedEncodingException {
|
|
| 158 | 159 |
ByteBuffer buffer = ByteBuffer.allocate(Header.HEADER_LENGTH + REPORT_ACK_BODY_LENGTH); |
| 159 | 160 |
Packet.setDefaultByte(buffer); |
| 160 | 161 |
Header.putHeader(buffer, Header.COMMAND_REPORT_ACK, REPORT_ACK_BODY_LENGTH); |
| 161 |
- buffer.put(REPORT_ACK_RESULT_CODE_POSITION, "1".getBytes()); |
|
| 162 |
+ buffer.put(REPORT_ACK_RESULT_CODE_POSITION, "1".getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 162 | 163 |
|
| 163 | 164 |
return buffer; |
| 164 | 165 |
} |
--- src/main/java/com/munjaon/client/server/packet/SmsMessage.java
+++ src/main/java/com/munjaon/client/server/packet/SmsMessage.java
... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 |
import com.munjaon.client.model.MunjaonMsg; |
| 4 | 4 |
import com.munjaon.client.util.CommonUtil; |
| 5 | 5 |
|
| 6 |
+import java.io.UnsupportedEncodingException; |
|
| 6 | 7 |
import java.nio.ByteBuffer; |
| 7 | 8 |
import java.util.Arrays; |
| 8 | 9 |
|
... | ... | @@ -16,12 +17,12 @@ |
| 16 | 17 |
public static final int DELIVER_MESSAGE_LENGTH = 160; |
| 17 | 18 |
public static final int DELIVER_MESSAGE_POSITION = CommonMessage.DELIVER_MSG_TYPE_POSITION + CommonMessage.DELIVER_MSG_TYPE_LENGTH; |
| 18 | 19 |
|
| 19 |
- public static void putMessageForDeliver(ByteBuffer buffer, String message) {
|
|
| 20 |
+ public static void putMessageForDeliver(ByteBuffer buffer, String message) throws UnsupportedEncodingException {
|
|
| 20 | 21 |
if (buffer == null || message == null) {
|
| 21 | 22 |
return; |
| 22 | 23 |
} |
| 23 | 24 |
message = CommonUtil.cutString(message, DELIVER_MESSAGE_LENGTH); |
| 24 |
- buffer.put(DELIVER_MESSAGE_POSITION, message.getBytes()); |
|
| 25 |
+ buffer.put(DELIVER_MESSAGE_POSITION, message.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 25 | 26 |
} |
| 26 | 27 |
public static String getMessageForDeliver(ByteBuffer buffer) {
|
| 27 | 28 |
if (buffer == null) {
|
... | ... | @@ -34,7 +35,7 @@ |
| 34 | 35 |
|
| 35 | 36 |
return Packet.getString(destArray); |
| 36 | 37 |
} |
| 37 |
- public static void makeDataForDeliver(ByteBuffer buffer, MunjaonMsg data) {
|
|
| 38 |
+ public static void makeDataForDeliver(ByteBuffer buffer, MunjaonMsg data) throws UnsupportedEncodingException {
|
|
| 38 | 39 |
if (buffer == null || data == null) {
|
| 39 | 40 |
return; |
| 40 | 41 |
} |
--- src/main/java/com/munjaon/client/server/service/CollectClientService.java
+++ src/main/java/com/munjaon/client/server/service/CollectClientService.java
... | ... | @@ -61,6 +61,23 @@ |
| 61 | 61 |
try {
|
| 62 | 62 |
socketChannel = SocketChannel.open(new InetSocketAddress(this.address, this.port)); |
| 63 | 63 |
socketChannel.configureBlocking(false); |
| 64 |
+ |
|
| 65 |
+ boolean isConnected = false; |
|
| 66 |
+ long connectStartTime = System.currentTimeMillis(); |
|
| 67 |
+ while (true) {
|
|
| 68 |
+ if (socketChannel.finishConnect()) {
|
|
| 69 |
+ isConnected = true; |
|
| 70 |
+ break; |
|
| 71 |
+ } |
|
| 72 |
+ if (System.currentTimeMillis() - connectStartTime > 3000) {
|
|
| 73 |
+ break; |
|
| 74 |
+ } |
|
| 75 |
+ } |
|
| 76 |
+ if (isConnected) {
|
|
| 77 |
+ saveSystemLog("Connected to [ADDRESS : " + this.address + "] [PORT : " + this.port + "] [ID : " + this.id + "]");
|
|
| 78 |
+ } else {
|
|
| 79 |
+ throw new IOException("Connection Timeout");
|
|
| 80 |
+ } |
|
| 64 | 81 |
} catch (IOException e) {
|
| 65 | 82 |
saveSystemLog("Connect Fail to [ADDRESS : " + this.address + "] [PORT : " + this.port + "] [ID : " + this.id + "]");
|
| 66 | 83 |
saveSystemLog("ERROR [" + e.getMessage() + "]");
|
... | ... | @@ -105,9 +122,10 @@ |
| 105 | 122 |
} |
| 106 | 123 |
|
| 107 | 124 |
private void bind() {
|
| 108 |
- ByteBuffer sendBuffer = Bind.makeBindBuffer(id, pwd); |
|
| 109 |
- ByteBuffer recvBuffer = ByteBuffer.allocate(Header.HEADER_LENGTH + Bind.BIND_ACK_BODY_LENGTH); |
|
| 110 | 125 |
try {
|
| 126 |
+ ByteBuffer sendBuffer = Bind.makeBindBuffer(id, pwd); |
|
| 127 |
+ ByteBuffer recvBuffer = ByteBuffer.allocate(Header.HEADER_LENGTH + Bind.BIND_ACK_BODY_LENGTH); |
|
| 128 |
+ |
|
| 111 | 129 |
saveSystemLog("[BIND REQUEST] [IP : " + this.address + "] [PORT : " + this.port + "] [ID : " + this.id + "]");
|
| 112 | 130 |
socketChannel.write(sendBuffer); |
| 113 | 131 |
long BIND_SEND_TIME = System.currentTimeMillis(); |
--- src/main/java/com/munjaon/client/server/service/ReportClientService.java
+++ src/main/java/com/munjaon/client/server/service/ReportClientService.java
... | ... | @@ -55,6 +55,23 @@ |
| 55 | 55 |
try {
|
| 56 | 56 |
socketChannel = SocketChannel.open(new InetSocketAddress(this.address, this.port)); |
| 57 | 57 |
socketChannel.configureBlocking(false); |
| 58 |
+ |
|
| 59 |
+ boolean isConnected = false; |
|
| 60 |
+ long connectStartTime = System.currentTimeMillis(); |
|
| 61 |
+ while (true) {
|
|
| 62 |
+ if (socketChannel.finishConnect()) {
|
|
| 63 |
+ isConnected = true; |
|
| 64 |
+ break; |
|
| 65 |
+ } |
|
| 66 |
+ if (System.currentTimeMillis() - connectStartTime > 3000) {
|
|
| 67 |
+ break; |
|
| 68 |
+ } |
|
| 69 |
+ } |
|
| 70 |
+ if (isConnected) {
|
|
| 71 |
+ saveSystemLog("Connected to [ADDRESS : " + this.address + "] [PORT : " + this.port + "] [ID : " + this.id + "]");
|
|
| 72 |
+ } else {
|
|
| 73 |
+ throw new IOException("Connection Timeout");
|
|
| 74 |
+ } |
|
| 58 | 75 |
} catch (IOException e) {
|
| 59 | 76 |
saveSystemLog("Connect Fail to [ADDRESS : " + this.address + "] [PORT : " + this.port + "] [ID : " + this.id + "]");
|
| 60 | 77 |
saveSystemLog("ERROR [" + e.getMessage() + "]");
|
... | ... | @@ -99,15 +116,19 @@ |
| 99 | 116 |
} |
| 100 | 117 |
|
| 101 | 118 |
private void bind() {
|
| 102 |
- ByteBuffer sendBuffer = Bind.makeBindBuffer(id, pwd); |
|
| 103 |
- ByteBuffer recvBuffer = ByteBuffer.allocate(Header.HEADER_LENGTH + Bind.BIND_ACK_BODY_LENGTH); |
|
| 104 | 119 |
try {
|
| 105 |
-// saveSystemLog("sendBuffer " + sendBuffer.position() + ":" + sendBuffer.limit());
|
|
| 120 |
+ ByteBuffer sendBuffer = Bind.makeBindBuffer(id, pwd); |
|
| 121 |
+ ByteBuffer recvBuffer = ByteBuffer.allocate(Header.HEADER_LENGTH + Bind.BIND_ACK_BODY_LENGTH); |
|
| 122 |
+ |
|
| 106 | 123 |
saveSystemLog("Bind Try Connect to " + this.address + ":" + this.port);
|
| 107 |
- Thread.sleep(300); |
|
| 108 | 124 |
socketChannel.write(sendBuffer); |
| 109 | 125 |
saveSystemLog("Bind Read to " + this.address + ":" + this.port);
|
| 126 |
+ long BIND_SEND_TIME = System.currentTimeMillis(); |
|
| 110 | 127 |
while (true) {
|
| 128 |
+ if (System.currentTimeMillis() - BIND_SEND_TIME >= Packet.LIMIT_PACKET_SEND_TIMEOUT) {
|
|
| 129 |
+ saveSystemLog("[bindTimeOut : Expired ... ... ... ... ... ... ...]");
|
|
| 130 |
+ throw new RuntimeException("bindTimeOut : Expired ... ... ... ... ... ... ...");
|
|
| 131 |
+ } |
|
| 111 | 132 |
int recvCount = socketChannel.read(recvBuffer); |
| 112 | 133 |
if (recvCount == -1) {
|
| 113 | 134 |
throw new RuntimeException("BIND ERROR");
|
--- src/main/java/com/munjaon/client/server/service/Server.java
+++ src/main/java/com/munjaon/client/server/service/Server.java
... | ... | @@ -1,5 +1,7 @@ |
| 1 | 1 |
package com.munjaon.client.server.service; |
| 2 | 2 |
|
| 3 |
+import com.munjaon.client.server.packet.Packet; |
|
| 4 |
+ |
|
| 3 | 5 |
import java.io.IOException; |
| 4 | 6 |
import java.net.InetSocketAddress; |
| 5 | 7 |
import java.net.Socket; |
... | ... | @@ -176,7 +178,7 @@ |
| 176 | 178 |
// StringBuffer 초기화 |
| 177 | 179 |
sb.setLength(0); |
| 178 | 180 |
// byte 형식으로 변환 |
| 179 |
- ByteBuffer buffer = ByteBuffer.wrap(data.getBytes()); |
|
| 181 |
+ ByteBuffer buffer = ByteBuffer.wrap(data.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 180 | 182 |
// ***데이터 송신*** |
| 181 | 183 |
channel.write(buffer); |
| 182 | 184 |
// Socket 채널을 channel에 수신 등록한다 |
--- src/main/java/com/munjaon/client/util/ByteUtil.java
+++ src/main/java/com/munjaon/client/util/ByteUtil.java
... | ... | @@ -5,6 +5,10 @@ |
| 5 | 5 |
|
| 6 | 6 |
package com.munjaon.client.util; |
| 7 | 7 |
|
| 8 |
+import com.munjaon.client.server.packet.Packet; |
|
| 9 |
+ |
|
| 10 |
+import java.io.UnsupportedEncodingException; |
|
| 11 |
+ |
|
| 8 | 12 |
/** |
| 9 | 13 |
* bytes 관련 유틸리티 클래스 |
| 10 | 14 |
* @author JDS |
... | ... | @@ -130,10 +134,10 @@ |
| 130 | 134 |
return src[offset]; |
| 131 | 135 |
} |
| 132 | 136 |
|
| 133 |
- public static byte[] getBytes(String data) {
|
|
| 137 |
+ public static byte[] getBytes(String data) throws UnsupportedEncodingException {
|
|
| 134 | 138 |
byte[] b = null; |
| 135 | 139 |
|
| 136 |
- b = data.getBytes(); |
|
| 140 |
+ b = data.getBytes(Packet.AGENT_CHARACTER_SET); |
|
| 137 | 141 |
|
| 138 | 142 |
return (b); |
| 139 | 143 |
} |
... | ... | @@ -171,8 +175,8 @@ |
| 171 | 175 |
return dest; |
| 172 | 176 |
} |
| 173 | 177 |
|
| 174 |
- public static void setBytes(byte[] dest, int offset, String s) {
|
|
| 175 |
- setBytes(dest, offset, s.getBytes()); |
|
| 178 |
+ public static void setBytes(byte[] dest, int offset, String s) throws UnsupportedEncodingException {
|
|
| 179 |
+ setBytes(dest, offset, s.getBytes(Packet.AGENT_CHARACTER_SET)); |
|
| 176 | 180 |
} |
| 177 | 181 |
|
| 178 | 182 |
public static byte[] setBytes(byte dest[], int offset, byte src[]) {
|
--- src/main/java/com/munjaon/client/util/CommonUtil.java
+++ src/main/java/com/munjaon/client/util/CommonUtil.java
... | ... | @@ -1,5 +1,8 @@ |
| 1 | 1 |
package com.munjaon.client.util; |
| 2 | 2 |
|
| 3 |
+import com.munjaon.client.server.packet.Packet; |
|
| 4 |
+ |
|
| 5 |
+import java.io.UnsupportedEncodingException; |
|
| 3 | 6 |
import java.text.ParseException; |
| 4 | 7 |
import java.text.SimpleDateFormat; |
| 5 | 8 |
import java.util.Calendar; |
... | ... | @@ -69,12 +72,11 @@ |
| 69 | 72 |
return isValid; |
| 70 | 73 |
} |
| 71 | 74 |
// 해당 길이만큼 문자열을 자르는 함수 |
| 72 |
- public static String cutString(String str, int limit) |
|
| 73 |
- {
|
|
| 75 |
+ public static String cutString(String str, int limit) throws UnsupportedEncodingException {
|
|
| 74 | 76 |
int len = str.length(); |
| 75 | 77 |
int sumLength=0; |
| 76 | 78 |
String cutString = null; |
| 77 |
- byte[] toByte = str.getBytes(); |
|
| 79 |
+ byte[] toByte = str.getBytes(Packet.AGENT_CHARACTER_SET); |
|
| 78 | 80 |
|
| 79 | 81 |
if(limit < 2) |
| 80 | 82 |
return ""; |
--- src/main/java/com/munjaon/client/util/MessageCheckUtil.java
+++ src/main/java/com/munjaon/client/util/MessageCheckUtil.java
... | ... | @@ -5,9 +5,10 @@ |
| 5 | 5 |
import com.munjaon.client.server.packet.*; |
| 6 | 6 |
|
| 7 | 7 |
import java.io.File; |
| 8 |
+import java.io.UnsupportedEncodingException; |
|
| 8 | 9 |
|
| 9 | 10 |
public class MessageCheckUtil {
|
| 10 |
- public static int validateMessageForCommon(MunjaonMsg data) {
|
|
| 11 |
+ public static int validateMessageForCommon(MunjaonMsg data) throws UnsupportedEncodingException {
|
|
| 11 | 12 |
int code = isNullMessageForCommon(data); |
| 12 | 13 |
if (code != ErrorCode.OK.getCode()) {
|
| 13 | 14 |
return code; |
... | ... | @@ -15,20 +16,20 @@ |
| 15 | 16 |
|
| 16 | 17 |
return isLengthMessageForCommon(data); |
| 17 | 18 |
} |
| 18 |
- public static int isLengthMessageForCommon(MunjaonMsg data) {
|
|
| 19 |
+ public static int isLengthMessageForCommon(MunjaonMsg data) throws UnsupportedEncodingException {
|
|
| 19 | 20 |
/* MSG_ID */ |
| 20 | 21 |
String value = data.getMsgId().trim(); |
| 21 |
- if (value.length() == 0 || value.getBytes().length > CommonMessage.DELIVER_MESSAGE_ID_LENGTH) {
|
|
| 22 |
+ if (value.length() == 0 || value.getBytes(Packet.AGENT_CHARACTER_SET).length > CommonMessage.DELIVER_MESSAGE_ID_LENGTH) {
|
|
| 22 | 23 |
return ErrorCode.ERROR_MSGID_IS_CAPACITY.getCode(); |
| 23 | 24 |
} |
| 24 | 25 |
/* SENDER */ |
| 25 | 26 |
value = MessageUtil.doNumber(data.getSendPhone()); |
| 26 |
- if (value.getBytes().length < 8 || value.getBytes().length > CommonMessage.DELIVER_SENDER_LENGTH) {
|
|
| 27 |
+ if (value.getBytes().length < 8 || value.getBytes(Packet.AGENT_CHARACTER_SET).length > CommonMessage.DELIVER_SENDER_LENGTH) {
|
|
| 27 | 28 |
return ErrorCode.ERROR_SENDER_IS_CAPACITY.getCode(); |
| 28 | 29 |
} |
| 29 | 30 |
/* RECEIVER */ |
| 30 | 31 |
value = MessageUtil.doNumber(data.getRecvPhone()); |
| 31 |
- if (value.getBytes().length < 10 || value.getBytes().length > CommonMessage.DELIVER_RECEIVER_LENGTH) {
|
|
| 32 |
+ if (value.getBytes().length < 10 || value.getBytes(Packet.AGENT_CHARACTER_SET).length > CommonMessage.DELIVER_RECEIVER_LENGTH) {
|
|
| 32 | 33 |
return ErrorCode.ERROR_RECEIVER_IS_CAPACITY.getCode(); |
| 33 | 34 |
} |
| 34 | 35 |
if ("01".equals(value.substring(0, 2)) == false) {
|
... | ... | @@ -55,18 +56,18 @@ |
| 55 | 56 |
return ErrorCode.OK.getCode(); |
| 56 | 57 |
} |
| 57 | 58 |
|
| 58 |
- public static int validateMessageForSms(MunjaonMsg data) {
|
|
| 59 |
+ public static int validateMessageForSms(MunjaonMsg data) throws UnsupportedEncodingException {
|
|
| 59 | 60 |
if (data.getMessage() == null || data.getMessage().isEmpty()) {
|
| 60 | 61 |
return ErrorCode.ERROR_SMS_MSG_IS_NULL.getCode(); |
| 61 | 62 |
} |
| 62 |
- if (data.getMessage().getBytes().length > SmsMessage.DELIVER_MESSAGE_TRANS_LENGTH) {
|
|
| 63 |
+ if (data.getMessage().getBytes(Packet.AGENT_CHARACTER_SET).length > SmsMessage.DELIVER_MESSAGE_TRANS_LENGTH) {
|
|
| 63 | 64 |
return ErrorCode.ERROR_SMS_MSG_IS_CAPACITY.getCode(); |
| 64 | 65 |
} |
| 65 | 66 |
|
| 66 | 67 |
return ErrorCode.OK.getCode(); |
| 67 | 68 |
} |
| 68 | 69 |
|
| 69 |
- public static int validateMessageForMedia(MunjaonMsg data) {
|
|
| 70 |
+ public static int validateMessageForMedia(MunjaonMsg data) throws UnsupportedEncodingException {
|
|
| 70 | 71 |
if (data == null) {
|
| 71 | 72 |
return ErrorCode.ERROR_DATA_IS_NULL.getCode(); |
| 72 | 73 |
} |
... | ... | @@ -76,10 +77,10 @@ |
| 76 | 77 |
if (data.getMessage() == null) {
|
| 77 | 78 |
return ErrorCode.ERROR_MULTI_MESSAGE_IS_NULL.getCode(); |
| 78 | 79 |
} |
| 79 |
- if (data.getSubject().getBytes().length > LmsMessage.DELIVER_SUBJECT_LENGTH) {
|
|
| 80 |
+ if (data.getSubject().getBytes(Packet.AGENT_CHARACTER_SET).length > LmsMessage.DELIVER_SUBJECT_LENGTH) {
|
|
| 80 | 81 |
return ErrorCode.ERROR_SUBJECT_OVER_CAPACITY.getCode(); |
| 81 | 82 |
} |
| 82 |
- if (data.getMessage().getBytes().length > LmsMessage.DELIVER_MESSAGE_LENGTH) {
|
|
| 83 |
+ if (data.getMessage().getBytes(Packet.AGENT_CHARACTER_SET).length > LmsMessage.DELIVER_MESSAGE_LENGTH) {
|
|
| 83 | 84 |
return ErrorCode.ERROR_MULTI_MESSAGE_OVER_CAPACITY.getCode(); |
| 84 | 85 |
} |
| 85 | 86 |
|
... | ... | @@ -193,7 +194,7 @@ |
| 193 | 194 |
return false; |
| 194 | 195 |
} |
| 195 | 196 |
|
| 196 |
- public static int validateMessageForKakao(MunjaonMsg data) {
|
|
| 197 |
+ public static int validateMessageForKakao(MunjaonMsg data) throws UnsupportedEncodingException {
|
|
| 197 | 198 |
if (data == null) {
|
| 198 | 199 |
return ErrorCode.ERROR_DATA_IS_NULL.getCode(); |
| 199 | 200 |
} |
... | ... | @@ -212,16 +213,16 @@ |
| 212 | 213 |
if (data.getKakaoJsonFile() == null) {
|
| 213 | 214 |
return ErrorCode.ERROR_KAKAO_JSON_FILE_IS_NULL.getCode(); |
| 214 | 215 |
} |
| 215 |
- if (data.getSubject().getBytes().length > LmsMessage.DELIVER_SUBJECT_LENGTH) {
|
|
| 216 |
+ if (data.getSubject().getBytes(Packet.AGENT_CHARACTER_SET).length > LmsMessage.DELIVER_SUBJECT_LENGTH) {
|
|
| 216 | 217 |
return ErrorCode.ERROR_SUBJECT_OVER_CAPACITY.getCode(); |
| 217 | 218 |
} |
| 218 |
- if (data.getMessage().getBytes().length > LmsMessage.DELIVER_MESSAGE_LENGTH) {
|
|
| 219 |
+ if (data.getMessage().getBytes(Packet.AGENT_CHARACTER_SET).length > LmsMessage.DELIVER_MESSAGE_LENGTH) {
|
|
| 219 | 220 |
return ErrorCode.ERROR_MULTI_MESSAGE_OVER_CAPACITY.getCode(); |
| 220 | 221 |
} |
| 221 |
- if (data.getKakaoSenderKey().getBytes().length > KakaoMessage.DELIVER_KAKAO_SENDER_KEY_LENGTH) {
|
|
| 222 |
+ if (data.getKakaoSenderKey().getBytes(Packet.AGENT_CHARACTER_SET).length > KakaoMessage.DELIVER_KAKAO_SENDER_KEY_LENGTH) {
|
|
| 222 | 223 |
return ErrorCode.ERROR_KAKAO_SENDER_KEY_OVER_CAPACITY.getCode(); |
| 223 | 224 |
} |
| 224 |
- if (data.getKakaoTemplateCode().getBytes().length > KakaoMessage.DELIVER_KAKAO_TEMPLATE_CODE_LENGTH) {
|
|
| 225 |
+ if (data.getKakaoTemplateCode().getBytes(Packet.AGENT_CHARACTER_SET).length > KakaoMessage.DELIVER_KAKAO_TEMPLATE_CODE_LENGTH) {
|
|
| 225 | 226 |
return ErrorCode.ERROR_KAKAO_TEMPLATE_CODE_OVER_CAPACITY.getCode(); |
| 226 | 227 |
} |
| 227 | 228 |
|
... | ... | @@ -264,14 +265,15 @@ |
| 264 | 265 |
} |
| 265 | 266 |
|
| 266 | 267 |
|
| 267 |
- public static void main(String[] args) {
|
|
| 268 |
- String fileName = " .dat"; |
|
| 269 |
- int lastIndex = fileName.lastIndexOf(".");
|
|
| 270 |
- if (lastIndex < 0) {
|
|
| 271 |
- System.out.println("EXT is not ");
|
|
| 272 |
- } else {
|
|
| 273 |
- System.out.println("EXT : " + fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()));
|
|
| 274 |
- } |
|
| 275 |
- System.out.println("NM :" + fileName.substring(0, lastIndex) + "<<");
|
|
| 268 |
+ public static void main(String[] args) throws UnsupportedEncodingException {
|
|
| 269 |
+// String fileName = " .dat"; |
|
| 270 |
+// int lastIndex = fileName.lastIndexOf(".");
|
|
| 271 |
+// if (lastIndex < 0) {
|
|
| 272 |
+// System.out.println("EXT is not ");
|
|
| 273 |
+// } else {
|
|
| 274 |
+// System.out.println("EXT : " + fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length()));
|
|
| 275 |
+// } |
|
| 276 |
+// System.out.println("NM :" + fileName.substring(0, lastIndex) + "<<");
|
|
| 277 |
+ System.out.println("한c".getBytes("EUC-KR").length);
|
|
| 276 | 278 |
} |
| 277 | 279 |
} |
--- src/main/java/com/munjaon/client/util/MessageUtil.java
+++ src/main/java/com/munjaon/client/util/MessageUtil.java
... | ... | @@ -1,5 +1,8 @@ |
| 1 | 1 |
package com.munjaon.client.util; |
| 2 | 2 |
|
| 3 |
+import com.munjaon.client.server.packet.Packet; |
|
| 4 |
+ |
|
| 5 |
+import java.io.UnsupportedEncodingException; |
|
| 3 | 6 |
import java.time.LocalDateTime; |
| 4 | 7 |
import java.time.format.DateTimeFormatter; |
| 5 | 8 |
|
... | ... | @@ -94,15 +97,15 @@ |
| 94 | 97 |
return isEmptyForMessage(obj, false); |
| 95 | 98 |
} |
| 96 | 99 |
|
| 97 |
- public static boolean isOverByteForMessage(String obj, int limitCount, boolean trimFlag) {
|
|
| 100 |
+ public static boolean isOverByteForMessage(String obj, int limitCount, boolean trimFlag) throws UnsupportedEncodingException {
|
|
| 98 | 101 |
if (isEmptyForMessage(obj, trimFlag)) {
|
| 99 | 102 |
return true; |
| 100 | 103 |
} |
| 101 | 104 |
|
| 102 |
- return obj.getBytes().length > limitCount; |
|
| 105 |
+ return obj.getBytes(Packet.AGENT_CHARACTER_SET).length > limitCount; |
|
| 103 | 106 |
} |
| 104 | 107 |
|
| 105 |
- public static boolean isOverByteForMessage(String obj, int limitCount) {
|
|
| 108 |
+ public static boolean isOverByteForMessage(String obj, int limitCount) throws UnsupportedEncodingException {
|
|
| 106 | 109 |
return isOverByteForMessage(obj, limitCount, false); |
| 107 | 110 |
} |
| 108 | 111 |
} |
--- src/main/java/com/munjaon/client/util/StringUtil.java
+++ src/main/java/com/munjaon/client/util/StringUtil.java
... | ... | @@ -5,6 +5,9 @@ |
| 5 | 5 |
|
| 6 | 6 |
package com.munjaon.client.util; |
| 7 | 7 |
|
| 8 |
+import com.munjaon.client.server.packet.Packet; |
|
| 9 |
+ |
|
| 10 |
+import java.io.UnsupportedEncodingException; |
|
| 8 | 11 |
import java.text.DecimalFormat; |
| 9 | 12 |
import java.util.ArrayList; |
| 10 | 13 |
|
... | ... | @@ -123,19 +126,19 @@ |
| 123 | 126 |
return sRet; |
| 124 | 127 |
} |
| 125 | 128 |
|
| 126 |
- public static String substring(String obj, int idx, int length) {
|
|
| 127 |
- if( obj.getBytes().length <= idx ) {
|
|
| 129 |
+ public static String substring(String obj, int idx, int length) throws UnsupportedEncodingException {
|
|
| 130 |
+ if( obj.getBytes(Packet.AGENT_CHARACTER_SET).length <= idx ) {
|
|
| 128 | 131 |
return ""; |
| 129 | 132 |
} |
| 130 | 133 |
|
| 131 |
- if( obj.getBytes().length <= length ) {
|
|
| 134 |
+ if( obj.getBytes(Packet.AGENT_CHARACTER_SET).length <= length ) {
|
|
| 132 | 135 |
return obj; |
| 133 | 136 |
} |
| 134 | 137 |
|
| 135 | 138 |
int totallen=0; |
| 136 | 139 |
int i=idx; |
| 137 | 140 |
for( i=idx; i<obj.length(); i++ ) {
|
| 138 |
- totallen += obj.substring(i, i+1).getBytes().length; |
|
| 141 |
+ totallen += obj.substring(i, i+1).getBytes(Packet.AGENT_CHARACTER_SET).length; |
|
| 139 | 142 |
|
| 140 | 143 |
if( length < totallen ) {
|
| 141 | 144 |
break; |
... | ... | @@ -145,7 +148,7 @@ |
| 145 | 148 |
return obj.substring(idx, i); |
| 146 | 149 |
} |
| 147 | 150 |
|
| 148 |
- public static String substring(String obj, int length) {
|
|
| 151 |
+ public static String substring(String obj, int length) throws UnsupportedEncodingException {
|
|
| 149 | 152 |
return substring(obj, 0, length); |
| 150 | 153 |
} |
| 151 | 154 |
|
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?