com.cloudhopper.smpp.channel.SmppSessionWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ch-smpp Show documentation
Show all versions of ch-smpp Show documentation
Efficient, scalable, and flexible Java implementation of the Short Messaging Peer to Peer Protocol (SMPP)
package com.cloudhopper.smpp.channel;
/*
* #%L
* ch-smpp
* %%
* Copyright (C) 2009 - 2015 Cloudhopper by Twitter
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import com.cloudhopper.smpp.impl.SmppSessionChannelListener;
import com.cloudhopper.smpp.pdu.Pdu;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static io.netty.channel.ChannelHandler.Sharable;
/**
*
* @author joelauer (twitter: @jjlauer or http://twitter.com/jjlauer)
*/
@Sharable
public class SmppSessionWrapper extends SimpleChannelInboundHandler {
private static final Logger logger = LoggerFactory.getLogger(SmppSessionWrapper.class);
private SmppSessionChannelListener listener;
public SmppSessionWrapper(SmppSessionChannelListener listener) {
this.listener = listener;
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, Pdu msg) throws Exception {
this.listener.firePduReceived(msg);
}
/**
* Invoked when a Channel was closed and all its related resources were released.
*/
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
this.listener.fireChannelClosed();
super.channelInactive(ctx);
}
/**
* Invoked when an exception was raised by an I/O thread or an upstream handler.
*/
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
this.listener.fireExceptionThrown(cause.getCause());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy