1 /* 2 * Copyright 2002-2015 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 module hunt.stomp.simp.stomp.StompSessionHandlerAdapter; 18 19 // import java.lang.reflect.Type; 20 import hunt.stomp.simp.stomp.StompCommand; 21 import hunt.stomp.simp.stomp.StompFrameHandler; 22 import hunt.stomp.simp.stomp.StompHeaders; 23 import hunt.stomp.simp.stomp.StompSessionHandler; 24 import hunt.stomp.simp.stomp.StompSession; 25 26 27 /** 28 * Abstract adapter class for {@link StompSessionHandler} with mostly empty 29 * implementation methods except for {@link #getPayloadType} which returns string 30 * as the default Object type expected for STOMP ERROR frame payloads. 31 * 32 * @author Rossen Stoyanchev 33 * @since 4.2 34 */ 35 abstract class StompSessionHandlerAdapter : StompSessionHandler { 36 37 /** 38 * This implementation returns string as the expected payload type 39 * for STOMP ERROR frames. 40 */ 41 override 42 TypeInfo getPayloadType(StompHeaders headers) { 43 return typeid(string); 44 } 45 46 /** 47 * This implementation is empty. 48 */ 49 override 50 void handleFrame(StompHeaders headers, Object payload) { 51 } 52 53 /** 54 * This implementation is empty. 55 */ 56 override 57 void afterConnected(StompSession session, StompHeaders connectedHeaders) { 58 } 59 60 /** 61 * This implementation is empty. 62 */ 63 override 64 void handleException(StompSession session, StompCommand command, 65 StompHeaders headers, byte[] payload, Throwable exception) { 66 } 67 68 /** 69 * This implementation is empty. 70 */ 71 override 72 void handleTransportError(StompSession session, Throwable exception) { 73 } 74 75 }