├── gradle.properties ├── settings.gradle ├── gradle └── wrapper │ └── gradle-wrapper.properties ├── src └── main │ ├── java │ ├── org │ │ ├── json │ │ │ ├── .svn │ │ │ │ ├── all-wcprops │ │ │ │ └── entries │ │ │ └── simple │ │ │ │ ├── JSONAware.java │ │ │ │ ├── .svn │ │ │ │ ├── text-base │ │ │ │ │ ├── JSONAware.java.svn-base │ │ │ │ │ ├── JSONStreamAware.java.svn-base │ │ │ │ │ ├── JSONArray.java.svn-base │ │ │ │ │ ├── ItemList.java.svn-base │ │ │ │ │ └── JSONObject.java.svn-base │ │ │ │ ├── all-wcprops │ │ │ │ └── entries │ │ │ │ ├── JSONStreamAware.java │ │ │ │ ├── parser │ │ │ │ ├── ContainerFactory.java │ │ │ │ ├── .svn │ │ │ │ │ ├── text-base │ │ │ │ │ │ ├── ContainerFactory.java.svn-base │ │ │ │ │ │ ├── Yytoken.java.svn-base │ │ │ │ │ │ ├── ParseException.java.svn-base │ │ │ │ │ │ └── ContentHandler.java.svn-base │ │ │ │ │ ├── all-wcprops │ │ │ │ │ └── entries │ │ │ │ ├── Yytoken.java │ │ │ │ ├── ParseException.java │ │ │ │ └── ContentHandler.java │ │ │ │ ├── JSONArray.java │ │ │ │ ├── ItemList.java │ │ │ │ └── JSONObject.java │ │ └── java_websocket │ │ │ ├── enums │ │ │ ├── Role.java │ │ │ ├── ReadyState.java │ │ │ ├── CloseHandshakeType.java │ │ │ ├── Opcode.java │ │ │ ├── HandshakeState.java │ │ │ └── package-info.java │ │ │ ├── exceptions │ │ │ ├── InvalidEncodingException.java │ │ │ ├── package-info.java │ │ │ ├── WebsocketNotConnectedException.java │ │ │ ├── IncompleteException.java │ │ │ ├── NotSendableException.java │ │ │ ├── IncompleteHandshakeException.java │ │ │ ├── WrappedIOException.java │ │ │ ├── InvalidFrameException.java │ │ │ ├── InvalidHandshakeException.java │ │ │ ├── InvalidDataException.java │ │ │ └── LimitExceededException.java │ │ │ ├── util │ │ │ ├── package-info.java │ │ │ ├── NamedThreadFactory.java │ │ │ └── ByteBufferUtils.java │ │ │ ├── interfaces │ │ │ ├── package-info.java │ │ │ └── ISSLChannel.java │ │ │ ├── client │ │ │ ├── package-info.java │ │ │ └── DnsResolver.java │ │ │ ├── drafts │ │ │ └── package-info.java │ │ │ ├── server │ │ │ ├── package-info.java │ │ │ ├── DefaultWebSocketServerFactory.java │ │ │ ├── SSLParametersWebSocketServerFactory.java │ │ │ ├── DefaultSSLWebSocketServerFactory.java │ │ │ └── CustomSSLWebSocketServerFactory.java │ │ │ ├── framing │ │ │ ├── package-info.java │ │ │ ├── PingFrame.java │ │ │ ├── BinaryFrame.java │ │ │ ├── ContinuousFrame.java │ │ │ ├── DataFrame.java │ │ │ ├── PongFrame.java │ │ │ ├── TextFrame.java │ │ │ ├── ControlFrame.java │ │ │ └── Framedata.java │ │ │ ├── handshake │ │ │ ├── package-info.java │ │ │ ├── ClientHandshake.java │ │ │ ├── ClientHandshakeBuilder.java │ │ │ ├── ServerHandshake.java │ │ │ ├── HandshakeBuilder.java │ │ │ ├── ServerHandshakeBuilder.java │ │ │ ├── HandshakeImpl1Client.java │ │ │ ├── HandshakeImpl1Server.java │ │ │ ├── Handshakedata.java │ │ │ └── HandshakedataImpl1.java │ │ │ ├── protocols │ │ │ ├── package-info.java │ │ │ ├── IProtocol.java │ │ │ └── Protocol.java │ │ │ ├── extensions │ │ │ ├── package-info.java │ │ │ ├── ExtensionRequestData.java │ │ │ ├── CompressionExtension.java │ │ │ └── DefaultExtension.java │ │ │ ├── WebSocketFactory.java │ │ │ ├── WebSocketServerFactory.java │ │ │ ├── WrappedByteChannel.java │ │ │ ├── AbstractWrappedByteChannel.java │ │ │ ├── SocketChannelIOHelper.java │ │ │ └── WebSocketAdapter.java │ └── me │ │ └── taromati │ │ └── doneconnector │ │ ├── soop │ │ ├── SoopLiveInfo.java │ │ ├── ByteUtil.java │ │ ├── SoopPacket.java │ │ └── SoopApi.java │ │ ├── exception │ │ ├── DoneException.java │ │ └── ExceptionCode.java │ │ ├── DonationListener.java │ │ ├── logger │ │ ├── Logger.java │ │ ├── LoggerFactory.java │ │ ├── SystemLogger.java │ │ └── BukkitLogger.java │ │ ├── SSLUtils.java │ │ ├── Applicaton.java │ │ └── chzzk │ │ └── ChzzkApi.java │ └── resources │ ├── plugin.yml │ └── config.yml ├── .idea └── codeStyles │ ├── codeStyleConfig.xml │ └── Project.xml ├── LICENSE ├── README.md ├── gradlew.bat └── .gitignore /gradle.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'done-connector' 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip 2 | -------------------------------------------------------------------------------- /src/main/java/org/json/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 63 4 | /svn/!svn/ver/201/tags/tag_release_1_1_1/src/main/java/org/json 5 | END 6 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/enums/Role.java: -------------------------------------------------------------------------------- 1 | package org.java_websocket.enums; 2 | 3 | /** 4 | * Enum which represents the states a websocket may be in 5 | */ 6 | public enum Role { 7 | CLIENT, SERVER 8 | } -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/enums/ReadyState.java: -------------------------------------------------------------------------------- 1 | package org.java_websocket.enums; 2 | 3 | /** 4 | * Enum which represents the state a websocket may be in 5 | */ 6 | public enum ReadyState { 7 | NOT_YET_CONNECTED, OPEN, CLOSING, CLOSED 8 | } -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/enums/CloseHandshakeType.java: -------------------------------------------------------------------------------- 1 | package org.java_websocket.enums; 2 | 3 | /** 4 | * Enum which represents type of handshake is required for a close 5 | */ 6 | public enum CloseHandshakeType { 7 | NONE, ONEWAY, TWOWAY 8 | } -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/enums/Opcode.java: -------------------------------------------------------------------------------- 1 | package org.java_websocket.enums; 2 | 3 | /** 4 | * Enum which contains the different valid opcodes 5 | */ 6 | public enum Opcode { 7 | CONTINUOUS, TEXT, BINARY, PING, PONG, CLOSING 8 | // more to come 9 | } -------------------------------------------------------------------------------- /src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: done-connector 2 | version: '${version}' 3 | main: me.taromati.doneconnector.DoneConnector 4 | api-version: '1.18' 5 | commands: 6 | done: 7 | description: 후원 기능 상태를 변경. 8 | usage: / [on|off|reconnect|reload|add] -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/JSONAware.java: -------------------------------------------------------------------------------- 1 | package org.json.simple; 2 | 3 | /** 4 | * Beans that support customized output of JSON text shall implement this interface. 5 | * @author FangYidong 6 | */ 7 | public interface JSONAware { 8 | /** 9 | * @return JSON text 10 | */ 11 | String toJSONString(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/.svn/text-base/JSONAware.java.svn-base: -------------------------------------------------------------------------------- 1 | package org.json.simple; 2 | 3 | /** 4 | * Beans that support customized output of JSON text shall implement this interface. 5 | * @author FangYidong 6 | */ 7 | public interface JSONAware { 8 | /** 9 | * @return JSON text 10 | */ 11 | String toJSONString(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/enums/HandshakeState.java: -------------------------------------------------------------------------------- 1 | package org.java_websocket.enums; 2 | 3 | /** 4 | * Enum which represents the states a handshake may be in 5 | */ 6 | public enum HandshakeState { 7 | /** 8 | * Handshake matched this Draft successfully 9 | */ 10 | MATCHED, 11 | /** 12 | * Handshake is does not match this Draft 13 | */ 14 | NOT_MATCHED 15 | } -------------------------------------------------------------------------------- /src/main/java/org/json/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 220 5 | http://json-simple.googlecode.com/svn/tags/tag_release_1_1_1/src/main/java/org/json 6 | http://json-simple.googlecode.com/svn 7 | 8 | 9 | 10 | 2009-03-06T08:27:21.608393Z 11 | 170 12 | Dieter.Krachtus 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | b68fe964-5755-0410-a06c-9fee2ea08261 28 | 29 | simple 30 | dir 31 | 32 | -------------------------------------------------------------------------------- /src/main/java/me/taromati/doneconnector/soop/SoopLiveInfo.java: -------------------------------------------------------------------------------- 1 | package me.taromati.doneconnector.soop; 2 | 3 | public record SoopLiveInfo( 4 | String CHDOMAIN, 5 | String CHATNO, 6 | String FTK, 7 | String TITLE, 8 | String BJID, 9 | String BNO, 10 | String CHIP, 11 | String CHPT, 12 | String CTIP, 13 | String CTPT, 14 | String GWIP, 15 | String GWPT 16 | ) {} 17 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/JSONStreamAware.java: -------------------------------------------------------------------------------- 1 | package org.json.simple; 2 | 3 | import java.io.IOException; 4 | import java.io.Writer; 5 | 6 | /** 7 | * Beans that support customized output of JSON text to a writer shall implement this interface. 8 | * @author FangYidong 9 | */ 10 | public interface JSONStreamAware { 11 | /** 12 | * write JSON string to out. 13 | */ 14 | void writeJSONString(Writer out) throws IOException; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/.svn/text-base/JSONStreamAware.java.svn-base: -------------------------------------------------------------------------------- 1 | package org.json.simple; 2 | 3 | import java.io.IOException; 4 | import java.io.Writer; 5 | 6 | /** 7 | * Beans that support customized output of JSON text to a writer shall implement this interface. 8 | * @author FangYidong 9 | */ 10 | public interface JSONStreamAware { 11 | /** 12 | * write JSON string to out. 13 | */ 14 | void writeJSONString(Writer out) throws IOException; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/me/taromati/doneconnector/exception/DoneException.java: -------------------------------------------------------------------------------- 1 | package me.taromati.doneconnector.exception; 2 | 3 | import lombok.Getter; 4 | 5 | @Getter 6 | public class DoneException extends RuntimeException { 7 | private final String code; 8 | private final String message; 9 | 10 | public DoneException(ExceptionCode code) { 11 | super(code.getMessage()); 12 | 13 | this.message = code.getMessage(); 14 | this.code = code.getCode(); 15 | } 16 | 17 | public DoneException(String code, String message) { 18 | super(message); 19 | 20 | this.message = message; 21 | this.code = code; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/me/taromati/doneconnector/soop/ByteUtil.java: -------------------------------------------------------------------------------- 1 | package me.taromati.doneconnector.soop; 2 | 3 | import java.nio.charset.StandardCharsets; 4 | 5 | public class ByteUtil { 6 | private static final byte[] HEX_ARRAY = "0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII); 7 | 8 | public static String bytesToHex(byte[] bytes) { 9 | byte[] hexChars = new byte[bytes.length * 2]; 10 | for (int j = 0; j < bytes.length; j++) { 11 | int v = bytes[j] & 0xFF; 12 | hexChars[j * 2] = HEX_ARRAY[v >>> 4]; 13 | hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F]; 14 | } 15 | return new String(hexChars, StandardCharsets.UTF_8); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/me/taromati/doneconnector/DonationListener.java: -------------------------------------------------------------------------------- 1 | package me.taromati.doneconnector; 2 | 3 | /** 4 | * Interface for handling donation events from different platforms. 5 | */ 6 | public interface DonationListener { 7 | 8 | /** 9 | * Called when a donation is received from any platform. 10 | * 11 | * @param platform The platform name (e.g., "Chzzk", "Soop") 12 | * @param streamerTag The streamer's tag (Minecraft nickname) 13 | * @param donorNickname The donor's nickname 14 | * @param amount The donation amount 15 | * @param message The donation message 16 | */ 17 | void onDonation(String platform, String streamerTag, String donorNickname, int amount, String message); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | 치지직: 2 | 루나핀: 3 | 식별자: affa78deac0b23d2046b8ed4856c1e62 4 | 마크닉네임: lunapin 5 | 숲: 6 | 루나핀: 7 | 식별자: lupin0 8 | 마크닉네임: lunapin 9 | 10 | 랜덤 보상: false 11 | 후원 보상: 12 | 0: 13 | - say 가격을 0원으로 쓰면 설정 안된 가격을 의미합니다. 14 | - say 예를 들어 1000원, 3000원 이외 후원들은 모두 이 명령어가 실행됩니다. 15 | - say 물론 0원을 설정해놓지 않으면 정해놓은 가격 이외 후원은 무시됩니다. 16 | - say 랜덤 보상을 true로 변경 시 정해진 후원내 - 줄중 한개를 실행합니다. 17 | - say 랜덤 보상에서도 여러개를 같이 실행하실려면; say 옆에있는 세미콜론을 이용하여 어러개 작성이 가능합니다. 18 | 1000: 19 | - say %tag% 는 후원받은 스트리머 명을 받아옵니다. 20 | - say %name% 은 후원자 입니다. 21 | - say %amount% 은 후원금액 입니다. 22 | - say %message% 는 후원시 작성한 내용이 포합됩니다. 23 | 3000: 24 | - say bye 25 | - time set 14000 26 | 숲풍선갯수로출력: false 27 | 디버그: false 28 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/parser/ContainerFactory.java: -------------------------------------------------------------------------------- 1 | package org.json.simple.parser; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | /** 7 | * Container factory for creating containers for JSON object and JSON array. 8 | * 9 | * @see org.json.simple.parser.JSONParser#parse(java.io.Reader, ContainerFactory) 10 | * 11 | * @author FangYidong 12 | */ 13 | public interface ContainerFactory { 14 | /** 15 | * @return A Map instance to store JSON object, or null if you want to use org.json.simple.JSONObject. 16 | */ 17 | Map createObjectContainer(); 18 | 19 | /** 20 | * @return A List instance to store JSON array, or null if you want to use org.json.simple.JSONArray. 21 | */ 22 | List creatArrayContainer(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/parser/.svn/text-base/ContainerFactory.java.svn-base: -------------------------------------------------------------------------------- 1 | package org.json.simple.parser; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | /** 7 | * Container factory for creating containers for JSON object and JSON array. 8 | * 9 | * @see org.json.simple.parser.JSONParser#parse(java.io.Reader, ContainerFactory) 10 | * 11 | * @author FangYidong 12 | */ 13 | public interface ContainerFactory { 14 | /** 15 | * @return A Map instance to store JSON object, or null if you want to use org.json.simple.JSONObject. 16 | */ 17 | Map createObjectContainer(); 18 | 19 | /** 20 | * @return A List instance to store JSON array, or null if you want to use org.json.simple.JSONArray. 21 | */ 22 | List creatArrayContainer(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/me/taromati/doneconnector/exception/ExceptionCode.java: -------------------------------------------------------------------------------- 1 | package me.taromati.doneconnector.exception; 2 | 3 | import lombok.Getter; 4 | 5 | @Getter 6 | public enum ExceptionCode { 7 | CONFIG_LOAD_ERROR("CONFIG_LOAD_ERROR", "설정 파일을 불러오는 중 오류가 발생했습니다."),/**/ 8 | ID_NOT_FOUND("ID_NOT_FOUND", "치지직 아이디가 없습니다."),/**/ 9 | REWARD_NOT_FOUND("REWARD_NOT_FOUND", "후원 목록이 없습니다."),/**/ 10 | REWARD_PARSE_ERROR("REWARD_PARSE_ERROR", "후원 목록을 파싱하는 중 오류가 발생했습니다."),/**/ 11 | API_CHAT_CHANNEL_ID_ERROR("API_CHAT_CHANNEL_ID_ERROR", "채널 아이디 조희를 실패했습니다."),/**/ 12 | API_ACCESS_TOKEN_ERROR("API_ACCESS_TOKEN_ERROR", "액세스 토큰을 발급받는 중 오류가 발생했습니다."),/**/ 13 | ; 14 | 15 | private final String code; 16 | 17 | private final String message; 18 | 19 | ExceptionCode(String code, String message) { 20 | this.code = code; 21 | this.message = message; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/me/taromati/doneconnector/logger/Logger.java: -------------------------------------------------------------------------------- 1 | package me.taromati.doneconnector.logger; 2 | 3 | /** 4 | * Logger interface for the DoneConnector plugin. 5 | * This interface defines methods for logging messages at different levels. 6 | */ 7 | public interface Logger { 8 | /** 9 | * Log an informational message. 10 | * @param msg The message to log 11 | */ 12 | void info(String msg); 13 | 14 | /** 15 | * Log a message indicating that a task is done. 16 | * @param msg The message to log 17 | */ 18 | void done(String msg); 19 | 20 | /** 21 | * Log an error message. 22 | * @param msg The message to log 23 | */ 24 | void error(String msg); 25 | 26 | /** 27 | * Log a warning message. 28 | * @param msg The message to log 29 | */ 30 | void warn(String msg); 31 | 32 | /** 33 | * Log a debug message. 34 | * @param msg The message to log 35 | */ 36 | void debug(String msg); 37 | } -------------------------------------------------------------------------------- /src/main/java/me/taromati/doneconnector/soop/SoopPacket.java: -------------------------------------------------------------------------------- 1 | package me.taromati.doneconnector.soop; 2 | 3 | import lombok.Getter; 4 | 5 | import java.time.LocalDateTime; 6 | import java.util.ArrayList; 7 | import java.util.Arrays; 8 | import java.util.List; 9 | 10 | @Getter 11 | public class SoopPacket { 12 | private final String command; 13 | private final List dataList; 14 | 15 | private final LocalDateTime receivedTime = LocalDateTime.now(); 16 | 17 | public SoopPacket(String[] args) { 18 | this.dataList = new ArrayList<>(Arrays.asList(args)); 19 | String cmd = dataList.remove(0); 20 | this.command = cmd.substring(0, 4); 21 | } 22 | 23 | public String toString() { 24 | StringBuilder sb = new StringBuilder(); 25 | 26 | sb.append("Command: ").append(command).append("\n"); 27 | sb.append("Data: "); 28 | 29 | for (String d : dataList) { 30 | sb.append(d).append(" "); 31 | } 32 | 33 | return sb.toString(); 34 | } 35 | } 36 | 37 | 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 taromati 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/exceptions/InvalidEncodingException.java: -------------------------------------------------------------------------------- 1 | package org.java_websocket.exceptions; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | 5 | /** 6 | * The Character Encoding is not supported. 7 | * 8 | * @since 1.4.0 9 | */ 10 | public class InvalidEncodingException extends RuntimeException { 11 | 12 | /** 13 | * attribute for the encoding exception 14 | */ 15 | private final UnsupportedEncodingException encodingException; 16 | 17 | /** 18 | * constructor for InvalidEncodingException 19 | * 20 | * @param encodingException the cause for this exception 21 | */ 22 | public InvalidEncodingException(UnsupportedEncodingException encodingException) { 23 | if (encodingException == null) { 24 | throw new IllegalArgumentException(); 25 | } 26 | this.encodingException = encodingException; 27 | } 28 | 29 | /** 30 | * Get the exception which includes more information on the unsupported encoding 31 | * 32 | * @return an UnsupportedEncodingException 33 | */ 34 | public UnsupportedEncodingException getEncodingException() { 35 | return encodingException; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/me/taromati/doneconnector/logger/LoggerFactory.java: -------------------------------------------------------------------------------- 1 | package me.taromati.doneconnector.logger; 2 | 3 | /** 4 | * Factory class for creating Logger instances. 5 | */ 6 | public class LoggerFactory { 7 | private static Logger defaultLogger = new SystemLogger(false); 8 | 9 | /** 10 | * Get the default logger. 11 | * @return The default logger 12 | */ 13 | public static Logger getLogger() { 14 | return defaultLogger; 15 | } 16 | 17 | /** 18 | * Set the default logger. 19 | * @param logger The logger to set as default 20 | */ 21 | public static void setLogger(Logger logger) { 22 | defaultLogger = logger; 23 | } 24 | 25 | /** 26 | * Create a new BukkitLogger. 27 | * @return A new BukkitLogger 28 | */ 29 | public static Logger createBukkitLogger(boolean enableDebug) { 30 | return new BukkitLogger(enableDebug); 31 | } 32 | 33 | /** 34 | * Create a new SystemLogger. 35 | * @return A new SystemLogger 36 | */ 37 | public static Logger createSystemLogger(boolean enableDebug) { 38 | return new SystemLogger(enableDebug); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 70 4 | /svn/!svn/ver/201/tags/tag_release_1_1_1/src/main/java/org/json/simple 5 | END 6 | JSONObject.java 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 86 10 | /svn/!svn/ver/201/tags/tag_release_1_1_1/src/main/java/org/json/simple/JSONObject.java 11 | END 12 | JSONStreamAware.java 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 91 16 | /svn/!svn/ver/201/tags/tag_release_1_1_1/src/main/java/org/json/simple/JSONStreamAware.java 17 | END 18 | JSONValue.java 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 85 22 | /svn/!svn/ver/201/tags/tag_release_1_1_1/src/main/java/org/json/simple/JSONValue.java 23 | END 24 | JSONArray.java 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 85 28 | /svn/!svn/ver/201/tags/tag_release_1_1_1/src/main/java/org/json/simple/JSONArray.java 29 | END 30 | JSONAware.java 31 | K 25 32 | svn:wc:ra_dav:version-url 33 | V 85 34 | /svn/!svn/ver/201/tags/tag_release_1_1_1/src/main/java/org/json/simple/JSONAware.java 35 | END 36 | ItemList.java 37 | K 25 38 | svn:wc:ra_dav:version-url 39 | V 84 40 | /svn/!svn/ver/201/tags/tag_release_1_1_1/src/main/java/org/json/simple/ItemList.java 41 | END 42 | -------------------------------------------------------------------------------- /src/main/java/me/taromati/doneconnector/SSLUtils.java: -------------------------------------------------------------------------------- 1 | package me.taromati.doneconnector; 2 | 3 | import javax.net.ssl.SSLContext; 4 | import javax.net.ssl.SSLSocketFactory; 5 | import javax.net.ssl.TrustManager; 6 | import javax.net.ssl.X509TrustManager; 7 | import java.security.cert.X509Certificate; 8 | 9 | public class SSLUtils { 10 | public static SSLSocketFactory createSSLSocketFactory() { 11 | try { 12 | SSLContext sslContext = SSLContext.getInstance("TLS"); 13 | sslContext.init(null, new TrustManager[]{new SimpleX509TrustManager()}, null); 14 | return sslContext.getSocketFactory(); 15 | } catch (Exception e) { 16 | throw new RuntimeException(e); 17 | } 18 | } 19 | 20 | private static class SimpleX509TrustManager implements X509TrustManager { 21 | @Override 22 | public void checkClientTrusted(X509Certificate[] certs, String authType) { 23 | } 24 | 25 | @Override 26 | public void checkServerTrusted(X509Certificate[] certs, String authType) { 27 | } 28 | 29 | @Override 30 | public X509Certificate[] getAcceptedIssuers() { 31 | return new X509Certificate[0]; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/parser/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 77 4 | /svn/!svn/ver/201/tags/tag_release_1_1_1/src/main/java/org/json/simple/parser 5 | END 6 | JSONParser.java 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 93 10 | /svn/!svn/ver/201/tags/tag_release_1_1_1/src/main/java/org/json/simple/parser/JSONParser.java 11 | END 12 | ContentHandler.java 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 97 16 | /svn/!svn/ver/201/tags/tag_release_1_1_1/src/main/java/org/json/simple/parser/ContentHandler.java 17 | END 18 | ParseException.java 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 97 22 | /svn/!svn/ver/201/tags/tag_release_1_1_1/src/main/java/org/json/simple/parser/ParseException.java 23 | END 24 | ContainerFactory.java 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 99 28 | /svn/!svn/ver/201/tags/tag_release_1_1_1/src/main/java/org/json/simple/parser/ContainerFactory.java 29 | END 30 | Yylex.java 31 | K 25 32 | svn:wc:ra_dav:version-url 33 | V 88 34 | /svn/!svn/ver/201/tags/tag_release_1_1_1/src/main/java/org/json/simple/parser/Yylex.java 35 | END 36 | Yytoken.java 37 | K 25 38 | svn:wc:ra_dav:version-url 39 | V 90 40 | /svn/!svn/ver/201/tags/tag_release_1_1_1/src/main/java/org/json/simple/parser/Yytoken.java 41 | END 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Minecraft Chzzk / Soop 후원 연동 플러그인 2 | 3 | ## **지원 버전** 4 | Java 버전: 21 이상, 17 5 | 6 | ※ Java 17 버전은 아래 다운로드에서 17버전을 다운받고 파일명에서 -jdk17을 제거 후 사용해주세요. 마인크래프트 1.20.4까지만 공식 지원 됩니다. 7 | 8 | 마인크래프트 서버 버전: Paper 1.18 ~ 1.21.5 9 | 10 | ## **빌드 방법** 11 | 12 | 1. 터미널에서 `gradlew jar` 실행 13 | 14 | ## **다운로드 방법** 15 | 16 | 1. Github(https://github.com/taromati/done-connector) 의 Release 에서 다운로드 17 | - [자바21버전](https://github.com/taromati/done-connector/releases/download/1.8.2/done-connector-1.8.2.jar) 18 | - [자바17버전](https://github.com/taromati/done-connector/releases/download/1.8.2/done-connector-1.8.2-jdk17.jar) 19 | ## **실행 방법** 20 | 21 | 1. plugins 폴더에 done-connector-1.8.2.jar 파일을 넣고 마인크래프트 서버를 1회 실행 후 종료 22 | 2. plugins 폴더에서 done-connector/config.yml 파일 수정 23 | 3. 마인크래프트 서버 실행 24 | 25 | 26 | ## **사용 방법** 27 | 28 | * 플러그인 적용 후 서버 실행시 자동으로 기능 활성화 29 | * `/done [on|off|reconnect|reload|add]` 명령어로 기능 제어 30 | * `/done on` 후원자 연동 기능 활성화 31 | * `/done off` 후원자 연동 기능 비활성화 32 | * `/done reconnect all` 전체 재접속 33 | * `/done reconnect <닉네임>` 해당 닉네임 재접속, 컨피그에서 치지직/숲 바로 아래 단계의 닉네임 혹은 마크닉네임 입력, 자동완성은 마크닉네임만 지원 34 | * `/done reload` 설정 파일 리로드 및 재접속 35 | * `/done add <플랫폼> <방송닉> <방송ID> <마크닉>` 도네연결 임시 추가, reload가 어려운 상황에서 임시로 연결 추가. 서버 재기동시에 없어짐 36 | 37 | ## 1.8.1 추가사항 38 | * config.yml에 `숲풍선갯수로출력: false`을 추가해주세요, true로 할 경우 금액이 아닌 별풍선 갯수로 전달됩니다. 39 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/enums/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all enums. 28 | */ 29 | package org.java_websocket.enums; -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates the utility classes. 28 | */ 29 | package org.java_websocket.util; -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/interfaces/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | */ 26 | 27 | /** 28 | * This package encapsulates all new interfaces. 29 | */ 30 | package org.java_websocket.interfaces; -------------------------------------------------------------------------------- /src/main/java/me/taromati/doneconnector/logger/SystemLogger.java: -------------------------------------------------------------------------------- 1 | package me.taromati.doneconnector.logger; 2 | 3 | public class SystemLogger implements Logger { 4 | private static final String PREFIX = "[TRMT] "; 5 | private static final String INFO_PREFIX = "[INFO] "; 6 | private static final String DONE_PREFIX = "[DONE] "; 7 | private static final String ERROR_PREFIX = "[ERROR] "; 8 | private static final String WARN_PREFIX = "[WARN] "; 9 | private static final String DEBUG_PREFIX = "[DEBUG] "; 10 | 11 | private final boolean enableDebug; 12 | 13 | public SystemLogger(boolean enableDebug) { 14 | this.enableDebug = enableDebug; 15 | } 16 | 17 | @Override 18 | public void info(String msg) { 19 | System.out.println(PREFIX + INFO_PREFIX + msg); 20 | } 21 | 22 | @Override 23 | public void done(String msg) { 24 | System.out.println(PREFIX + DONE_PREFIX + msg); 25 | } 26 | 27 | @Override 28 | public void error(String msg) { 29 | System.out.println(PREFIX + ERROR_PREFIX + msg); 30 | } 31 | 32 | @Override 33 | public void warn(String msg) { 34 | System.out.println(PREFIX + WARN_PREFIX + msg); 35 | } 36 | 37 | @Override 38 | public void debug(String msg) { 39 | if (this.enableDebug) { 40 | System.out.println(PREFIX + DEBUG_PREFIX + msg); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/client/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all implementations in relation with the WebSocketClient. 28 | */ 29 | package org.java_websocket.client; -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/drafts/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all implementations in relation with the WebSocket drafts. 28 | */ 29 | package org.java_websocket.drafts; -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/server/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all implementations in relation with the WebSocketServer. 28 | */ 29 | package org.java_websocket.server; -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/framing/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all interfaces and implementations in relation with the WebSocket 28 | * frames. 29 | */ 30 | package org.java_websocket.framing; -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/exceptions/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all implementations in relation with the exceptions thrown in this 28 | * lib. 29 | */ 30 | package org.java_websocket.exceptions; -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/handshake/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all interfaces and implementations in relation with the WebSocket 28 | * handshake. 29 | */ 30 | package org.java_websocket.handshake; 31 | 32 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/protocols/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all interfaces and implementations in relation with the WebSocket 28 | * Sec-WebSocket-Protocol. 29 | */ 30 | package org.java_websocket.protocols; -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/extensions/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all interfaces and implementations in relation with the WebSocket 28 | * Sec-WebSocket-Extensions. 29 | */ 30 | package org.java_websocket.extensions; -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/framing/PingFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.framing; 27 | 28 | import org.java_websocket.enums.Opcode; 29 | 30 | /** 31 | * Class to represent a ping frame 32 | */ 33 | public class PingFrame extends ControlFrame { 34 | 35 | /** 36 | * constructor which sets the opcode of this frame to ping 37 | */ 38 | public PingFrame() { 39 | super(Opcode.PING); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/framing/BinaryFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.framing; 27 | 28 | import org.java_websocket.enums.Opcode; 29 | 30 | /** 31 | * Class to represent a binary frame 32 | */ 33 | public class BinaryFrame extends DataFrame { 34 | 35 | /** 36 | * constructor which sets the opcode of this frame to binary 37 | */ 38 | public BinaryFrame() { 39 | super(Opcode.BINARY); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/exceptions/WebsocketNotConnectedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.exceptions; 27 | 28 | /** 29 | * exception which indicates the websocket is not yet connected (ReadyState.OPEN) 30 | */ 31 | public class WebsocketNotConnectedException extends RuntimeException { 32 | 33 | /** 34 | * Serializable 35 | */ 36 | private static final long serialVersionUID = -785314021592982715L; 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/framing/ContinuousFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.framing; 27 | 28 | import org.java_websocket.enums.Opcode; 29 | 30 | /** 31 | * Class to represent a continuous frame 32 | */ 33 | public class ContinuousFrame extends DataFrame { 34 | 35 | /** 36 | * constructor which sets the opcode of this frame to continuous 37 | */ 38 | public ContinuousFrame() { 39 | super(Opcode.CONTINUOUS); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/handshake/ClientHandshake.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | /** 29 | * The interface for a client handshake 30 | */ 31 | public interface ClientHandshake extends Handshakedata { 32 | 33 | /** 34 | * returns the HTTP Request-URI as defined by http://tools.ietf.org/html/rfc2616#section-5.1.2 35 | * 36 | * @return the HTTP Request-URI 37 | */ 38 | String getResourceDescriptor(); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/parser/Yytoken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: Yytoken.java,v 1.1 2006/04/15 14:10:48 platform Exp $ 3 | * Created on 2006-4-15 4 | */ 5 | package org.json.simple.parser; 6 | 7 | /** 8 | * @author FangYidong 9 | */ 10 | public class Yytoken { 11 | public static final int TYPE_VALUE=0;//JSON primitive value: string,number,boolean,null 12 | public static final int TYPE_LEFT_BRACE=1; 13 | public static final int TYPE_RIGHT_BRACE=2; 14 | public static final int TYPE_LEFT_SQUARE=3; 15 | public static final int TYPE_RIGHT_SQUARE=4; 16 | public static final int TYPE_COMMA=5; 17 | public static final int TYPE_COLON=6; 18 | public static final int TYPE_EOF=-1;//end of file 19 | 20 | public int type=0; 21 | public Object value=null; 22 | 23 | public Yytoken(int type,Object value){ 24 | this.type=type; 25 | this.value=value; 26 | } 27 | 28 | public String toString(){ 29 | StringBuffer sb = new StringBuffer(); 30 | switch(type){ 31 | case TYPE_VALUE: 32 | sb.append("VALUE(").append(value).append(")"); 33 | break; 34 | case TYPE_LEFT_BRACE: 35 | sb.append("LEFT BRACE({)"); 36 | break; 37 | case TYPE_RIGHT_BRACE: 38 | sb.append("RIGHT BRACE(})"); 39 | break; 40 | case TYPE_LEFT_SQUARE: 41 | sb.append("LEFT SQUARE([)"); 42 | break; 43 | case TYPE_RIGHT_SQUARE: 44 | sb.append("RIGHT SQUARE(])"); 45 | break; 46 | case TYPE_COMMA: 47 | sb.append("COMMA(,)"); 48 | break; 49 | case TYPE_COLON: 50 | sb.append("COLON(:)"); 51 | break; 52 | case TYPE_EOF: 53 | sb.append("END OF FILE"); 54 | break; 55 | } 56 | return sb.toString(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/handshake/ClientHandshakeBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | /** 29 | * The interface for building a handshake for the client 30 | */ 31 | public interface ClientHandshakeBuilder extends HandshakeBuilder, ClientHandshake { 32 | 33 | /** 34 | * Set a specific resource descriptor 35 | * 36 | * @param resourceDescriptor the resource descriptior to set 37 | */ 38 | void setResourceDescriptor(String resourceDescriptor); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/parser/.svn/text-base/Yytoken.java.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: Yytoken.java,v 1.1 2006/04/15 14:10:48 platform Exp $ 3 | * Created on 2006-4-15 4 | */ 5 | package org.json.simple.parser; 6 | 7 | /** 8 | * @author FangYidong 9 | */ 10 | public class Yytoken { 11 | public static final int TYPE_VALUE=0;//JSON primitive value: string,number,boolean,null 12 | public static final int TYPE_LEFT_BRACE=1; 13 | public static final int TYPE_RIGHT_BRACE=2; 14 | public static final int TYPE_LEFT_SQUARE=3; 15 | public static final int TYPE_RIGHT_SQUARE=4; 16 | public static final int TYPE_COMMA=5; 17 | public static final int TYPE_COLON=6; 18 | public static final int TYPE_EOF=-1;//end of file 19 | 20 | public int type=0; 21 | public Object value=null; 22 | 23 | public Yytoken(int type,Object value){ 24 | this.type=type; 25 | this.value=value; 26 | } 27 | 28 | public String toString(){ 29 | StringBuffer sb = new StringBuffer(); 30 | switch(type){ 31 | case TYPE_VALUE: 32 | sb.append("VALUE(").append(value).append(")"); 33 | break; 34 | case TYPE_LEFT_BRACE: 35 | sb.append("LEFT BRACE({)"); 36 | break; 37 | case TYPE_RIGHT_BRACE: 38 | sb.append("RIGHT BRACE(})"); 39 | break; 40 | case TYPE_LEFT_SQUARE: 41 | sb.append("LEFT SQUARE([)"); 42 | break; 43 | case TYPE_RIGHT_SQUARE: 44 | sb.append("RIGHT SQUARE(])"); 45 | break; 46 | case TYPE_COMMA: 47 | sb.append("COMMA(,)"); 48 | break; 49 | case TYPE_COLON: 50 | sb.append("COLON(:)"); 51 | break; 52 | case TYPE_EOF: 53 | sb.append("END OF FILE"); 54 | break; 55 | } 56 | return sb.toString(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/interfaces/ISSLChannel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | */ 26 | 27 | package org.java_websocket.interfaces; 28 | 29 | import javax.net.ssl.SSLEngine; 30 | 31 | /** 32 | * Interface which specifies all required methods a SSLSocketChannel has to make public. 33 | * 34 | * @since 1.4.1 35 | */ 36 | public interface ISSLChannel { 37 | 38 | /** 39 | * Get the ssl engine used for the de- and encryption of the communication. 40 | * 41 | * @return the ssl engine of this channel 42 | */ 43 | SSLEngine getSSLEngine(); 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/handshake/ServerHandshake.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | /** 29 | * Interface for the server handshake 30 | */ 31 | public interface ServerHandshake extends Handshakedata { 32 | 33 | /** 34 | * Get the http status code 35 | * 36 | * @return the http status code 37 | */ 38 | short getHttpStatus(); 39 | 40 | /** 41 | * Get the http status message 42 | * 43 | * @return the http status message 44 | */ 45 | String getHttpStatusMessage(); 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/extensions/ExtensionRequestData.java: -------------------------------------------------------------------------------- 1 | package org.java_websocket.extensions; 2 | 3 | import java.util.LinkedHashMap; 4 | import java.util.Map; 5 | 6 | public class ExtensionRequestData { 7 | 8 | public static final String EMPTY_VALUE = ""; 9 | 10 | private Map extensionParameters; 11 | private String extensionName; 12 | 13 | private ExtensionRequestData() { 14 | extensionParameters = new LinkedHashMap<>(); 15 | } 16 | 17 | public static ExtensionRequestData parseExtensionRequest(String extensionRequest) { 18 | ExtensionRequestData extensionData = new ExtensionRequestData(); 19 | String[] parts = extensionRequest.split(";"); 20 | extensionData.extensionName = parts[0].trim(); 21 | 22 | for (int i = 1; i < parts.length; i++) { 23 | String[] keyValue = parts[i].split("="); 24 | String value = EMPTY_VALUE; 25 | 26 | // Some parameters don't take a value. For those that do, parse the value. 27 | if (keyValue.length > 1) { 28 | String tempValue = keyValue[1].trim(); 29 | 30 | // If the value is wrapped in quotes, just get the data between them. 31 | if ((tempValue.startsWith("\"") && tempValue.endsWith("\"")) 32 | || (tempValue.startsWith("'") && tempValue.endsWith("'")) 33 | && tempValue.length() > 2) { 34 | tempValue = tempValue.substring(1, tempValue.length() - 1); 35 | } 36 | 37 | value = tempValue; 38 | } 39 | 40 | extensionData.extensionParameters.put(keyValue[0].trim(), value); 41 | } 42 | 43 | return extensionData; 44 | } 45 | 46 | public String getExtensionName() { 47 | return extensionName; 48 | } 49 | 50 | public Map getExtensionParameters() { 51 | return extensionParameters; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/handshake/HandshakeBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | /** 29 | * The interface for building a handshake 30 | */ 31 | public interface HandshakeBuilder extends Handshakedata { 32 | 33 | /** 34 | * Setter for the content of the handshake 35 | * 36 | * @param content the content to set 37 | */ 38 | void setContent(byte[] content); 39 | 40 | /** 41 | * Adding a specific field with a specific value 42 | * 43 | * @param name the http field 44 | * @param value the value for this field 45 | */ 46 | void put(String name, String value); 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/handshake/ServerHandshakeBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | /** 29 | * The interface for building a handshake for the server 30 | */ 31 | public interface ServerHandshakeBuilder extends HandshakeBuilder, ServerHandshake { 32 | 33 | /** 34 | * Setter for the http status code 35 | * 36 | * @param status the http status code 37 | */ 38 | void setHttpStatus(short status); 39 | 40 | /** 41 | * Setter for the http status message 42 | * 43 | * @param message the http status message 44 | */ 45 | void setHttpStatusMessage(String message); 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/me/taromati/doneconnector/logger/BukkitLogger.java: -------------------------------------------------------------------------------- 1 | package me.taromati.doneconnector.logger; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.ChatColor; 5 | 6 | public class BukkitLogger implements Logger { 7 | private static final String prefix = ChatColor.AQUA + "[TRMT] "; 8 | private final boolean enableDebug; 9 | 10 | public BukkitLogger(boolean enableDebug) { 11 | this.enableDebug = enableDebug; 12 | } 13 | 14 | @Override 15 | public void info(String msg) { 16 | try { 17 | Bukkit.getConsoleSender().sendMessage(prefix + ChatColor.WHITE + msg); 18 | } catch (Exception ignored) { 19 | // Ignore exceptions 20 | } 21 | } 22 | 23 | @Override 24 | public void done(String msg) { 25 | try { 26 | Bukkit.getConsoleSender().sendMessage(prefix + ChatColor.GREEN + msg); 27 | } catch (Exception ignored) { 28 | // Ignore exceptions 29 | } 30 | } 31 | 32 | @Override 33 | public void error(String msg) { 34 | try { 35 | Bukkit.getConsoleSender().sendMessage(prefix + ChatColor.RED + msg); 36 | } catch (Exception ignored) { 37 | // Ignore exceptions 38 | } 39 | } 40 | 41 | @Override 42 | public void warn(String msg) { 43 | try { 44 | Bukkit.getConsoleSender().sendMessage(prefix + ChatColor.YELLOW + msg); 45 | } catch (Exception ignored) { 46 | // Ignore exceptions 47 | } 48 | } 49 | 50 | @Override 51 | public void debug(String msg) { 52 | if (this.enableDebug) { 53 | try { 54 | Bukkit.getConsoleSender().sendMessage(prefix + ChatColor.LIGHT_PURPLE + msg); 55 | } catch (Exception ignored) { 56 | // Ignore exceptions 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/framing/DataFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.framing; 27 | 28 | import org.java_websocket.enums.Opcode; 29 | import org.java_websocket.exceptions.InvalidDataException; 30 | 31 | /** 32 | * Abstract class to represent data frames 33 | */ 34 | public abstract class DataFrame extends FramedataImpl1 { 35 | 36 | /** 37 | * Class to represent a data frame 38 | * 39 | * @param opcode the opcode to use 40 | */ 41 | public DataFrame(Opcode opcode) { 42 | super(opcode); 43 | } 44 | 45 | @Override 46 | public void isValid() throws InvalidDataException { 47 | //Nothing specific to check 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/framing/PongFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.framing; 27 | 28 | import org.java_websocket.enums.Opcode; 29 | 30 | /** 31 | * Class to represent a pong frame 32 | */ 33 | public class PongFrame extends ControlFrame { 34 | 35 | /** 36 | * constructor which sets the opcode of this frame to pong 37 | */ 38 | public PongFrame() { 39 | super(Opcode.PONG); 40 | } 41 | 42 | /** 43 | * constructor which sets the opcode of this frame to ping copying over the payload of the ping 44 | * 45 | * @param pingFrame the PingFrame which payload is to copy 46 | */ 47 | public PongFrame(PingFrame pingFrame) { 48 | super(Opcode.PONG); 49 | setPayload(pingFrame.getPayloadData()); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/handshake/HandshakeImpl1Client.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | /** 29 | * Implementation for a client handshake 30 | */ 31 | public class HandshakeImpl1Client extends HandshakedataImpl1 implements ClientHandshakeBuilder { 32 | 33 | /** 34 | * Attribute for the resource descriptor 35 | */ 36 | private String resourceDescriptor = "*"; 37 | 38 | @Override 39 | public void setResourceDescriptor(String resourceDescriptor) { 40 | if (resourceDescriptor == null) { 41 | throw new IllegalArgumentException("http resource descriptor must not be null"); 42 | } 43 | this.resourceDescriptor = resourceDescriptor; 44 | } 45 | 46 | @Override 47 | public String getResourceDescriptor() { 48 | return resourceDescriptor; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/framing/TextFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.framing; 27 | 28 | import org.java_websocket.enums.Opcode; 29 | import org.java_websocket.exceptions.InvalidDataException; 30 | import org.java_websocket.util.Charsetfunctions; 31 | 32 | /** 33 | * Class to represent a text frames 34 | */ 35 | public class TextFrame extends DataFrame { 36 | 37 | /** 38 | * constructor which sets the opcode of this frame to text 39 | */ 40 | public TextFrame() { 41 | super(Opcode.TEXT); 42 | } 43 | 44 | @Override 45 | public void isValid() throws InvalidDataException { 46 | super.isValid(); 47 | if (!Charsetfunctions.isValidUTF8(getPayloadData())) { 48 | throw new InvalidDataException(CloseFrame.NO_UTF8, "Received text is no valid utf8 string!"); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/WebSocketFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket; 27 | 28 | import java.util.List; 29 | import org.java_websocket.drafts.Draft; 30 | 31 | public interface WebSocketFactory { 32 | 33 | /** 34 | * Create a new Websocket with the provided listener, drafts and socket 35 | * 36 | * @param a The Listener for the WebsocketImpl 37 | * @param d The draft which should be used 38 | * @return A WebsocketImpl 39 | */ 40 | WebSocket createWebSocket(WebSocketAdapter a, Draft d); 41 | 42 | /** 43 | * Create a new Websocket with the provided listener, drafts and socket 44 | * 45 | * @param a The Listener for the WebsocketImpl 46 | * @param drafts The drafts which should be used 47 | * @return A WebsocketImpl 48 | */ 49 | WebSocket createWebSocket(WebSocketAdapter a, List drafts); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/client/DnsResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.client; 27 | 28 | import java.net.InetAddress; 29 | import java.net.URI; 30 | import java.net.UnknownHostException; 31 | 32 | /** 33 | * Users may implement this interface to override the default DNS lookup offered by the OS. 34 | * 35 | * @since 1.4.1 36 | */ 37 | public interface DnsResolver { 38 | 39 | /** 40 | * Resolves the IP address for the given URI. 41 | *

42 | * This method should never return null. If it's not able to resolve the IP address then it should 43 | * throw an UnknownHostException 44 | * 45 | * @param uri The URI to be resolved 46 | * @return The resolved IP address 47 | * @throws UnknownHostException if no IP address for the uri could be found. 48 | */ 49 | InetAddress resolve(URI uri) throws UnknownHostException; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/handshake/HandshakeImpl1Server.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | /** 29 | * Implementation for a server handshake 30 | */ 31 | public class HandshakeImpl1Server extends HandshakedataImpl1 implements ServerHandshakeBuilder { 32 | 33 | /** 34 | * Attribute for the http status 35 | */ 36 | private short httpstatus; 37 | 38 | /** 39 | * Attribute for the http status message 40 | */ 41 | private String httpstatusmessage; 42 | 43 | @Override 44 | public String getHttpStatusMessage() { 45 | return httpstatusmessage; 46 | } 47 | 48 | @Override 49 | public short getHttpStatus() { 50 | return httpstatus; 51 | } 52 | 53 | @Override 54 | public void setHttpStatusMessage(String message) { 55 | this.httpstatusmessage = message; 56 | } 57 | 58 | @Override 59 | public void setHttpStatus(short status) { 60 | httpstatus = status; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/exceptions/IncompleteException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.exceptions; 27 | 28 | /** 29 | * Exception which indicates that the frame is not yet complete 30 | */ 31 | public class IncompleteException extends Exception { 32 | 33 | /** 34 | * It's Serializable. 35 | */ 36 | private static final long serialVersionUID = 7330519489840500997L; 37 | 38 | /** 39 | * The preferred size 40 | */ 41 | private final int preferredSize; 42 | 43 | /** 44 | * Constructor for the preferred size of a frame 45 | * 46 | * @param preferredSize the preferred size of a frame 47 | */ 48 | public IncompleteException(int preferredSize) { 49 | this.preferredSize = preferredSize; 50 | } 51 | 52 | /** 53 | * Getter for the preferredSize 54 | * 55 | * @return the value of the preferred size 56 | */ 57 | public int getPreferredSize() { 58 | return preferredSize; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/handshake/Handshakedata.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | import java.util.Iterator; 29 | 30 | /** 31 | * The interface for the data of a handshake 32 | */ 33 | public interface Handshakedata { 34 | 35 | /** 36 | * Iterator for the http fields 37 | * 38 | * @return the http fields 39 | */ 40 | Iterator iterateHttpFields(); 41 | 42 | /** 43 | * Gets the value of the field 44 | * 45 | * @param name The name of the field 46 | * @return the value of the field or an empty String if not in the handshake 47 | */ 48 | String getFieldValue(String name); 49 | 50 | /** 51 | * Checks if this handshake contains a specific field 52 | * 53 | * @param name The name of the field 54 | * @return true, if it contains the field 55 | */ 56 | boolean hasFieldValue(String name); 57 | 58 | /** 59 | * Get the content of the handshake 60 | * 61 | * @return the content as byte-array 62 | */ 63 | byte[] getContent(); 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/server/DefaultWebSocketServerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.server; 27 | 28 | import java.nio.channels.SelectionKey; 29 | import java.nio.channels.SocketChannel; 30 | import java.util.List; 31 | import org.java_websocket.WebSocketAdapter; 32 | import org.java_websocket.WebSocketImpl; 33 | import org.java_websocket.WebSocketServerFactory; 34 | import org.java_websocket.drafts.Draft; 35 | 36 | public class DefaultWebSocketServerFactory implements WebSocketServerFactory { 37 | 38 | @Override 39 | public WebSocketImpl createWebSocket(WebSocketAdapter a, Draft d) { 40 | return new WebSocketImpl(a, d); 41 | } 42 | 43 | @Override 44 | public WebSocketImpl createWebSocket(WebSocketAdapter a, List d) { 45 | return new WebSocketImpl(a, d); 46 | } 47 | 48 | @Override 49 | public SocketChannel wrapChannel(SocketChannel channel, SelectionKey key) { 50 | return channel; 51 | } 52 | 53 | @Override 54 | public void close() { 55 | //Nothing to do for a normal ws factory 56 | } 57 | } -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/exceptions/NotSendableException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.exceptions; 27 | 28 | /** 29 | * exception which indicates the frame payload is not sendable 30 | */ 31 | public class NotSendableException extends RuntimeException { 32 | 33 | /** 34 | * Serializable 35 | */ 36 | private static final long serialVersionUID = -6468967874576651628L; 37 | 38 | /** 39 | * constructor for a NotSendableException 40 | * 41 | * @param s the detail message. 42 | */ 43 | public NotSendableException(String s) { 44 | super(s); 45 | } 46 | 47 | /** 48 | * constructor for a NotSendableException 49 | * 50 | * @param t the throwable causing this exception. 51 | */ 52 | public NotSendableException(Throwable t) { 53 | super(t); 54 | } 55 | 56 | /** 57 | * constructor for a NotSendableException 58 | * 59 | * @param s the detail message. 60 | * @param t the throwable causing this exception. 61 | */ 62 | public NotSendableException(String s, Throwable t) { 63 | super(s, t); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/util/NamedThreadFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.util; 27 | 28 | import java.util.concurrent.Executors; 29 | import java.util.concurrent.ThreadFactory; 30 | import java.util.concurrent.atomic.AtomicInteger; 31 | 32 | public class NamedThreadFactory implements ThreadFactory { 33 | 34 | private final ThreadFactory defaultThreadFactory = Executors.defaultThreadFactory(); 35 | private final AtomicInteger threadNumber = new AtomicInteger(1); 36 | private final String threadPrefix; 37 | private final boolean daemon; 38 | 39 | public NamedThreadFactory(String threadPrefix) { 40 | this.threadPrefix = threadPrefix; 41 | this.daemon = false; 42 | } 43 | 44 | public NamedThreadFactory(String threadPrefix, boolean daemon) { 45 | this.threadPrefix = threadPrefix; 46 | this.daemon = daemon; 47 | } 48 | 49 | @Override 50 | public Thread newThread(Runnable runnable) { 51 | Thread thread = defaultThreadFactory.newThread(runnable); 52 | thread.setDaemon(daemon); 53 | thread.setName(threadPrefix + "-" + threadNumber); 54 | return thread; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/framing/ControlFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.framing; 27 | 28 | import org.java_websocket.enums.Opcode; 29 | import org.java_websocket.exceptions.InvalidDataException; 30 | import org.java_websocket.exceptions.InvalidFrameException; 31 | 32 | /** 33 | * Abstract class to represent control frames 34 | */ 35 | public abstract class ControlFrame extends FramedataImpl1 { 36 | 37 | /** 38 | * Class to represent a control frame 39 | * 40 | * @param opcode the opcode to use 41 | */ 42 | public ControlFrame(Opcode opcode) { 43 | super(opcode); 44 | } 45 | 46 | @Override 47 | public void isValid() throws InvalidDataException { 48 | if (!isFin()) { 49 | throw new InvalidFrameException("Control frame can't have fin==false set"); 50 | } 51 | if (isRSV1()) { 52 | throw new InvalidFrameException("Control frame can't have rsv1==true set"); 53 | } 54 | if (isRSV2()) { 55 | throw new InvalidFrameException("Control frame can't have rsv2==true set"); 56 | } 57 | if (isRSV3()) { 58 | throw new InvalidFrameException("Control frame can't have rsv3==true set"); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/exceptions/IncompleteHandshakeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.exceptions; 27 | 28 | /** 29 | * exception which indicates that a incomplete handshake was received 30 | */ 31 | public class IncompleteHandshakeException extends RuntimeException { 32 | 33 | /** 34 | * Serializable 35 | */ 36 | private static final long serialVersionUID = 7906596804233893092L; 37 | 38 | /** 39 | * attribute which size of handshake would have been preferred 40 | */ 41 | private final int preferredSize; 42 | 43 | /** 44 | * constructor for a IncompleteHandshakeException 45 | *

46 | * 47 | * @param preferredSize the preferred size 48 | */ 49 | public IncompleteHandshakeException(int preferredSize) { 50 | this.preferredSize = preferredSize; 51 | } 52 | 53 | /** 54 | * constructor for a IncompleteHandshakeException 55 | *

56 | * preferredSize will be 0 57 | */ 58 | public IncompleteHandshakeException() { 59 | this.preferredSize = 0; 60 | } 61 | 62 | /** 63 | * Getter preferredSize 64 | * 65 | * @return the preferredSize 66 | */ 67 | public int getPreferredSize() { 68 | return preferredSize; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/parser/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 220 5 | http://json-simple.googlecode.com/svn/tags/tag_release_1_1_1/src/main/java/org/json/simple/parser 6 | http://json-simple.googlecode.com/svn 7 | 8 | 9 | 10 | 2009-01-31T13:47:34.868970Z 11 | 93 12 | fangyidong 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | b68fe964-5755-0410-a06c-9fee2ea08261 28 | 29 | JSONParser.java 30 | file 31 | 32 | 33 | 34 | 35 | 2016-01-08T03:57:55.645385Z 36 | 5ce7769d7fc83817f7d29b1ab2492eef 37 | 2009-01-23T06:28:59.905803Z 38 | 89 39 | fangyidong 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 14821 62 | 63 | ContentHandler.java 64 | file 65 | 66 | 67 | 68 | 69 | 2016-01-08T03:57:55.645385Z 70 | 34fddb0345f83acd04ee92ae803fa6f0 71 | 2009-01-31T13:47:34.868970Z 72 | 93 73 | fangyidong 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 3177 96 | 97 | ParseException.java 98 | file 99 | 100 | 101 | 102 | 103 | 2016-01-08T03:57:55.645385Z 104 | 88e9d94b7e82423709f1472348fbdd9d 105 | 2009-01-23T06:28:59.905803Z 106 | 89 107 | fangyidong 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 2567 130 | 131 | ContainerFactory.java 132 | file 133 | 134 | 135 | 136 | 137 | 2016-01-08T03:57:55.645385Z 138 | d5c3d3f9f107086adbbad4c5a3f6b2ff 139 | 2009-01-23T06:28:59.905803Z 140 | 89 141 | fangyidong 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 651 164 | 165 | Yylex.java 166 | file 167 | 168 | 169 | 170 | 171 | 2016-01-08T03:57:55.645385Z 172 | 35e25e450561c66c52f1bcfa0753f087 173 | 2009-01-23T06:28:59.905803Z 174 | 89 175 | fangyidong 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 20546 198 | 199 | Yytoken.java 200 | file 201 | 202 | 203 | 204 | 205 | 2016-01-08T03:57:55.645385Z 206 | 1ca75190ef419ccbebd805a83a3e7b8f 207 | 2009-01-23T06:28:59.905803Z 208 | 89 209 | fangyidong 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 1423 232 | 233 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/util/ByteBufferUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.util; 27 | 28 | import java.nio.ByteBuffer; 29 | 30 | /** 31 | * Utility class for ByteBuffers 32 | */ 33 | public class ByteBufferUtils { 34 | 35 | /** 36 | * Private constructor for static class 37 | */ 38 | private ByteBufferUtils() { 39 | } 40 | 41 | /** 42 | * Transfer from one ByteBuffer to another ByteBuffer 43 | * 44 | * @param source the ByteBuffer to copy from 45 | * @param dest the ByteBuffer to copy to 46 | * @return the number of transferred bytes 47 | */ 48 | public static int transferByteBuffer(ByteBuffer source, ByteBuffer dest) { 49 | if (source == null || dest == null) { 50 | throw new IllegalArgumentException(); 51 | } 52 | int fremain = source.remaining(); 53 | int toremain = dest.remaining(); 54 | if (fremain > toremain) { 55 | int limit = Math.min(fremain, toremain); 56 | source.limit(limit); 57 | dest.put(source); 58 | return limit; 59 | } else { 60 | dest.put(source); 61 | return fremain; 62 | } 63 | } 64 | 65 | /** 66 | * Get a ByteBuffer with zero capacity 67 | * 68 | * @return empty ByteBuffer 69 | */ 70 | public static ByteBuffer getEmptyByteBuffer() { 71 | return ByteBuffer.allocate(0); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 220 5 | http://json-simple.googlecode.com/svn/tags/tag_release_1_1_1/src/main/java/org/json/simple 6 | http://json-simple.googlecode.com/svn 7 | 8 | 9 | 10 | 2009-03-06T08:27:21.608393Z 11 | 170 12 | Dieter.Krachtus 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | b68fe964-5755-0410-a06c-9fee2ea08261 28 | 29 | JSONObject.java 30 | file 31 | 32 | 33 | 34 | 35 | 2016-01-08T03:57:55.645385Z 36 | 17d5e434364d7830a5b24600c1a08c40 37 | 2009-03-06T08:27:21.608393Z 38 | 170 39 | Dieter.Krachtus 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 3809 62 | 63 | JSONStreamAware.java 64 | file 65 | 66 | 67 | 68 | 69 | 2016-01-08T03:57:55.645385Z 70 | b783f0e06cdc7d035d351eea908e4377 71 | 2009-01-23T06:28:59.905803Z 72 | 89 73 | fangyidong 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 378 96 | 97 | JSONValue.java 98 | file 99 | 100 | 101 | 102 | 103 | 2016-01-08T03:57:55.645385Z 104 | 7a6e3ec720d6e2cfd7b42c24ecbeb1b2 105 | 2009-02-01T04:48:01.376086Z 106 | 94 107 | fangyidong 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 6841 130 | 131 | JSONArray.java 132 | file 133 | 134 | 135 | 136 | 137 | 2016-01-08T03:57:55.645385Z 138 | 88f035bc87d77225ff61a58cc78618c9 139 | 2009-01-23T06:28:59.905803Z 140 | 89 141 | fangyidong 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 2605 164 | 165 | JSONAware.java 166 | file 167 | 168 | 169 | 170 | 171 | 2016-01-08T03:57:55.645385Z 172 | d48ad0210f0751578aab9911721cd809 173 | 2009-01-23T06:28:59.905803Z 174 | 89 175 | fangyidong 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 267 198 | 199 | ItemList.java 200 | file 201 | 202 | 203 | 204 | 205 | 2016-01-08T03:57:55.645385Z 206 | 7cd4f5ddb6b0127a4a72781a2db1e182 207 | 2009-01-23T06:28:59.905803Z 208 | 89 209 | fangyidong 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 2683 232 | 233 | parser 234 | dir 235 | 236 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/extensions/CompressionExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.extensions; 27 | 28 | import org.java_websocket.exceptions.InvalidDataException; 29 | import org.java_websocket.exceptions.InvalidFrameException; 30 | import org.java_websocket.framing.ControlFrame; 31 | import org.java_websocket.framing.DataFrame; 32 | import org.java_websocket.framing.Framedata; 33 | 34 | /** 35 | * Implementation for a compression extension specified by https://tools.ietf.org/html/rfc7692 36 | * 37 | * @since 1.3.5 38 | */ 39 | public abstract class CompressionExtension extends DefaultExtension { 40 | 41 | @Override 42 | public void isFrameValid(Framedata inputFrame) throws InvalidDataException { 43 | if ((inputFrame instanceof DataFrame) && (inputFrame.isRSV2() || inputFrame.isRSV3())) { 44 | throw new InvalidFrameException( 45 | "bad rsv RSV1: " + inputFrame.isRSV1() + " RSV2: " + inputFrame.isRSV2() + " RSV3: " 46 | + inputFrame.isRSV3()); 47 | } 48 | if ((inputFrame instanceof ControlFrame) && (inputFrame.isRSV1() || inputFrame.isRSV2() 49 | || inputFrame.isRSV3())) { 50 | throw new InvalidFrameException( 51 | "bad rsv RSV1: " + inputFrame.isRSV1() + " RSV2: " + inputFrame.isRSV2() + " RSV3: " 52 | + inputFrame.isRSV3()); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/WebSocketServerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket; 27 | 28 | import java.io.IOException; 29 | import java.nio.channels.ByteChannel; 30 | import java.nio.channels.SelectionKey; 31 | import java.nio.channels.SocketChannel; 32 | import java.util.List; 33 | import org.java_websocket.drafts.Draft; 34 | 35 | /** 36 | * Interface to encapsulate the required methods for a websocket factory 37 | */ 38 | public interface WebSocketServerFactory extends WebSocketFactory { 39 | 40 | @Override 41 | WebSocketImpl createWebSocket(WebSocketAdapter a, Draft d); 42 | 43 | @Override 44 | WebSocketImpl createWebSocket(WebSocketAdapter a, List drafts); 45 | 46 | /** 47 | * Allows to wrap the SocketChannel( key.channel() ) to insert a protocol layer( like ssl or proxy 48 | * authentication) beyond the ws layer. 49 | * 50 | * @param channel The SocketChannel to wrap 51 | * @param key a SelectionKey of an open SocketChannel. 52 | * @return The channel on which the read and write operations will be performed.
53 | * @throws IOException may be thrown while writing on the channel 54 | */ 55 | ByteChannel wrapChannel(SocketChannel channel, SelectionKey key) throws IOException; 56 | 57 | /** 58 | * Allows to shutdown the websocket factory for a clean shutdown 59 | */ 60 | void close(); 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/exceptions/WrappedIOException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | */ 26 | 27 | package org.java_websocket.exceptions; 28 | 29 | import java.io.IOException; 30 | import org.java_websocket.WebSocket; 31 | 32 | /** 33 | * Exception to wrap an IOException and include information about the websocket which had the 34 | * exception 35 | * 36 | * @since 1.4.1 37 | */ 38 | public class WrappedIOException extends Exception { 39 | 40 | /** 41 | * The websocket where the IOException happened 42 | */ 43 | private final transient WebSocket connection; 44 | 45 | /** 46 | * The IOException 47 | */ 48 | private final IOException ioException; 49 | 50 | /** 51 | * Wrapp an IOException and include the websocket 52 | * 53 | * @param connection the websocket where the IOException happened 54 | * @param ioException the IOException 55 | */ 56 | public WrappedIOException(WebSocket connection, IOException ioException) { 57 | this.connection = connection; 58 | this.ioException = ioException; 59 | } 60 | 61 | /** 62 | * The websocket where the IOException happened 63 | * 64 | * @return the websocket for the wrapped IOException 65 | */ 66 | public WebSocket getConnection() { 67 | return connection; 68 | } 69 | 70 | /** 71 | * The wrapped IOException 72 | * 73 | * @return IOException which is wrapped 74 | */ 75 | public IOException getIOException() { 76 | return ioException; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/handshake/HandshakedataImpl1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | import java.util.Collections; 29 | import java.util.Iterator; 30 | import java.util.TreeMap; 31 | 32 | /** 33 | * Implementation of a handshake builder 34 | */ 35 | public class HandshakedataImpl1 implements HandshakeBuilder { 36 | 37 | /** 38 | * Attribute for the content of the handshake 39 | */ 40 | private byte[] content; 41 | 42 | /** 43 | * Attribute for the http fields and values 44 | */ 45 | private TreeMap map; 46 | 47 | /** 48 | * Constructor for handshake implementation 49 | */ 50 | public HandshakedataImpl1() { 51 | map = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); 52 | } 53 | 54 | @Override 55 | public Iterator iterateHttpFields() { 56 | return Collections.unmodifiableSet(map.keySet()).iterator();// Safety first 57 | } 58 | 59 | @Override 60 | public String getFieldValue(String name) { 61 | String s = map.get(name); 62 | if (s == null) { 63 | return ""; 64 | } 65 | return s; 66 | } 67 | 68 | @Override 69 | public byte[] getContent() { 70 | return content; 71 | } 72 | 73 | @Override 74 | public void setContent(byte[] content) { 75 | this.content = content; 76 | } 77 | 78 | @Override 79 | public void put(String name, String value) { 80 | map.put(name, value); 81 | } 82 | 83 | @Override 84 | public boolean hasFieldValue(String name) { 85 | return map.containsKey(name); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/exceptions/InvalidFrameException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.exceptions; 27 | 28 | import org.java_websocket.framing.CloseFrame; 29 | 30 | /** 31 | * exception which indicates that a invalid frame was received (CloseFrame.PROTOCOL_ERROR) 32 | */ 33 | public class InvalidFrameException extends InvalidDataException { 34 | 35 | /** 36 | * Serializable 37 | */ 38 | private static final long serialVersionUID = -9016496369828887591L; 39 | 40 | /** 41 | * constructor for a InvalidFrameException 42 | *

43 | * calling InvalidDataException with closecode PROTOCOL_ERROR 44 | */ 45 | public InvalidFrameException() { 46 | super(CloseFrame.PROTOCOL_ERROR); 47 | } 48 | 49 | /** 50 | * constructor for a InvalidFrameException 51 | *

52 | * calling InvalidDataException with closecode PROTOCOL_ERROR 53 | * 54 | * @param s the detail message. 55 | */ 56 | public InvalidFrameException(String s) { 57 | super(CloseFrame.PROTOCOL_ERROR, s); 58 | } 59 | 60 | /** 61 | * constructor for a InvalidFrameException 62 | *

63 | * calling InvalidDataException with closecode PROTOCOL_ERROR 64 | * 65 | * @param t the throwable causing this exception. 66 | */ 67 | public InvalidFrameException(Throwable t) { 68 | super(CloseFrame.PROTOCOL_ERROR, t); 69 | } 70 | 71 | /** 72 | * constructor for a InvalidFrameException 73 | *

74 | * calling InvalidDataException with closecode PROTOCOL_ERROR 75 | * 76 | * @param s the detail message. 77 | * @param t the throwable causing this exception. 78 | */ 79 | public InvalidFrameException(String s, Throwable t) { 80 | super(CloseFrame.PROTOCOL_ERROR, s, t); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/WrappedByteChannel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket; 27 | 28 | import java.io.IOException; 29 | import java.nio.ByteBuffer; 30 | import java.nio.channels.ByteChannel; 31 | 32 | public interface WrappedByteChannel extends ByteChannel { 33 | 34 | /** 35 | * returns whether writeMore should be called write additional data. 36 | * 37 | * @return is a additional write needed 38 | */ 39 | boolean isNeedWrite(); 40 | 41 | /** 42 | * Gets called when {@link #isNeedWrite()} ()} requires a additional rite 43 | * 44 | * @throws IOException may be thrown due to an error while writing 45 | */ 46 | void writeMore() throws IOException; 47 | 48 | /** 49 | * returns whether readMore should be called to fetch data which has been decoded but not yet been 50 | * returned. 51 | * 52 | * @return is a additional read needed 53 | * @see #read(ByteBuffer) 54 | * @see #readMore(ByteBuffer) 55 | **/ 56 | boolean isNeedRead(); 57 | 58 | /** 59 | * This function does not read data from the underlying channel at all. It is just a way to fetch 60 | * data which has already be received or decoded but was but was not yet returned to the user. 61 | * This could be the case when the decoded data did not fit into the buffer the user passed to 62 | * {@link #read(ByteBuffer)}. 63 | * 64 | * @param dst the destiny of the read 65 | * @return the amount of remaining data 66 | * @throws IOException when a error occurred during unwrapping 67 | **/ 68 | int readMore(ByteBuffer dst) throws IOException; 69 | 70 | /** 71 | * This function returns the blocking state of the channel 72 | * 73 | * @return is the channel blocking 74 | */ 75 | boolean isBlocking(); 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/parser/ParseException.java: -------------------------------------------------------------------------------- 1 | package org.json.simple.parser; 2 | 3 | /** 4 | * ParseException explains why and where the error occurs in source JSON text. 5 | * 6 | * @author FangYidong 7 | * 8 | */ 9 | public class ParseException extends Exception { 10 | private static final long serialVersionUID = -7880698968187728548L; 11 | 12 | public static final int ERROR_UNEXPECTED_CHAR = 0; 13 | public static final int ERROR_UNEXPECTED_TOKEN = 1; 14 | public static final int ERROR_UNEXPECTED_EXCEPTION = 2; 15 | 16 | private int errorType; 17 | private Object unexpectedObject; 18 | private int position; 19 | 20 | public ParseException(int errorType){ 21 | this(-1, errorType, null); 22 | } 23 | 24 | public ParseException(int errorType, Object unexpectedObject){ 25 | this(-1, errorType, unexpectedObject); 26 | } 27 | 28 | public ParseException(int position, int errorType, Object unexpectedObject){ 29 | this.position = position; 30 | this.errorType = errorType; 31 | this.unexpectedObject = unexpectedObject; 32 | } 33 | 34 | public int getErrorType() { 35 | return errorType; 36 | } 37 | 38 | public void setErrorType(int errorType) { 39 | this.errorType = errorType; 40 | } 41 | 42 | /** 43 | * @see org.json.simple.parser.JSONParser#getPosition() 44 | * 45 | * @return The character position (starting with 0) of the input where the error occurs. 46 | */ 47 | public int getPosition() { 48 | return position; 49 | } 50 | 51 | public void setPosition(int position) { 52 | this.position = position; 53 | } 54 | 55 | /** 56 | * @see org.json.simple.parser.Yytoken 57 | * 58 | * @return One of the following base on the value of errorType: 59 | * ERROR_UNEXPECTED_CHAR java.lang.Character 60 | * ERROR_UNEXPECTED_TOKEN org.json.simple.parser.Yytoken 61 | * ERROR_UNEXPECTED_EXCEPTION java.lang.Exception 62 | */ 63 | public Object getUnexpectedObject() { 64 | return unexpectedObject; 65 | } 66 | 67 | public void setUnexpectedObject(Object unexpectedObject) { 68 | this.unexpectedObject = unexpectedObject; 69 | } 70 | 71 | public String toString(){ 72 | StringBuffer sb = new StringBuffer(); 73 | 74 | switch(errorType){ 75 | case ERROR_UNEXPECTED_CHAR: 76 | sb.append("Unexpected character (").append(unexpectedObject).append(") at position ").append(position).append("."); 77 | break; 78 | case ERROR_UNEXPECTED_TOKEN: 79 | sb.append("Unexpected token ").append(unexpectedObject).append(" at position ").append(position).append("."); 80 | break; 81 | case ERROR_UNEXPECTED_EXCEPTION: 82 | sb.append("Unexpected exception at position ").append(position).append(": ").append(unexpectedObject); 83 | break; 84 | default: 85 | sb.append("Unkown error at position ").append(position).append("."); 86 | break; 87 | } 88 | return sb.toString(); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/protocols/IProtocol.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.protocols; 27 | 28 | /** 29 | * Interface which specifies all required methods for a Sec-WebSocket-Protocol 30 | * 31 | * @since 1.3.7 32 | */ 33 | public interface IProtocol { 34 | 35 | /** 36 | * Check if the received Sec-WebSocket-Protocol header field contains a offer for the specific 37 | * protocol 38 | * 39 | * @param inputProtocolHeader the received Sec-WebSocket-Protocol header field offered by the 40 | * other endpoint 41 | * @return true, if the offer does fit to this specific protocol 42 | * @since 1.3.7 43 | */ 44 | boolean acceptProvidedProtocol(String inputProtocolHeader); 45 | 46 | /** 47 | * Return the specific Sec-WebSocket-protocol header offer for this protocol if the endpoint. If 48 | * the extension returns an empty string (""), the offer will not be included in the handshake. 49 | * 50 | * @return the specific Sec-WebSocket-Protocol header for this protocol 51 | * @since 1.3.7 52 | */ 53 | String getProvidedProtocol(); 54 | 55 | /** 56 | * To prevent protocols to be used more than once the Websocket implementation should call this 57 | * method in order to create a new usable version of a given protocol instance. 58 | * 59 | * @return a copy of the protocol 60 | * @since 1.3.7 61 | */ 62 | IProtocol copyInstance(); 63 | 64 | /** 65 | * Return a string which should contain the protocol name as well as additional information about 66 | * the current configurations for this protocol (DEBUG purposes) 67 | * 68 | * @return a string containing the protocol name as well as additional information 69 | * @since 1.3.7 70 | */ 71 | String toString(); 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/parser/.svn/text-base/ParseException.java.svn-base: -------------------------------------------------------------------------------- 1 | package org.json.simple.parser; 2 | 3 | /** 4 | * ParseException explains why and where the error occurs in source JSON text. 5 | * 6 | * @author FangYidong 7 | * 8 | */ 9 | public class ParseException extends Exception { 10 | private static final long serialVersionUID = -7880698968187728548L; 11 | 12 | public static final int ERROR_UNEXPECTED_CHAR = 0; 13 | public static final int ERROR_UNEXPECTED_TOKEN = 1; 14 | public static final int ERROR_UNEXPECTED_EXCEPTION = 2; 15 | 16 | private int errorType; 17 | private Object unexpectedObject; 18 | private int position; 19 | 20 | public ParseException(int errorType){ 21 | this(-1, errorType, null); 22 | } 23 | 24 | public ParseException(int errorType, Object unexpectedObject){ 25 | this(-1, errorType, unexpectedObject); 26 | } 27 | 28 | public ParseException(int position, int errorType, Object unexpectedObject){ 29 | this.position = position; 30 | this.errorType = errorType; 31 | this.unexpectedObject = unexpectedObject; 32 | } 33 | 34 | public int getErrorType() { 35 | return errorType; 36 | } 37 | 38 | public void setErrorType(int errorType) { 39 | this.errorType = errorType; 40 | } 41 | 42 | /** 43 | * @see org.json.simple.parser.JSONParser#getPosition() 44 | * 45 | * @return The character position (starting with 0) of the input where the error occurs. 46 | */ 47 | public int getPosition() { 48 | return position; 49 | } 50 | 51 | public void setPosition(int position) { 52 | this.position = position; 53 | } 54 | 55 | /** 56 | * @see org.json.simple.parser.Yytoken 57 | * 58 | * @return One of the following base on the value of errorType: 59 | * ERROR_UNEXPECTED_CHAR java.lang.Character 60 | * ERROR_UNEXPECTED_TOKEN org.json.simple.parser.Yytoken 61 | * ERROR_UNEXPECTED_EXCEPTION java.lang.Exception 62 | */ 63 | public Object getUnexpectedObject() { 64 | return unexpectedObject; 65 | } 66 | 67 | public void setUnexpectedObject(Object unexpectedObject) { 68 | this.unexpectedObject = unexpectedObject; 69 | } 70 | 71 | public String toString(){ 72 | StringBuffer sb = new StringBuffer(); 73 | 74 | switch(errorType){ 75 | case ERROR_UNEXPECTED_CHAR: 76 | sb.append("Unexpected character (").append(unexpectedObject).append(") at position ").append(position).append("."); 77 | break; 78 | case ERROR_UNEXPECTED_TOKEN: 79 | sb.append("Unexpected token ").append(unexpectedObject).append(" at position ").append(position).append("."); 80 | break; 81 | case ERROR_UNEXPECTED_EXCEPTION: 82 | sb.append("Unexpected exception at position ").append(position).append(": ").append(unexpectedObject); 83 | break; 84 | default: 85 | sb.append("Unkown error at position ").append(position).append("."); 86 | break; 87 | } 88 | return sb.toString(); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/exceptions/InvalidHandshakeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.exceptions; 27 | 28 | import org.java_websocket.framing.CloseFrame; 29 | 30 | /** 31 | * exception which indicates that a invalid handshake was received (CloseFrame.PROTOCOL_ERROR) 32 | */ 33 | public class InvalidHandshakeException extends InvalidDataException { 34 | 35 | /** 36 | * Serializable 37 | */ 38 | private static final long serialVersionUID = -1426533877490484964L; 39 | 40 | /** 41 | * constructor for a InvalidHandshakeException 42 | *

43 | * calling InvalidDataException with closecode PROTOCOL_ERROR 44 | */ 45 | public InvalidHandshakeException() { 46 | super(CloseFrame.PROTOCOL_ERROR); 47 | } 48 | 49 | /** 50 | * constructor for a InvalidHandshakeException 51 | *

52 | * calling InvalidDataException with closecode PROTOCOL_ERROR 53 | * 54 | * @param s the detail message. 55 | * @param t the throwable causing this exception. 56 | */ 57 | public InvalidHandshakeException(String s, Throwable t) { 58 | super(CloseFrame.PROTOCOL_ERROR, s, t); 59 | } 60 | 61 | /** 62 | * constructor for a InvalidHandshakeException 63 | *

64 | * calling InvalidDataException with closecode PROTOCOL_ERROR 65 | * 66 | * @param s the detail message. 67 | */ 68 | public InvalidHandshakeException(String s) { 69 | super(CloseFrame.PROTOCOL_ERROR, s); 70 | } 71 | 72 | /** 73 | * constructor for a InvalidHandshakeException 74 | *

75 | * calling InvalidDataException with closecode PROTOCOL_ERROR 76 | * 77 | * @param t the throwable causing this exception. 78 | */ 79 | public InvalidHandshakeException(Throwable t) { 80 | super(CloseFrame.PROTOCOL_ERROR, t); 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/framing/Framedata.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.framing; 27 | 28 | import java.nio.ByteBuffer; 29 | import org.java_websocket.enums.Opcode; 30 | 31 | /** 32 | * The interface for the frame 33 | */ 34 | public interface Framedata { 35 | 36 | /** 37 | * Indicates that this is the final fragment in a message. The first fragment MAY also be the 38 | * final fragment. 39 | * 40 | * @return true, if this frame is the final fragment 41 | */ 42 | boolean isFin(); 43 | 44 | /** 45 | * Indicates that this frame has the rsv1 bit set. 46 | * 47 | * @return true, if this frame has the rsv1 bit set 48 | */ 49 | boolean isRSV1(); 50 | 51 | /** 52 | * Indicates that this frame has the rsv2 bit set. 53 | * 54 | * @return true, if this frame has the rsv2 bit set 55 | */ 56 | boolean isRSV2(); 57 | 58 | /** 59 | * Indicates that this frame has the rsv3 bit set. 60 | * 61 | * @return true, if this frame has the rsv3 bit set 62 | */ 63 | boolean isRSV3(); 64 | 65 | /** 66 | * Defines whether the "Payload data" is masked. 67 | * 68 | * @return true, "Payload data" is masked 69 | */ 70 | boolean getTransfereMasked(); 71 | 72 | /** 73 | * Defines the interpretation of the "Payload data". 74 | * 75 | * @return the interpretation as a Opcode 76 | */ 77 | Opcode getOpcode(); 78 | 79 | /** 80 | * The "Payload data" which was sent in this frame 81 | * 82 | * @return the "Payload data" as ByteBuffer 83 | */ 84 | ByteBuffer getPayloadData();// TODO the separation of the application data and the extension data is yet to be done 85 | 86 | /** 87 | * Appends an additional frame to the current frame 88 | *

89 | * This methods does not override the opcode, but does override the fin 90 | * 91 | * @param nextframe the additional frame 92 | */ 93 | void append(Framedata nextframe); 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/JSONArray.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: JSONArray.java,v 1.1 2006/04/15 14:10:48 platform Exp $ 3 | * Created on 2006-4-10 4 | */ 5 | package org.json.simple; 6 | 7 | import java.io.IOException; 8 | import java.io.Writer; 9 | import java.util.ArrayList; 10 | import java.util.Iterator; 11 | import java.util.List; 12 | 13 | 14 | /** 15 | * A JSON array. JSONObject supports java.util.List interface. 16 | * 17 | * @author FangYidong 18 | */ 19 | public class JSONArray extends ArrayList implements List, JSONAware, JSONStreamAware { 20 | private static final long serialVersionUID = 3957988303675231981L; 21 | 22 | /** 23 | * Encode a list into JSON text and write it to out. 24 | * If this list is also a JSONStreamAware or a JSONAware, JSONStreamAware and JSONAware specific behaviours will be ignored at this top level. 25 | * 26 | * @see org.json.simple.JSONValue#writeJSONString(Object, Writer) 27 | * 28 | * @param list 29 | * @param out 30 | */ 31 | public static void writeJSONString(List list, Writer out) throws IOException{ 32 | if(list == null){ 33 | out.write("null"); 34 | return; 35 | } 36 | 37 | boolean first = true; 38 | Iterator iter=list.iterator(); 39 | 40 | out.write('['); 41 | while(iter.hasNext()){ 42 | if(first) 43 | first = false; 44 | else 45 | out.write(','); 46 | 47 | Object value=iter.next(); 48 | if(value == null){ 49 | out.write("null"); 50 | continue; 51 | } 52 | 53 | JSONValue.writeJSONString(value, out); 54 | } 55 | out.write(']'); 56 | } 57 | 58 | public void writeJSONString(Writer out) throws IOException{ 59 | writeJSONString(this, out); 60 | } 61 | 62 | /** 63 | * Convert a list to JSON text. The result is a JSON array. 64 | * If this list is also a JSONAware, JSONAware specific behaviours will be omitted at this top level. 65 | * 66 | * @see org.json.simple.JSONValue#toJSONString(Object) 67 | * 68 | * @param list 69 | * @return JSON text, or "null" if list is null. 70 | */ 71 | public static String toJSONString(List list){ 72 | if(list == null) 73 | return "null"; 74 | 75 | boolean first = true; 76 | StringBuffer sb = new StringBuffer(); 77 | Iterator iter=list.iterator(); 78 | 79 | sb.append('['); 80 | while(iter.hasNext()){ 81 | if(first) 82 | first = false; 83 | else 84 | sb.append(','); 85 | 86 | Object value=iter.next(); 87 | if(value == null){ 88 | sb.append("null"); 89 | continue; 90 | } 91 | sb.append(JSONValue.toJSONString(value)); 92 | } 93 | sb.append(']'); 94 | return sb.toString(); 95 | } 96 | 97 | public String toJSONString(){ 98 | return toJSONString(this); 99 | } 100 | 101 | public String toString() { 102 | return toJSONString(); 103 | } 104 | 105 | 106 | 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/exceptions/InvalidDataException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.exceptions; 27 | 28 | /** 29 | * exception which indicates that a invalid data was received 30 | */ 31 | public class InvalidDataException extends Exception { 32 | 33 | /** 34 | * Serializable 35 | */ 36 | private static final long serialVersionUID = 3731842424390998726L; 37 | 38 | /** 39 | * attribute which closecode will be returned 40 | */ 41 | private final int closecode; 42 | 43 | /** 44 | * constructor for a InvalidDataException 45 | * 46 | * @param closecode the closecode which will be returned 47 | */ 48 | public InvalidDataException(int closecode) { 49 | this.closecode = closecode; 50 | } 51 | 52 | /** 53 | * constructor for a InvalidDataException. 54 | * 55 | * @param closecode the closecode which will be returned. 56 | * @param s the detail message. 57 | */ 58 | public InvalidDataException(int closecode, String s) { 59 | super(s); 60 | this.closecode = closecode; 61 | } 62 | 63 | /** 64 | * constructor for a InvalidDataException. 65 | * 66 | * @param closecode the closecode which will be returned. 67 | * @param t the throwable causing this exception. 68 | */ 69 | public InvalidDataException(int closecode, Throwable t) { 70 | super(t); 71 | this.closecode = closecode; 72 | } 73 | 74 | /** 75 | * constructor for a InvalidDataException. 76 | * 77 | * @param closecode the closecode which will be returned. 78 | * @param s the detail message. 79 | * @param t the throwable causing this exception. 80 | */ 81 | public InvalidDataException(int closecode, String s, Throwable t) { 82 | super(s, t); 83 | this.closecode = closecode; 84 | } 85 | 86 | /** 87 | * Getter closecode 88 | * 89 | * @return the closecode 90 | */ 91 | public int getCloseCode() { 92 | return closecode; 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/.svn/text-base/JSONArray.java.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: JSONArray.java,v 1.1 2006/04/15 14:10:48 platform Exp $ 3 | * Created on 2006-4-10 4 | */ 5 | package org.json.simple; 6 | 7 | import java.io.IOException; 8 | import java.io.Writer; 9 | import java.util.ArrayList; 10 | import java.util.Iterator; 11 | import java.util.List; 12 | 13 | 14 | /** 15 | * A JSON array. JSONObject supports java.util.List interface. 16 | * 17 | * @author FangYidong 18 | */ 19 | public class JSONArray extends ArrayList implements List, JSONAware, JSONStreamAware { 20 | private static final long serialVersionUID = 3957988303675231981L; 21 | 22 | /** 23 | * Encode a list into JSON text and write it to out. 24 | * If this list is also a JSONStreamAware or a JSONAware, JSONStreamAware and JSONAware specific behaviours will be ignored at this top level. 25 | * 26 | * @see org.json.simple.JSONValue#writeJSONString(Object, Writer) 27 | * 28 | * @param list 29 | * @param out 30 | */ 31 | public static void writeJSONString(List list, Writer out) throws IOException{ 32 | if(list == null){ 33 | out.write("null"); 34 | return; 35 | } 36 | 37 | boolean first = true; 38 | Iterator iter=list.iterator(); 39 | 40 | out.write('['); 41 | while(iter.hasNext()){ 42 | if(first) 43 | first = false; 44 | else 45 | out.write(','); 46 | 47 | Object value=iter.next(); 48 | if(value == null){ 49 | out.write("null"); 50 | continue; 51 | } 52 | 53 | JSONValue.writeJSONString(value, out); 54 | } 55 | out.write(']'); 56 | } 57 | 58 | public void writeJSONString(Writer out) throws IOException{ 59 | writeJSONString(this, out); 60 | } 61 | 62 | /** 63 | * Convert a list to JSON text. The result is a JSON array. 64 | * If this list is also a JSONAware, JSONAware specific behaviours will be omitted at this top level. 65 | * 66 | * @see org.json.simple.JSONValue#toJSONString(Object) 67 | * 68 | * @param list 69 | * @return JSON text, or "null" if list is null. 70 | */ 71 | public static String toJSONString(List list){ 72 | if(list == null) 73 | return "null"; 74 | 75 | boolean first = true; 76 | StringBuffer sb = new StringBuffer(); 77 | Iterator iter=list.iterator(); 78 | 79 | sb.append('['); 80 | while(iter.hasNext()){ 81 | if(first) 82 | first = false; 83 | else 84 | sb.append(','); 85 | 86 | Object value=iter.next(); 87 | if(value == null){ 88 | sb.append("null"); 89 | continue; 90 | } 91 | sb.append(JSONValue.toJSONString(value)); 92 | } 93 | sb.append(']'); 94 | return sb.toString(); 95 | } 96 | 97 | public String toJSONString(){ 98 | return toJSONString(this); 99 | } 100 | 101 | public String toString() { 102 | return toJSONString(); 103 | } 104 | 105 | 106 | 107 | } 108 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/exceptions/LimitExceededException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.exceptions; 27 | 28 | import org.java_websocket.framing.CloseFrame; 29 | 30 | /** 31 | * exception which indicates that the message limited was exceeded (CloseFrame.TOOBIG) 32 | */ 33 | public class LimitExceededException extends InvalidDataException { 34 | 35 | /** 36 | * Serializable 37 | */ 38 | private static final long serialVersionUID = 6908339749836826785L; 39 | 40 | /** 41 | * A closer indication about the limit 42 | */ 43 | private final int limit; 44 | 45 | /** 46 | * constructor for a LimitExceededException 47 | *

48 | * calling LimitExceededException with closecode TOOBIG 49 | */ 50 | public LimitExceededException() { 51 | this(Integer.MAX_VALUE); 52 | } 53 | 54 | /** 55 | * constructor for a LimitExceededException 56 | *

57 | * calling InvalidDataException with closecode TOOBIG 58 | * @param limit the allowed size which was not enough 59 | */ 60 | public LimitExceededException(int limit) { 61 | super(CloseFrame.TOOBIG); 62 | this.limit = limit; 63 | } 64 | 65 | /** 66 | * constructor for a LimitExceededException 67 | *

68 | * calling InvalidDataException with closecode TOOBIG 69 | * @param s the detail message. 70 | * @param limit the allowed size which was not enough 71 | */ 72 | public LimitExceededException(String s, int limit) { 73 | super(CloseFrame.TOOBIG, s); 74 | this.limit = limit; 75 | } 76 | 77 | /** 78 | * constructor for a LimitExceededException 79 | *

80 | * calling InvalidDataException with closecode TOOBIG 81 | * 82 | * @param s the detail message. 83 | */ 84 | public LimitExceededException(String s) { 85 | this(s, Integer.MAX_VALUE); 86 | } 87 | 88 | /** 89 | * Get the limit which was hit so this exception was caused 90 | * 91 | * @return the limit as int 92 | */ 93 | public int getLimit() { 94 | return limit; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/me/taromati/doneconnector/Applicaton.java: -------------------------------------------------------------------------------- 1 | //package me.taromati.doneconnector; 2 | // 3 | //import me.taromati.doneconnector.chzzk.ChzzkApi; 4 | //import me.taromati.doneconnector.chzzk.ChzzkWebSocket; 5 | //import me.taromati.doneconnector.logger.LoggerFactory; 6 | //import me.taromati.doneconnector.soop.SoopApi; 7 | //import me.taromati.doneconnector.soop.SoopLiveInfo; 8 | //import me.taromati.doneconnector.soop.SoopWebSocket; 9 | //import org.java_websocket.drafts.Draft_6455; 10 | //import org.java_websocket.protocols.Protocol; 11 | // 12 | //import java.util.Collections; 13 | //import java.util.HashMap; 14 | //import java.util.Map; 15 | //import java.util.concurrent.TimeUnit; 16 | // 17 | //public class Applicaton { 18 | // public static void main(String[] args) throws InterruptedException { 19 | // // Create a simple donation listener for the standalone application 20 | // DonationListener listener = (platform, streamerTag, donorNickname, amount, message) -> System.out.println("[" + platform + " Donation] " + donorNickname + " donated " + amount + " KRW: " + message); 21 | // 22 | // { 23 | // String id = "madaomm"; 24 | // Map user = new HashMap<>(); 25 | // user.put("id", id); 26 | // user.put("nickname", "닉네임"); 27 | // user.put("tag", "마크닉네임"); 28 | // SoopLiveInfo liveInfo = SoopApi.getPlayerLive(id); 29 | // 30 | // Draft_6455 draft6455 = new Draft_6455( 31 | // Collections.emptyList(), 32 | // Collections.singletonList(new Protocol("chat")) 33 | // ); 34 | // 35 | // SoopWebSocket webSocket = new SoopWebSocket( 36 | // "wss://" + liveInfo.CHDOMAIN().toLowerCase() + ":" + liveInfo.CHPT() + "/Websocket/" + liveInfo.BJID(), 37 | // draft6455, 38 | // liveInfo, 39 | // user, 40 | // false, 41 | // LoggerFactory.createSystemLogger(true), 42 | // listener 43 | // ); 44 | // webSocket.connectBlocking(10, TimeUnit.SECONDS); 45 | // } 46 | // 47 | // { 48 | // String id = "45e71a76e949e16a34764deb962f9d9f"; 49 | // Map user = new HashMap<>(); 50 | // user.put("id", id); 51 | // user.put("nickname", "닉네임"); 52 | // user.put("tag", "마크닉네임"); 53 | // 54 | // // 치지직 웹소켓 연결 55 | // String chatChannelId = ChzzkApi.getChatChannelId(id); 56 | // String[] tokens = ChzzkApi.getAccessToken(chatChannelId).split(";"); 57 | // String accessToken = tokens[0]; 58 | // String extraToken = tokens[1]; 59 | // 60 | // ChzzkWebSocket webSocket = new ChzzkWebSocket( 61 | // "wss://kr-ss1.chat.naver.com/chat", 62 | // chatChannelId, 63 | // accessToken, 64 | // extraToken, 65 | // user, 66 | // LoggerFactory.createSystemLogger(true), 67 | // listener 68 | // ); 69 | // webSocket.connect(); 70 | // } 71 | // while (true) { 72 | // Thread.sleep(1000); 73 | // } 74 | // } 75 | //} 76 | -------------------------------------------------------------------------------- /src/main/java/me/taromati/doneconnector/chzzk/ChzzkApi.java: -------------------------------------------------------------------------------- 1 | package me.taromati.doneconnector.chzzk; 2 | 3 | import me.taromati.doneconnector.exception.DoneException; 4 | import me.taromati.doneconnector.exception.ExceptionCode; 5 | import org.json.simple.JSONObject; 6 | import org.json.simple.parser.JSONParser; 7 | 8 | import java.net.URI; 9 | import java.net.http.HttpClient; 10 | import java.net.http.HttpRequest; 11 | import java.net.http.HttpResponse; 12 | 13 | public class ChzzkApi { 14 | public static String getChatChannelId(String id) { 15 | String requestURL = "https://api.chzzk.naver.com/polling/v2/channels/" + id + "/live-status"; 16 | 17 | try { 18 | HttpClient client = HttpClient.newHttpClient(); 19 | HttpRequest request = HttpRequest.newBuilder() 20 | .method("GET", HttpRequest.BodyPublishers.noBody()) 21 | .uri(URI.create(requestURL)) 22 | .header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36") 23 | .build(); // HttpRequest 생성 24 | 25 | 26 | HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); 27 | if (response.statusCode() == 200) { 28 | JSONParser parser = new JSONParser(); 29 | JSONObject jsonObject = (JSONObject) parser.parse(response.body()); 30 | return ((JSONObject)jsonObject.get("content")).get("chatChannelId").toString(); 31 | } else { 32 | throw new DoneException(ExceptionCode.API_CHAT_CHANNEL_ID_ERROR); 33 | } 34 | } catch (Exception e) { 35 | throw new DoneException(ExceptionCode.API_CHAT_CHANNEL_ID_ERROR); 36 | } 37 | } 38 | 39 | // TODO: Cookie를 이용한 API 호출 40 | public static String getAccessToken(String chatChannelId) { 41 | String requestURL = "https://comm-api.game.naver.com/nng_main/v1/chats/access-token?channelId=" + chatChannelId + "&chatType=STREAMING"; 42 | 43 | try { 44 | HttpClient client = HttpClient.newHttpClient(); 45 | HttpRequest request = HttpRequest.newBuilder() 46 | .method("GET", HttpRequest.BodyPublishers.noBody()) 47 | .uri(URI.create(requestURL)) 48 | .header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36") 49 | .build(); // HttpRequest 생성 50 | 51 | HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); 52 | if (response.statusCode() == 200) { 53 | JSONParser parser = new JSONParser(); 54 | JSONObject jsonObject = (JSONObject) parser.parse(response.body()); 55 | String accessToken = ((JSONObject)jsonObject.get("content")).get("accessToken").toString(); 56 | String extraToken = ((JSONObject)jsonObject.get("content")).get("extraToken").toString(); 57 | return accessToken + ";" + extraToken; 58 | } else { 59 | throw new DoneException(ExceptionCode.API_ACCESS_TOKEN_ERROR); 60 | } 61 | } catch (Exception e) { 62 | throw new DoneException(ExceptionCode.API_ACCESS_TOKEN_ERROR); 63 | } 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/ItemList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: ItemList.java,v 1.1 2006/04/15 14:10:48 platform Exp $ 3 | * Created on 2006-3-24 4 | */ 5 | package org.json.simple; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.StringTokenizer; 10 | 11 | /** 12 | * |a:b:c| => |a|,|b|,|c| 13 | * |:| => ||,|| 14 | * |a:| => |a|,|| 15 | * @author FangYidong 16 | */ 17 | public class ItemList { 18 | private String sp=","; 19 | List items=new ArrayList(); 20 | 21 | 22 | public ItemList(){} 23 | 24 | 25 | public ItemList(String s){ 26 | this.split(s,sp,items); 27 | } 28 | 29 | public ItemList(String s,String sp){ 30 | this.sp=s; 31 | this.split(s,sp,items); 32 | } 33 | 34 | public ItemList(String s,String sp,boolean isMultiToken){ 35 | split(s,sp,items,isMultiToken); 36 | } 37 | 38 | public List getItems(){ 39 | return this.items; 40 | } 41 | 42 | public String[] getArray(){ 43 | return (String[])this.items.toArray(); 44 | } 45 | 46 | public void split(String s,String sp,List append,boolean isMultiToken){ 47 | if(s==null || sp==null) 48 | return; 49 | if(isMultiToken){ 50 | StringTokenizer tokens=new StringTokenizer(s,sp); 51 | while(tokens.hasMoreTokens()){ 52 | append.add(tokens.nextToken().trim()); 53 | } 54 | } 55 | else{ 56 | this.split(s,sp,append); 57 | } 58 | } 59 | 60 | public void split(String s,String sp,List append){ 61 | if(s==null || sp==null) 62 | return; 63 | int pos=0; 64 | int prevPos=0; 65 | do{ 66 | prevPos=pos; 67 | pos=s.indexOf(sp,pos); 68 | if(pos==-1) 69 | break; 70 | append.add(s.substring(prevPos,pos).trim()); 71 | pos+=sp.length(); 72 | }while(pos!=-1); 73 | append.add(s.substring(prevPos).trim()); 74 | } 75 | 76 | public void setSP(String sp){ 77 | this.sp=sp; 78 | } 79 | 80 | public void add(int i,String item){ 81 | if(item==null) 82 | return; 83 | items.add(i,item.trim()); 84 | } 85 | 86 | public void add(String item){ 87 | if(item==null) 88 | return; 89 | items.add(item.trim()); 90 | } 91 | 92 | public void addAll(ItemList list){ 93 | items.addAll(list.items); 94 | } 95 | 96 | public void addAll(String s){ 97 | this.split(s,sp,items); 98 | } 99 | 100 | public void addAll(String s,String sp){ 101 | this.split(s,sp,items); 102 | } 103 | 104 | public void addAll(String s,String sp,boolean isMultiToken){ 105 | this.split(s,sp,items,isMultiToken); 106 | } 107 | 108 | /** 109 | * @param i 0-based 110 | * @return 111 | */ 112 | public String get(int i){ 113 | return (String)items.get(i); 114 | } 115 | 116 | public int size(){ 117 | return items.size(); 118 | } 119 | 120 | public String toString(){ 121 | return toString(sp); 122 | } 123 | 124 | public String toString(String sp){ 125 | StringBuffer sb=new StringBuffer(); 126 | 127 | for(int i=0;inull 51 | * @param sslParameters - can not be null 52 | */ 53 | public SSLParametersWebSocketServerFactory(SSLContext sslContext, SSLParameters sslParameters) { 54 | this(sslContext, Executors.newSingleThreadScheduledExecutor(), sslParameters); 55 | } 56 | 57 | /** 58 | * New CustomSSLWebSocketServerFactory configured to only support given protocols and given cipher 59 | * suites. 60 | * 61 | * @param sslContext - can not be null 62 | * @param executerService - can not be null 63 | * @param sslParameters - can not be null 64 | */ 65 | public SSLParametersWebSocketServerFactory(SSLContext sslContext, ExecutorService executerService, 66 | SSLParameters sslParameters) { 67 | super(sslContext, executerService); 68 | if (sslParameters == null) { 69 | throw new IllegalArgumentException(); 70 | } 71 | this.sslParameters = sslParameters; 72 | } 73 | 74 | @Override 75 | public ByteChannel wrapChannel(SocketChannel channel, SelectionKey key) throws IOException { 76 | SSLEngine e = sslcontext.createSSLEngine(); 77 | e.setUseClientMode(false); 78 | e.setSSLParameters(sslParameters); 79 | return new SSLSocketChannel2(channel, e, exec, key); 80 | } 81 | } -------------------------------------------------------------------------------- /src/main/java/org/json/simple/.svn/text-base/ItemList.java.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: ItemList.java,v 1.1 2006/04/15 14:10:48 platform Exp $ 3 | * Created on 2006-3-24 4 | */ 5 | package org.json.simple; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.StringTokenizer; 10 | 11 | /** 12 | * |a:b:c| => |a|,|b|,|c| 13 | * |:| => ||,|| 14 | * |a:| => |a|,|| 15 | * @author FangYidong 16 | */ 17 | public class ItemList { 18 | private String sp=","; 19 | List items=new ArrayList(); 20 | 21 | 22 | public ItemList(){} 23 | 24 | 25 | public ItemList(String s){ 26 | this.split(s,sp,items); 27 | } 28 | 29 | public ItemList(String s,String sp){ 30 | this.sp=s; 31 | this.split(s,sp,items); 32 | } 33 | 34 | public ItemList(String s,String sp,boolean isMultiToken){ 35 | split(s,sp,items,isMultiToken); 36 | } 37 | 38 | public List getItems(){ 39 | return this.items; 40 | } 41 | 42 | public String[] getArray(){ 43 | return (String[])this.items.toArray(); 44 | } 45 | 46 | public void split(String s,String sp,List append,boolean isMultiToken){ 47 | if(s==null || sp==null) 48 | return; 49 | if(isMultiToken){ 50 | StringTokenizer tokens=new StringTokenizer(s,sp); 51 | while(tokens.hasMoreTokens()){ 52 | append.add(tokens.nextToken().trim()); 53 | } 54 | } 55 | else{ 56 | this.split(s,sp,append); 57 | } 58 | } 59 | 60 | public void split(String s,String sp,List append){ 61 | if(s==null || sp==null) 62 | return; 63 | int pos=0; 64 | int prevPos=0; 65 | do{ 66 | prevPos=pos; 67 | pos=s.indexOf(sp,pos); 68 | if(pos==-1) 69 | break; 70 | append.add(s.substring(prevPos,pos).trim()); 71 | pos+=sp.length(); 72 | }while(pos!=-1); 73 | append.add(s.substring(prevPos).trim()); 74 | } 75 | 76 | public void setSP(String sp){ 77 | this.sp=sp; 78 | } 79 | 80 | public void add(int i,String item){ 81 | if(item==null) 82 | return; 83 | items.add(i,item.trim()); 84 | } 85 | 86 | public void add(String item){ 87 | if(item==null) 88 | return; 89 | items.add(item.trim()); 90 | } 91 | 92 | public void addAll(ItemList list){ 93 | items.addAll(list.items); 94 | } 95 | 96 | public void addAll(String s){ 97 | this.split(s,sp,items); 98 | } 99 | 100 | public void addAll(String s,String sp){ 101 | this.split(s,sp,items); 102 | } 103 | 104 | public void addAll(String s,String sp,boolean isMultiToken){ 105 | this.split(s,sp,items,isMultiToken); 106 | } 107 | 108 | /** 109 | * @param i 0-based 110 | * @return 111 | */ 112 | public String get(int i){ 113 | return (String)items.get(i); 114 | } 115 | 116 | public int size(){ 117 | return items.size(); 118 | } 119 | 120 | public String toString(){ 121 | return toString(sp); 122 | } 123 | 124 | public String toString(String sp){ 125 | StringBuffer sb=new StringBuffer(); 126 | 127 | for(int i=0;i 35 | * This is a fallback and will always be available for a Draft_6455 36 | * 37 | * @since 1.3.5 38 | */ 39 | public class DefaultExtension implements IExtension { 40 | 41 | @Override 42 | public void decodeFrame(Framedata inputFrame) throws InvalidDataException { 43 | //Nothing to do here 44 | } 45 | 46 | @Override 47 | public void encodeFrame(Framedata inputFrame) { 48 | //Nothing to do here 49 | } 50 | 51 | @Override 52 | public boolean acceptProvidedExtensionAsServer(String inputExtension) { 53 | return true; 54 | } 55 | 56 | @Override 57 | public boolean acceptProvidedExtensionAsClient(String inputExtension) { 58 | return true; 59 | } 60 | 61 | @Override 62 | public void isFrameValid(Framedata inputFrame) throws InvalidDataException { 63 | if (inputFrame.isRSV1() || inputFrame.isRSV2() || inputFrame.isRSV3()) { 64 | throw new InvalidFrameException( 65 | "bad rsv RSV1: " + inputFrame.isRSV1() + " RSV2: " + inputFrame.isRSV2() + " RSV3: " 66 | + inputFrame.isRSV3()); 67 | } 68 | } 69 | 70 | @Override 71 | public String getProvidedExtensionAsClient() { 72 | return ""; 73 | } 74 | 75 | @Override 76 | public String getProvidedExtensionAsServer() { 77 | return ""; 78 | } 79 | 80 | @Override 81 | public IExtension copyInstance() { 82 | return new DefaultExtension(); 83 | } 84 | 85 | public void reset() { 86 | //Nothing to do here. No internal stats. 87 | } 88 | 89 | @Override 90 | public String toString() { 91 | return getClass().getSimpleName(); 92 | } 93 | 94 | @Override 95 | public int hashCode() { 96 | return getClass().hashCode(); 97 | } 98 | 99 | @Override 100 | public boolean equals(Object o) { 101 | return this == o || o != null && getClass() == o.getClass(); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/AbstractWrappedByteChannel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket; 27 | 28 | import java.io.IOException; 29 | import java.nio.ByteBuffer; 30 | import java.nio.channels.ByteChannel; 31 | import java.nio.channels.SocketChannel; 32 | 33 | /** 34 | * @deprecated 35 | */ 36 | @Deprecated 37 | public class AbstractWrappedByteChannel implements WrappedByteChannel { 38 | 39 | private final ByteChannel channel; 40 | 41 | /** 42 | * @deprecated 43 | */ 44 | @Deprecated 45 | public AbstractWrappedByteChannel(ByteChannel towrap) { 46 | this.channel = towrap; 47 | } 48 | 49 | /** 50 | * @deprecated 51 | */ 52 | @Deprecated 53 | public AbstractWrappedByteChannel(WrappedByteChannel towrap) { 54 | this.channel = towrap; 55 | } 56 | 57 | @Override 58 | public int read(ByteBuffer dst) throws IOException { 59 | return channel.read(dst); 60 | } 61 | 62 | @Override 63 | public boolean isOpen() { 64 | return channel.isOpen(); 65 | } 66 | 67 | @Override 68 | public void close() throws IOException { 69 | channel.close(); 70 | } 71 | 72 | @Override 73 | public int write(ByteBuffer src) throws IOException { 74 | return channel.write(src); 75 | } 76 | 77 | @Override 78 | public boolean isNeedWrite() { 79 | return channel instanceof WrappedByteChannel && ((WrappedByteChannel) channel).isNeedWrite(); 80 | } 81 | 82 | @Override 83 | public void writeMore() throws IOException { 84 | if (channel instanceof WrappedByteChannel) { 85 | ((WrappedByteChannel) channel).writeMore(); 86 | } 87 | 88 | } 89 | 90 | @Override 91 | public boolean isNeedRead() { 92 | return channel instanceof WrappedByteChannel && ((WrappedByteChannel) channel).isNeedRead(); 93 | 94 | } 95 | 96 | @Override 97 | public int readMore(ByteBuffer dst) throws IOException { 98 | return channel instanceof WrappedByteChannel ? ((WrappedByteChannel) channel).readMore(dst) : 0; 99 | } 100 | 101 | @Override 102 | public boolean isBlocking() { 103 | if (channel instanceof SocketChannel) { 104 | return ((SocketChannel) channel).isBlocking(); 105 | } else if (channel instanceof WrappedByteChannel) { 106 | return ((WrappedByteChannel) channel).isBlocking(); 107 | } 108 | return false; 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/parser/ContentHandler.java: -------------------------------------------------------------------------------- 1 | package org.json.simple.parser; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * A simplified and stoppable SAX-like content handler for stream processing of JSON text. 7 | * 8 | * @see org.xml.sax.ContentHandler 9 | * @see org.json.simple.parser.JSONParser#parse(java.io.Reader, ContentHandler, boolean) 10 | * 11 | * @author FangYidong 12 | */ 13 | public interface ContentHandler { 14 | /** 15 | * Receive notification of the beginning of JSON processing. 16 | * The parser will invoke this method only once. 17 | * 18 | * @throws ParseException 19 | * - JSONParser will stop and throw the same exception to the caller when receiving this exception. 20 | */ 21 | void startJSON() throws ParseException, IOException; 22 | 23 | /** 24 | * Receive notification of the end of JSON processing. 25 | * 26 | * @throws ParseException 27 | */ 28 | void endJSON() throws ParseException, IOException; 29 | 30 | /** 31 | * Receive notification of the beginning of a JSON object. 32 | * 33 | * @return false if the handler wants to stop parsing after return. 34 | * @throws ParseException 35 | * - JSONParser will stop and throw the same exception to the caller when receiving this exception. 36 | * @see #endJSON 37 | */ 38 | boolean startObject() throws ParseException, IOException; 39 | 40 | /** 41 | * Receive notification of the end of a JSON object. 42 | * 43 | * @return false if the handler wants to stop parsing after return. 44 | * @throws ParseException 45 | * 46 | * @see #startObject 47 | */ 48 | boolean endObject() throws ParseException, IOException; 49 | 50 | /** 51 | * Receive notification of the beginning of a JSON object entry. 52 | * 53 | * @param key - Key of a JSON object entry. 54 | * 55 | * @return false if the handler wants to stop parsing after return. 56 | * @throws ParseException 57 | * 58 | * @see #endObjectEntry 59 | */ 60 | boolean startObjectEntry(String key) throws ParseException, IOException; 61 | 62 | /** 63 | * Receive notification of the end of the value of previous object entry. 64 | * 65 | * @return false if the handler wants to stop parsing after return. 66 | * @throws ParseException 67 | * 68 | * @see #startObjectEntry 69 | */ 70 | boolean endObjectEntry() throws ParseException, IOException; 71 | 72 | /** 73 | * Receive notification of the beginning of a JSON array. 74 | * 75 | * @return false if the handler wants to stop parsing after return. 76 | * @throws ParseException 77 | * 78 | * @see #endArray 79 | */ 80 | boolean startArray() throws ParseException, IOException; 81 | 82 | /** 83 | * Receive notification of the end of a JSON array. 84 | * 85 | * @return false if the handler wants to stop parsing after return. 86 | * @throws ParseException 87 | * 88 | * @see #startArray 89 | */ 90 | boolean endArray() throws ParseException, IOException; 91 | 92 | /** 93 | * Receive notification of the JSON primitive values: 94 | * java.lang.String, 95 | * java.lang.Number, 96 | * java.lang.Boolean 97 | * null 98 | * 99 | * @param value - Instance of the following: 100 | * java.lang.String, 101 | * java.lang.Number, 102 | * java.lang.Boolean 103 | * null 104 | * 105 | * @return false if the handler wants to stop parsing after return. 106 | * @throws ParseException 107 | */ 108 | boolean primitive(Object value) throws ParseException, IOException; 109 | 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/parser/.svn/text-base/ContentHandler.java.svn-base: -------------------------------------------------------------------------------- 1 | package org.json.simple.parser; 2 | 3 | import java.io.IOException; 4 | 5 | /** 6 | * A simplified and stoppable SAX-like content handler for stream processing of JSON text. 7 | * 8 | * @see org.xml.sax.ContentHandler 9 | * @see org.json.simple.parser.JSONParser#parse(java.io.Reader, ContentHandler, boolean) 10 | * 11 | * @author FangYidong 12 | */ 13 | public interface ContentHandler { 14 | /** 15 | * Receive notification of the beginning of JSON processing. 16 | * The parser will invoke this method only once. 17 | * 18 | * @throws ParseException 19 | * - JSONParser will stop and throw the same exception to the caller when receiving this exception. 20 | */ 21 | void startJSON() throws ParseException, IOException; 22 | 23 | /** 24 | * Receive notification of the end of JSON processing. 25 | * 26 | * @throws ParseException 27 | */ 28 | void endJSON() throws ParseException, IOException; 29 | 30 | /** 31 | * Receive notification of the beginning of a JSON object. 32 | * 33 | * @return false if the handler wants to stop parsing after return. 34 | * @throws ParseException 35 | * - JSONParser will stop and throw the same exception to the caller when receiving this exception. 36 | * @see #endJSON 37 | */ 38 | boolean startObject() throws ParseException, IOException; 39 | 40 | /** 41 | * Receive notification of the end of a JSON object. 42 | * 43 | * @return false if the handler wants to stop parsing after return. 44 | * @throws ParseException 45 | * 46 | * @see #startObject 47 | */ 48 | boolean endObject() throws ParseException, IOException; 49 | 50 | /** 51 | * Receive notification of the beginning of a JSON object entry. 52 | * 53 | * @param key - Key of a JSON object entry. 54 | * 55 | * @return false if the handler wants to stop parsing after return. 56 | * @throws ParseException 57 | * 58 | * @see #endObjectEntry 59 | */ 60 | boolean startObjectEntry(String key) throws ParseException, IOException; 61 | 62 | /** 63 | * Receive notification of the end of the value of previous object entry. 64 | * 65 | * @return false if the handler wants to stop parsing after return. 66 | * @throws ParseException 67 | * 68 | * @see #startObjectEntry 69 | */ 70 | boolean endObjectEntry() throws ParseException, IOException; 71 | 72 | /** 73 | * Receive notification of the beginning of a JSON array. 74 | * 75 | * @return false if the handler wants to stop parsing after return. 76 | * @throws ParseException 77 | * 78 | * @see #endArray 79 | */ 80 | boolean startArray() throws ParseException, IOException; 81 | 82 | /** 83 | * Receive notification of the end of a JSON array. 84 | * 85 | * @return false if the handler wants to stop parsing after return. 86 | * @throws ParseException 87 | * 88 | * @see #startArray 89 | */ 90 | boolean endArray() throws ParseException, IOException; 91 | 92 | /** 93 | * Receive notification of the JSON primitive values: 94 | * java.lang.String, 95 | * java.lang.Number, 96 | * java.lang.Boolean 97 | * null 98 | * 99 | * @param value - Instance of the following: 100 | * java.lang.String, 101 | * java.lang.Number, 102 | * java.lang.Boolean 103 | * null 104 | * 105 | * @return false if the handler wants to stop parsing after return. 106 | * @throws ParseException 107 | */ 108 | boolean primitive(Object value) throws ParseException, IOException; 109 | 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/server/DefaultSSLWebSocketServerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.server; 27 | 28 | import java.io.IOException; 29 | import java.nio.channels.ByteChannel; 30 | import java.nio.channels.SelectionKey; 31 | import java.nio.channels.SocketChannel; 32 | import java.util.ArrayList; 33 | import java.util.Arrays; 34 | import java.util.List; 35 | import java.util.concurrent.ExecutorService; 36 | import java.util.concurrent.Executors; 37 | import javax.net.ssl.SSLContext; 38 | import javax.net.ssl.SSLEngine; 39 | import org.java_websocket.SSLSocketChannel2; 40 | import org.java_websocket.WebSocketAdapter; 41 | import org.java_websocket.WebSocketImpl; 42 | import org.java_websocket.WebSocketServerFactory; 43 | import org.java_websocket.drafts.Draft; 44 | 45 | public class DefaultSSLWebSocketServerFactory implements WebSocketServerFactory { 46 | 47 | protected SSLContext sslcontext; 48 | protected ExecutorService exec; 49 | 50 | public DefaultSSLWebSocketServerFactory(SSLContext sslContext) { 51 | this(sslContext, Executors.newSingleThreadScheduledExecutor()); 52 | } 53 | 54 | public DefaultSSLWebSocketServerFactory(SSLContext sslContext, ExecutorService exec) { 55 | if (sslContext == null || exec == null) { 56 | throw new IllegalArgumentException(); 57 | } 58 | this.sslcontext = sslContext; 59 | this.exec = exec; 60 | } 61 | 62 | @Override 63 | public ByteChannel wrapChannel(SocketChannel channel, SelectionKey key) throws IOException { 64 | SSLEngine e = sslcontext.createSSLEngine(); 65 | /* 66 | * See https://github.com/TooTallNate/Java-WebSocket/issues/466 67 | * 68 | * We remove TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 from the enabled ciphers since it is just available when you patch your java installation directly. 69 | * E.g. firefox requests this cipher and this causes some dcs/instable connections 70 | */ 71 | List ciphers = new ArrayList<>(Arrays.asList(e.getEnabledCipherSuites())); 72 | ciphers.remove("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"); 73 | e.setEnabledCipherSuites(ciphers.toArray(new String[ciphers.size()])); 74 | e.setUseClientMode(false); 75 | return new SSLSocketChannel2(channel, e, exec, key); 76 | } 77 | 78 | @Override 79 | public WebSocketImpl createWebSocket(WebSocketAdapter a, Draft d) { 80 | return new WebSocketImpl(a, d); 81 | } 82 | 83 | @Override 84 | public WebSocketImpl createWebSocket(WebSocketAdapter a, List d) { 85 | return new WebSocketImpl(a, d); 86 | } 87 | 88 | @Override 89 | public void close() { 90 | exec.shutdown(); 91 | } 92 | } -------------------------------------------------------------------------------- /src/main/java/me/taromati/doneconnector/soop/SoopApi.java: -------------------------------------------------------------------------------- 1 | package me.taromati.doneconnector.soop; 2 | 3 | import me.taromati.doneconnector.logger.Logger; 4 | import me.taromati.doneconnector.logger.LoggerFactory; 5 | import me.taromati.doneconnector.exception.DoneException; 6 | import me.taromati.doneconnector.exception.ExceptionCode; 7 | import org.json.simple.JSONObject; 8 | import org.json.simple.parser.JSONParser; 9 | 10 | import java.net.URI; 11 | import java.net.URLEncoder; 12 | import java.net.http.HttpClient; 13 | import java.net.http.HttpRequest; 14 | import java.net.http.HttpResponse; 15 | import java.nio.charset.StandardCharsets; 16 | import java.util.Map; 17 | 18 | public class SoopApi { 19 | public static SoopLiveInfo getPlayerLive(String bjid) { 20 | return getPlayerLive(bjid, LoggerFactory.getLogger()); 21 | } 22 | 23 | public static SoopLiveInfo getPlayerLive(String bjid, Logger logger) { 24 | String requestURL = String.format("https://live.sooplive.co.kr/afreeca/player_live_api.php?bjid=%s", bjid); 25 | 26 | try { 27 | HttpClient client = HttpClient.newHttpClient(); 28 | JSONObject bodyJson = new JSONObject(); 29 | bodyJson.put("bid", bjid); 30 | bodyJson.put("type", "live"); 31 | bodyJson.put("pwd", ""); 32 | bodyJson.put("player_type", "html5"); 33 | bodyJson.put("stream_type", "common"); 34 | bodyJson.put("quality", "HD"); 35 | bodyJson.put("mode", "landing"); 36 | bodyJson.put("is_revive", "false"); 37 | bodyJson.put("from_api", "0"); 38 | 39 | logger.debug("Request URL: " + requestURL + "\n" + "Request Body: " + bodyJson.toJSONString()); 40 | 41 | HttpRequest request = HttpRequest.newBuilder() 42 | .POST(ofFormData(bodyJson)) 43 | .uri(URI.create(requestURL)) 44 | .header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36") 45 | .header("Content-Type", "application/x-www-form-urlencoded") 46 | .build(); // HttpRequest 생성 47 | 48 | 49 | HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); 50 | 51 | if (response.statusCode() == 200) { 52 | JSONParser parser = new JSONParser(); 53 | JSONObject jsonObject = (JSONObject) parser.parse(response.body()); 54 | JSONObject channel = (JSONObject) jsonObject.get("CHANNEL"); 55 | SoopLiveInfo soopLiveInfo = new SoopLiveInfo( 56 | channel.get("CHDOMAIN").toString(), 57 | channel.get("CHATNO").toString(), 58 | channel.get("FTK").toString(), 59 | channel.get("TITLE").toString(), 60 | channel.get("BJID").toString(), 61 | channel.get("BNO").toString(), 62 | channel.get("CHIP").toString(), 63 | String.valueOf(Integer.parseInt(channel.get("CHPT").toString()) + 1), 64 | channel.get("CTIP").toString(), 65 | channel.get("CTPT").toString(), 66 | channel.get("GWIP").toString(), 67 | channel.get("GWPT").toString() 68 | ); 69 | 70 | logger.debug(soopLiveInfo.toString()); 71 | 72 | return soopLiveInfo; 73 | } else { 74 | throw new DoneException(ExceptionCode.API_CHAT_CHANNEL_ID_ERROR); 75 | } 76 | } catch (Exception e) { 77 | throw new DoneException(ExceptionCode.API_CHAT_CHANNEL_ID_ERROR); 78 | } 79 | } 80 | 81 | public static HttpRequest.BodyPublisher ofFormData(Map data) { 82 | var builder = new StringBuilder(); 83 | 84 | for (Map.Entry entry : data.entrySet()) { 85 | if (builder.length() > 0) { 86 | builder.append("&"); 87 | } 88 | 89 | builder.append(URLEncoder.encode(entry.getKey().toString(), StandardCharsets.UTF_8)); 90 | builder.append("="); 91 | builder.append(URLEncoder.encode(entry.getValue().toString(), StandardCharsets.UTF_8)); 92 | } 93 | 94 | return HttpRequest.BodyPublishers.ofString(builder.toString()); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/SocketChannelIOHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket; 27 | 28 | import java.io.IOException; 29 | import java.nio.ByteBuffer; 30 | import java.nio.channels.ByteChannel; 31 | import org.java_websocket.enums.Role; 32 | 33 | public class SocketChannelIOHelper { 34 | 35 | private SocketChannelIOHelper() { 36 | throw new IllegalStateException("Utility class"); 37 | } 38 | 39 | public static boolean read(final ByteBuffer buf, WebSocketImpl ws, ByteChannel channel) 40 | throws IOException { 41 | buf.clear(); 42 | int read = channel.read(buf); 43 | buf.flip(); 44 | 45 | if (read == -1) { 46 | ws.eot(); 47 | return false; 48 | } 49 | return read != 0; 50 | } 51 | 52 | /** 53 | * @param buf The ByteBuffer to read from 54 | * @param ws The WebSocketImpl associated with the channels 55 | * @param channel The channel to read from 56 | * @return returns Whether there is more data left which can be obtained via {@link 57 | * WrappedByteChannel#readMore(ByteBuffer)} 58 | * @throws IOException May be thrown by {@link WrappedByteChannel#readMore(ByteBuffer)}# 59 | * @see WrappedByteChannel#readMore(ByteBuffer) 60 | **/ 61 | public static boolean readMore(final ByteBuffer buf, WebSocketImpl ws, WrappedByteChannel channel) 62 | throws IOException { 63 | buf.clear(); 64 | int read = channel.readMore(buf); 65 | buf.flip(); 66 | 67 | if (read == -1) { 68 | ws.eot(); 69 | return false; 70 | } 71 | return channel.isNeedRead(); 72 | } 73 | 74 | /** 75 | * Returns whether the whole outQueue has been flushed 76 | * 77 | * @param ws The WebSocketImpl associated with the channels 78 | * @param sockchannel The channel to write to 79 | * @return returns Whether there is more data to write 80 | * @throws IOException May be thrown by {@link WrappedByteChannel#writeMore()} 81 | */ 82 | public static boolean batch(WebSocketImpl ws, ByteChannel sockchannel) throws IOException { 83 | if (ws == null) { 84 | return false; 85 | } 86 | ByteBuffer buffer = ws.outQueue.peek(); 87 | WrappedByteChannel c = null; 88 | 89 | if (buffer == null) { 90 | if (sockchannel instanceof WrappedByteChannel) { 91 | c = (WrappedByteChannel) sockchannel; 92 | if (c.isNeedWrite()) { 93 | c.writeMore(); 94 | } 95 | } 96 | } else { 97 | do { 98 | // FIXME writing as much as possible is unfair!! 99 | /*int written = */ 100 | sockchannel.write(buffer); 101 | if (buffer.remaining() > 0) { 102 | return false; 103 | } else { 104 | ws.outQueue.poll(); // Buffer finished. Remove it. 105 | buffer = ws.outQueue.peek(); 106 | } 107 | } while (buffer != null); 108 | } 109 | 110 | if (ws.outQueue.isEmpty() && ws.isFlushAndClose() && ws.getDraft() != null 111 | && ws.getDraft().getRole() != null && ws.getDraft().getRole() == Role.SERVER) { 112 | ws.closeConnection(); 113 | } 114 | return c == null || !((WrappedByteChannel) sockchannel).isNeedWrite(); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/server/CustomSSLWebSocketServerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.server; 27 | 28 | import java.io.IOException; 29 | import java.nio.channels.ByteChannel; 30 | import java.nio.channels.SelectionKey; 31 | import java.nio.channels.SocketChannel; 32 | import java.util.concurrent.ExecutorService; 33 | import java.util.concurrent.Executors; 34 | import javax.net.ssl.SSLContext; 35 | import javax.net.ssl.SSLEngine; 36 | import org.java_websocket.SSLSocketChannel2; 37 | 38 | /** 39 | * WebSocketFactory that can be configured to only support specific protocols and cipher suites. 40 | */ 41 | public class CustomSSLWebSocketServerFactory extends DefaultSSLWebSocketServerFactory { 42 | 43 | /** 44 | * The enabled protocols saved as a String array 45 | */ 46 | private final String[] enabledProtocols; 47 | 48 | /** 49 | * The enabled ciphersuites saved as a String array 50 | */ 51 | private final String[] enabledCiphersuites; 52 | 53 | /** 54 | * New CustomSSLWebSocketServerFactory configured to only support given protocols and given cipher 55 | * suites. 56 | * 57 | * @param sslContext - can not be null 58 | * @param enabledProtocols - only these protocols are enabled, when null default 59 | * settings will be used. 60 | * @param enabledCiphersuites - only these cipher suites are enabled, when null 61 | * default settings will be used. 62 | */ 63 | public CustomSSLWebSocketServerFactory(SSLContext sslContext, String[] enabledProtocols, 64 | String[] enabledCiphersuites) { 65 | this(sslContext, Executors.newSingleThreadScheduledExecutor(), enabledProtocols, 66 | enabledCiphersuites); 67 | } 68 | 69 | /** 70 | * New CustomSSLWebSocketServerFactory configured to only support given protocols and given cipher 71 | * suites. 72 | * 73 | * @param sslContext - can not be null 74 | * @param executerService - can not be null 75 | * @param enabledProtocols - only these protocols are enabled, when null default 76 | * settings will be used. 77 | * @param enabledCiphersuites - only these cipher suites are enabled, when null 78 | * default settings will be used. 79 | */ 80 | public CustomSSLWebSocketServerFactory(SSLContext sslContext, ExecutorService executerService, 81 | String[] enabledProtocols, String[] enabledCiphersuites) { 82 | super(sslContext, executerService); 83 | this.enabledProtocols = enabledProtocols; 84 | this.enabledCiphersuites = enabledCiphersuites; 85 | } 86 | 87 | @Override 88 | public ByteChannel wrapChannel(SocketChannel channel, SelectionKey key) throws IOException { 89 | SSLEngine e = sslcontext.createSSLEngine(); 90 | if (enabledProtocols != null) { 91 | e.setEnabledProtocols(enabledProtocols); 92 | } 93 | if (enabledCiphersuites != null) { 94 | e.setEnabledCipherSuites(enabledCiphersuites); 95 | } 96 | e.setUseClientMode(false); 97 | return new SSLSocketChannel2(channel, e, exec, key); 98 | } 99 | 100 | } -------------------------------------------------------------------------------- /src/main/java/org/json/simple/JSONObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: JSONObject.java,v 1.1 2006/04/15 14:10:48 platform Exp $ 3 | * Created on 2006-4-10 4 | */ 5 | package org.json.simple; 6 | 7 | import java.io.IOException; 8 | import java.io.Writer; 9 | import java.util.HashMap; 10 | import java.util.Iterator; 11 | import java.util.Map; 12 | 13 | /** 14 | * A JSON object. Key value pairs are unordered. JSONObject supports java.util.Map interface. 15 | * 16 | * @author FangYidong 17 | */ 18 | public class JSONObject extends HashMap implements Map, JSONAware, JSONStreamAware{ 19 | 20 | private static final long serialVersionUID = -503443796854799292L; 21 | 22 | 23 | public JSONObject() { 24 | super(); 25 | } 26 | 27 | /** 28 | * Allows creation of a JSONObject from a Map. After that, both the 29 | * generated JSONObject and the Map can be modified independently. 30 | * 31 | * @param map 32 | */ 33 | public JSONObject(Map map) { 34 | super(map); 35 | } 36 | 37 | 38 | /** 39 | * Encode a map into JSON text and write it to out. 40 | * If this map is also a JSONAware or JSONStreamAware, JSONAware or JSONStreamAware specific behaviours will be ignored at this top level. 41 | * 42 | * @see org.json.simple.JSONValue#writeJSONString(Object, Writer) 43 | * 44 | * @param map 45 | * @param out 46 | */ 47 | public static void writeJSONString(Map map, Writer out) throws IOException { 48 | if(map == null){ 49 | out.write("null"); 50 | return; 51 | } 52 | 53 | boolean first = true; 54 | Iterator iter=map.entrySet().iterator(); 55 | 56 | out.write('{'); 57 | while(iter.hasNext()){ 58 | if(first) 59 | first = false; 60 | else 61 | out.write(','); 62 | Map.Entry entry=(Map.Entry)iter.next(); 63 | out.write('\"'); 64 | out.write(escape(String.valueOf(entry.getKey()))); 65 | out.write('\"'); 66 | out.write(':'); 67 | JSONValue.writeJSONString(entry.getValue(), out); 68 | } 69 | out.write('}'); 70 | } 71 | 72 | public void writeJSONString(Writer out) throws IOException{ 73 | writeJSONString(this, out); 74 | } 75 | 76 | /** 77 | * Convert a map to JSON text. The result is a JSON object. 78 | * If this map is also a JSONAware, JSONAware specific behaviours will be omitted at this top level. 79 | * 80 | * @see org.json.simple.JSONValue#toJSONString(Object) 81 | * 82 | * @param map 83 | * @return JSON text, or "null" if map is null. 84 | */ 85 | public static String toJSONString(Map map){ 86 | if(map == null) 87 | return "null"; 88 | 89 | StringBuffer sb = new StringBuffer(); 90 | boolean first = true; 91 | Iterator iter=map.entrySet().iterator(); 92 | 93 | sb.append('{'); 94 | while(iter.hasNext()){ 95 | if(first) 96 | first = false; 97 | else 98 | sb.append(','); 99 | 100 | Map.Entry entry=(Map.Entry)iter.next(); 101 | toJSONString(String.valueOf(entry.getKey()),entry.getValue(), sb); 102 | } 103 | sb.append('}'); 104 | return sb.toString(); 105 | } 106 | 107 | public String toJSONString(){ 108 | return toJSONString(this); 109 | } 110 | 111 | private static String toJSONString(String key,Object value, StringBuffer sb){ 112 | sb.append('\"'); 113 | if(key == null) 114 | sb.append("null"); 115 | else 116 | JSONValue.escape(key, sb); 117 | sb.append('\"').append(':'); 118 | 119 | sb.append(JSONValue.toJSONString(value)); 120 | 121 | return sb.toString(); 122 | } 123 | 124 | public String toString(){ 125 | return toJSONString(); 126 | } 127 | 128 | public static String toString(String key,Object value){ 129 | StringBuffer sb = new StringBuffer(); 130 | toJSONString(key, value, sb); 131 | return sb.toString(); 132 | } 133 | 134 | /** 135 | * Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F). 136 | * It's the same as JSONValue.escape() only for compatibility here. 137 | * 138 | * @see org.json.simple.JSONValue#escape(String) 139 | * 140 | * @param s 141 | * @return 142 | */ 143 | public static String escape(String s){ 144 | return JSONValue.escape(s); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /src/main/java/org/json/simple/.svn/text-base/JSONObject.java.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: JSONObject.java,v 1.1 2006/04/15 14:10:48 platform Exp $ 3 | * Created on 2006-4-10 4 | */ 5 | package org.json.simple; 6 | 7 | import java.io.IOException; 8 | import java.io.Writer; 9 | import java.util.HashMap; 10 | import java.util.Iterator; 11 | import java.util.Map; 12 | 13 | /** 14 | * A JSON object. Key value pairs are unordered. JSONObject supports java.util.Map interface. 15 | * 16 | * @author FangYidong 17 | */ 18 | public class JSONObject extends HashMap implements Map, JSONAware, JSONStreamAware{ 19 | 20 | private static final long serialVersionUID = -503443796854799292L; 21 | 22 | 23 | public JSONObject() { 24 | super(); 25 | } 26 | 27 | /** 28 | * Allows creation of a JSONObject from a Map. After that, both the 29 | * generated JSONObject and the Map can be modified independently. 30 | * 31 | * @param map 32 | */ 33 | public JSONObject(Map map) { 34 | super(map); 35 | } 36 | 37 | 38 | /** 39 | * Encode a map into JSON text and write it to out. 40 | * If this map is also a JSONAware or JSONStreamAware, JSONAware or JSONStreamAware specific behaviours will be ignored at this top level. 41 | * 42 | * @see org.json.simple.JSONValue#writeJSONString(Object, Writer) 43 | * 44 | * @param map 45 | * @param out 46 | */ 47 | public static void writeJSONString(Map map, Writer out) throws IOException { 48 | if(map == null){ 49 | out.write("null"); 50 | return; 51 | } 52 | 53 | boolean first = true; 54 | Iterator iter=map.entrySet().iterator(); 55 | 56 | out.write('{'); 57 | while(iter.hasNext()){ 58 | if(first) 59 | first = false; 60 | else 61 | out.write(','); 62 | Map.Entry entry=(Map.Entry)iter.next(); 63 | out.write('\"'); 64 | out.write(escape(String.valueOf(entry.getKey()))); 65 | out.write('\"'); 66 | out.write(':'); 67 | JSONValue.writeJSONString(entry.getValue(), out); 68 | } 69 | out.write('}'); 70 | } 71 | 72 | public void writeJSONString(Writer out) throws IOException{ 73 | writeJSONString(this, out); 74 | } 75 | 76 | /** 77 | * Convert a map to JSON text. The result is a JSON object. 78 | * If this map is also a JSONAware, JSONAware specific behaviours will be omitted at this top level. 79 | * 80 | * @see org.json.simple.JSONValue#toJSONString(Object) 81 | * 82 | * @param map 83 | * @return JSON text, or "null" if map is null. 84 | */ 85 | public static String toJSONString(Map map){ 86 | if(map == null) 87 | return "null"; 88 | 89 | StringBuffer sb = new StringBuffer(); 90 | boolean first = true; 91 | Iterator iter=map.entrySet().iterator(); 92 | 93 | sb.append('{'); 94 | while(iter.hasNext()){ 95 | if(first) 96 | first = false; 97 | else 98 | sb.append(','); 99 | 100 | Map.Entry entry=(Map.Entry)iter.next(); 101 | toJSONString(String.valueOf(entry.getKey()),entry.getValue(), sb); 102 | } 103 | sb.append('}'); 104 | return sb.toString(); 105 | } 106 | 107 | public String toJSONString(){ 108 | return toJSONString(this); 109 | } 110 | 111 | private static String toJSONString(String key,Object value, StringBuffer sb){ 112 | sb.append('\"'); 113 | if(key == null) 114 | sb.append("null"); 115 | else 116 | JSONValue.escape(key, sb); 117 | sb.append('\"').append(':'); 118 | 119 | sb.append(JSONValue.toJSONString(value)); 120 | 121 | return sb.toString(); 122 | } 123 | 124 | public String toString(){ 125 | return toJSONString(); 126 | } 127 | 128 | public static String toString(String key,Object value){ 129 | StringBuffer sb = new StringBuffer(); 130 | toJSONString(key, value, sb); 131 | return sb.toString(); 132 | } 133 | 134 | /** 135 | * Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F). 136 | * It's the same as JSONValue.escape() only for compatibility here. 137 | * 138 | * @see org.json.simple.JSONValue#escape(String) 139 | * 140 | * @param s 141 | * @return 142 | */ 143 | public static String escape(String s){ 144 | return JSONValue.escape(s); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /src/main/java/org/java_websocket/WebSocketAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2020 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket; 27 | 28 | import org.java_websocket.drafts.Draft; 29 | import org.java_websocket.exceptions.InvalidDataException; 30 | import org.java_websocket.framing.Framedata; 31 | import org.java_websocket.framing.PingFrame; 32 | import org.java_websocket.framing.PongFrame; 33 | import org.java_websocket.handshake.ClientHandshake; 34 | import org.java_websocket.handshake.HandshakeImpl1Server; 35 | import org.java_websocket.handshake.ServerHandshake; 36 | import org.java_websocket.handshake.ServerHandshakeBuilder; 37 | 38 | /** 39 | * This class default implements all methods of the WebSocketListener that can be overridden 40 | * optionally when advances functionalities is needed.
41 | **/ 42 | public abstract class WebSocketAdapter implements WebSocketListener { 43 | 44 | private PingFrame pingFrame; 45 | 46 | /** 47 | * This default implementation does not do anything. Go ahead and overwrite it. 48 | * 49 | * @see org.java_websocket.WebSocketListener#onWebsocketHandshakeReceivedAsServer(WebSocket, 50 | * Draft, ClientHandshake) 51 | */ 52 | @Override 53 | public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer(WebSocket conn, Draft draft, 54 | ClientHandshake request) throws InvalidDataException { 55 | return new HandshakeImpl1Server(); 56 | } 57 | 58 | @Override 59 | public void onWebsocketHandshakeReceivedAsClient(WebSocket conn, ClientHandshake request, 60 | ServerHandshake response) throws InvalidDataException { 61 | //To overwrite 62 | } 63 | 64 | /** 65 | * This default implementation does not do anything which will cause the connections to always 66 | * progress. 67 | * 68 | * @see org.java_websocket.WebSocketListener#onWebsocketHandshakeSentAsClient(WebSocket, 69 | * ClientHandshake) 70 | */ 71 | @Override 72 | public void onWebsocketHandshakeSentAsClient(WebSocket conn, ClientHandshake request) 73 | throws InvalidDataException { 74 | //To overwrite 75 | } 76 | 77 | /** 78 | * This default implementation will send a pong in response to the received ping. The pong frame 79 | * will have the same payload as the ping frame. 80 | * 81 | * @see org.java_websocket.WebSocketListener#onWebsocketPing(WebSocket, Framedata) 82 | */ 83 | @Override 84 | public void onWebsocketPing(WebSocket conn, Framedata f) { 85 | conn.sendFrame(new PongFrame((PingFrame) f)); 86 | } 87 | 88 | /** 89 | * This default implementation does not do anything. Go ahead and overwrite it. 90 | * 91 | * @see org.java_websocket.WebSocketListener#onWebsocketPong(WebSocket, Framedata) 92 | */ 93 | @Override 94 | public void onWebsocketPong(WebSocket conn, Framedata f) { 95 | //To overwrite 96 | } 97 | 98 | /** 99 | * Default implementation for onPreparePing, returns a (cached) PingFrame that has no application 100 | * data. 101 | * 102 | * @param conn The WebSocket connection from which the ping frame will be sent. 103 | * @return PingFrame to be sent. 104 | * @see org.java_websocket.WebSocketListener#onPreparePing(WebSocket) 105 | */ 106 | @Override 107 | public PingFrame onPreparePing(WebSocket conn) { 108 | if (pingFrame == null) { 109 | pingFrame = new PingFrame(); 110 | } 111 | return pingFrame; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/macos,windows,linux,intellij+all,visualstudiocode,gradle 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=macos,windows,linux,intellij+all,visualstudiocode,gradle 3 | 4 | ### Intellij+all ### 5 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 6 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 7 | 8 | # User-specific stuff 9 | .idea/**/workspace.xml 10 | .idea/**/tasks.xml 11 | .idea/**/usage.statistics.xml 12 | .idea/**/dictionaries 13 | .idea/**/shelf 14 | 15 | # AWS User-specific 16 | .idea/**/aws.xml 17 | 18 | # Generated files 19 | .idea/**/contentModel.xml 20 | 21 | # Sensitive or high-churn files 22 | .idea/**/dataSources/ 23 | .idea/**/dataSources.ids 24 | .idea/**/dataSources.local.xml 25 | .idea/**/sqlDataSources.xml 26 | .idea/**/dynamic.xml 27 | .idea/**/uiDesigner.xml 28 | .idea/**/dbnavigator.xml 29 | 30 | # Gradle 31 | .idea/**/gradle.xml 32 | .idea/**/libraries 33 | 34 | # Gradle and Maven with auto-import 35 | # When using Gradle or Maven with auto-import, you should exclude module files, 36 | # since they will be recreated, and may cause churn. Uncomment if using 37 | # auto-import. 38 | # .idea/artifacts 39 | # .idea/compiler.xml 40 | # .idea/jarRepositories.xml 41 | # .idea/modules.xml 42 | # .idea/*.iml 43 | # .idea/modules 44 | # *.iml 45 | # *.ipr 46 | 47 | # CMake 48 | cmake-build-*/ 49 | 50 | # Mongo Explorer plugin 51 | .idea/**/mongoSettings.xml 52 | 53 | # File-based project format 54 | *.iws 55 | 56 | # IntelliJ 57 | out/ 58 | 59 | # mpeltonen/sbt-idea plugin 60 | .idea_modules/ 61 | 62 | # JIRA plugin 63 | atlassian-ide-plugin.xml 64 | 65 | # Cursive Clojure plugin 66 | .idea/replstate.xml 67 | 68 | # SonarLint plugin 69 | .idea/sonarlint/ 70 | 71 | # Crashlytics plugin (for Android Studio and IntelliJ) 72 | com_crashlytics_export_strings.xml 73 | crashlytics.properties 74 | crashlytics-build.properties 75 | fabric.properties 76 | 77 | # Editor-based Rest Client 78 | .idea/httpRequests 79 | 80 | # Android studio 3.1+ serialized cache file 81 | .idea/caches/build_file_checksums.ser 82 | 83 | ### Intellij+all Patch ### 84 | # Ignore everything but code style settings and run configurations 85 | # that are supposed to be shared within teams. 86 | 87 | .idea/* 88 | 89 | !.idea/codeStyles 90 | !.idea/runConfigurations 91 | 92 | ### Linux ### 93 | *~ 94 | 95 | # temporary files which can be created if a process still has a handle open of a deleted file 96 | .fuse_hidden* 97 | 98 | # KDE directory preferences 99 | .directory 100 | 101 | # Linux trash folder which might appear on any partition or disk 102 | .Trash-* 103 | 104 | # .nfs files are created when an open file is removed but is still being accessed 105 | .nfs* 106 | 107 | ### macOS ### 108 | # General 109 | .DS_Store 110 | .AppleDouble 111 | .LSOverride 112 | 113 | # Icon must end with two \r 114 | Icon 115 | 116 | 117 | # Thumbnails 118 | ._* 119 | 120 | # Files that might appear in the root of a volume 121 | .DocumentRevisions-V100 122 | .fseventsd 123 | .Spotlight-V100 124 | .TemporaryItems 125 | .Trashes 126 | .VolumeIcon.icns 127 | .com.apple.timemachine.donotpresent 128 | 129 | # Directories potentially created on remote AFP share 130 | .AppleDB 131 | .AppleDesktop 132 | Network Trash Folder 133 | Temporary Items 134 | .apdisk 135 | 136 | ### macOS Patch ### 137 | # iCloud generated files 138 | *.icloud 139 | 140 | ### VisualStudioCode ### 141 | .vscode/* 142 | !.vscode/settings.json 143 | !.vscode/tasks.json 144 | !.vscode/launch.json 145 | !.vscode/extensions.json 146 | !.vscode/*.code-snippets 147 | 148 | # Local History for Visual Studio Code 149 | .history/ 150 | 151 | # Built Visual Studio Code Extensions 152 | *.vsix 153 | 154 | ### VisualStudioCode Patch ### 155 | # Ignore all local history of files 156 | .history 157 | .ionide 158 | 159 | ### Windows ### 160 | # Windows thumbnail cache files 161 | Thumbs.db 162 | Thumbs.db:encryptable 163 | ehthumbs.db 164 | ehthumbs_vista.db 165 | 166 | # Dump file 167 | *.stackdump 168 | 169 | # Folder config file 170 | [Dd]esktop.ini 171 | 172 | # Recycle Bin used on file shares 173 | $RECYCLE.BIN/ 174 | 175 | # Windows Installer files 176 | *.cab 177 | *.msi 178 | *.msix 179 | *.msm 180 | *.msp 181 | 182 | # Windows shortcuts 183 | *.lnk 184 | 185 | ### Gradle ### 186 | .gradle 187 | **/build/ 188 | !src/**/build/ 189 | 190 | # Ignore Gradle GUI config 191 | gradle-app.setting 192 | 193 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 194 | !gradle-wrapper.jar 195 | 196 | # Avoid ignore Gradle wrappper properties 197 | !gradle-wrapper.properties 198 | 199 | # Cache of project 200 | .gradletasknamecache 201 | 202 | # Eclipse Gradle plugin generated files 203 | # Eclipse Core 204 | .project 205 | # JDT-specific (Eclipse Java Development Tools) 206 | .classpath 207 | 208 | ### Gradle Patch ### 209 | # Java heap dump 210 | *.hprof 211 | 212 | # End of https://www.toptal.com/developers/gitignore/api/macos,windows,linux,intellij+all,visualstudiocode,gradle --------------------------------------------------------------------------------