Search in sources :

Example 6 with EndpointManager

use of com.zx.sms.connect.manager.EndpointManager in project SMSGate by Lihuanghe.

the class ClientTestCMPPEndPoint method testCMPPEndpoint.

@Test
public void testCMPPEndpoint() throws Exception {
    final EndpointManager manager = EndpointManager.INS;
    CMPPClientEndpointEntity client = new CMPPClientEndpointEntity();
    client.setId("GSDT01");
    client.setHost("127.0.0.1");
    client.setPort(7891);
    client.setChartset(Charset.forName("utf-8"));
    client.setGroupName("test");
    client.setUserName("901782");
    client.setPassword("ICP");
    client.setSpCode("1069039128");
    client.setMaxChannels((short) 11);
    client.setVersion((short) 0x20);
    client.setRetryWaitTimeSec((short) 30);
    client.setUseSSL(false);
    client.setReSendFailMsg(false);
    // client.setWriteLimit(500);
    List<BusinessHandlerInterface> clienthandlers = new ArrayList<BusinessHandlerInterface>();
    clienthandlers.add(new CMPPSessionConnectedHandler(100));
    client.setBusinessHandlerSet(clienthandlers);
    manager.addEndpointEntity(client);
    CMPPClientEndpointEntity client1 = new CMPPClientEndpointEntity();
    client1.setId("GSDT02");
    client1.setHost("127.0.0.1");
    client1.setPort(7891);
    client1.setChartset(Charset.forName("utf-8"));
    client1.setGroupName("test");
    client1.setSpCode("1069039129");
    client1.setUserName("901782");
    client1.setPassword("ICP");
    // client1.setProxy("http://username:password@127.0.0.1:1080");
    client1.setMaxChannels((short) 30);
    client1.setVersion((short) 0x20);
    client1.setRetryWaitTimeSec((short) 30);
    client1.setUseSSL(false);
    client1.setReSendFailMsg(true);
    // client.setWriteLimit(10);
    List<BusinessHandlerInterface> clienthandlers1 = new ArrayList<BusinessHandlerInterface>();
    clienthandlers1.add(new CMPPSessionConnectedHandler(0));
    client1.setBusinessHandlerSet(clienthandlers1);
    // manager.addEndpointEntity(client1);
    // manager.openAll();
    // LockSupport.park();
    Thread.sleep(1000);
    manager.openEndpoint(client);
    // manager.openEndpoint(client);Thread.sleep(1000);
    // manager.startConnectionCheckTask();
    // while(true){
    // 
    // try{
    // Thread.sleep(20000);
    // }catch(Exception e){
    // break;
    // }
    // EndpointConnector conn = manager.getEndpointConnector(client);
    // conn.fetch().close();
    // }
    System.out.println("start.....");
    LockSupport.park();
    EndpointManager.INS.close();
}
Also used : BusinessHandlerInterface(com.zx.sms.handler.api.BusinessHandlerInterface) ArrayList(java.util.ArrayList) EndpointManager(com.zx.sms.connect.manager.EndpointManager) Test(org.junit.Test)

Example 7 with EndpointManager

use of com.zx.sms.connect.manager.EndpointManager in project SMSGate by Lihuanghe.

the class TestSMPPEndPoint method testSMPPEndpoint.

@Test
public void testSMPPEndpoint() throws Exception {
    final EndpointManager manager = EndpointManager.INS;
    int port = 27761;
    SMPPServerEndpointEntity server = new SMPPServerEndpointEntity();
    server.setId("smppserver");
    server.setHost("127.0.0.1");
    server.setPort(port);
    server.setValid(true);
    // 使用ssl加密数据流
    server.setUseSSL(false);
    SMPPServerChildEndpointEntity child = new SMPPServerChildEndpointEntity();
    child.setId("smppchild");
    child.setSystemId("901782");
    child.setPassword("ICP");
    child.setValid(true);
    child.setChannelType(ChannelType.DUPLEX);
    child.setMaxChannels((short) 3);
    child.setRetryWaitTimeSec((short) 30);
    child.setMaxRetryCnt((short) 3);
    child.setReSendFailMsg(false);
    child.setIdleTimeSec((short) 15);
    // child.setWriteLimit(200);
    // child.setReadLimit(200);
    List<BusinessHandlerInterface> serverhandlers = new ArrayList<BusinessHandlerInterface>();
    serverhandlers.add(new SMPPMessageReceiveHandler());
    child.setBusinessHandlerSet(serverhandlers);
    server.addchild(child);
    SMPPClientEndpointEntity client = new SMPPClientEndpointEntity();
    client.setId("smppclient");
    client.setHost("127.0.0.1");
    client.setPort(port);
    client.setSystemId("901782");
    client.setPassword("ICP");
    client.setChannelType(ChannelType.DUPLEX);
    client.setMaxChannels((short) 12);
    client.setRetryWaitTimeSec((short) 100);
    client.setUseSSL(false);
    client.setReSendFailMsg(false);
    // client.setWriteLimit(200);
    // client.setReadLimit(200);
    // 接收长短信时不自动合并
    client.setSupportLongmsg(SupportLongMessage.SEND);
    List<BusinessHandlerInterface> clienthandlers = new ArrayList<BusinessHandlerInterface>();
    clienthandlers.add(new SMPPSessionConnectedHandler(10));
    client.setBusinessHandlerSet(clienthandlers);
    manager.addEndpointEntity(server);
    manager.addEndpointEntity(client);
    manager.openAll();
    Thread.sleep(1000);
    System.out.println("start.....");
    LockSupport.park();
    EndpointManager.INS.close();
}
Also used : BusinessHandlerInterface(com.zx.sms.handler.api.BusinessHandlerInterface) ArrayList(java.util.ArrayList) EndpointManager(com.zx.sms.connect.manager.EndpointManager) Test(org.junit.Test)

Example 8 with EndpointManager

use of com.zx.sms.connect.manager.EndpointManager in project SMSGate by Lihuanghe.

the class TestTcpEndPoint method testEchoTcpEndpoint.

@Test
public void testEchoTcpEndpoint() throws Exception {
    int port = 7890;
    final EndpointManager manager = EndpointManager.INS;
    final EndpointEntity server = new TCPServerEndpointEntity(port);
    server.setId("svrID");
    EndpointEntity client = new TCPClientEndpointEntity("127.0.0.1", port);
    client.setId("tcpid");
    client.setMaxChannels((short) 2);
    manager.addEndpointEntity(server);
    manager.addEndpointEntity(client);
    // manager.addEndpointEntity(new TCPClientEndpointEntity("221.176.67.103",port));
    // manager.addEndpointEntity(client);
    // manager.addEndpointEntity(new TCPClientEndpointEntity("192.168.1.103",port));
    // manager.addEndpointEntity(new TCPClientEndpointEntity("192.168.1.103",port));
    // manager.addEndpointEntity(new TCPClientEndpointEntity("192.168.1.103",port));
    // manager.addEndpointEntity(new TCPClientEndpointEntity("192.168.1.103",port));
    // manager.addEndpointEntity(new TCPClientEndpointEntity("192.168.1.103",port));
    // manager.addEndpointEntity(new TCPClientEndpointEntity("192.168.1.103",port));
    manager.openAll();
    // EventLoopGroupFactory.INS.getWorker().scheduleAtFixedRate(new Runnable() {
    // @Override
    // public void run() {
    // logger.info("connections: {}",manager.getEndpointConnector(server).getConnectionNum());
    // }
    // }, 10, 10, TimeUnit.SECONDS);
    Thread.sleep(5000);
    client.getSingletonConnector().fetch().writeAndFlush(Unpooled.wrappedBuffer(new byte[] { 1 }));
    Thread.sleep(10000);
    Set<EndpointEntity> entities = CMPPEndpointManager.INS.allEndPointEntity();
    for (EndpointEntity en : entities) {
        CMPPEndpointManager.INS.close(en);
    }
}
Also used : CMPPEndpointManager(com.zx.sms.connect.manager.CMPPEndpointManager) EndpointManager(com.zx.sms.connect.manager.EndpointManager) EndpointEntity(com.zx.sms.connect.manager.EndpointEntity) Test(org.junit.Test)

Example 9 with EndpointManager

use of com.zx.sms.connect.manager.EndpointManager in project SMSGate by Lihuanghe.

the class TestWithOpenSMPP method test.

@Test
public void test() throws Exception {
    final EndpointManager manager = EndpointManager.INS;
    SMPPServerEndpointEntity server = new SMPPServerEndpointEntity();
    server.setId("sms-core-smppserver");
    server.setHost("127.0.0.1");
    server.setPort(port);
    server.setValid(true);
    // 使用ssl加密数据流
    server.setUseSSL(false);
    SMPPServerChildEndpointEntity child = new SMPPServerChildEndpointEntity();
    child.setId("smppchild");
    child.setSystemId(systemId);
    child.setPassword(password);
    child.setValid(true);
    child.setChannelType(ChannelType.DOWN);
    child.setMaxChannels((short) 3);
    child.setRetryWaitTimeSec((short) 30);
    child.setMaxRetryCnt((short) 3);
    child.setReSendFailMsg(false);
    child.setIdleTimeSec((short) 15);
    // child.setWriteLimit(200);
    // child.setReadLimit(200);
    List<BusinessHandlerInterface> serverhandlers = new ArrayList<BusinessHandlerInterface>();
    serverhandlers.add(new SMPPMessageReceiveHandler());
    child.setBusinessHandlerSet(serverhandlers);
    server.addchild(child);
    manager.addEndpointEntity(server);
    manager.openAll();
    Thread.sleep(2000);
    System.out.println("start.....");
    bind();
    String randomStr = String.valueOf(RandomUtils.nextInt(0, 10000));
    sendsubmit("@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !\"#¤%&'()*+,-./0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà^{}\\[~]|" + randomStr, Data.ENC_GSM7BIT);
    sendsubmit("尊敬的客户,您好!您于2016-03-23 14:51:36通过中国移动10085销售专线订购的【一加手机高清防刮保护膜】" + randomStr, Data.ENC_UTF16_BE);
    unbind();
}
Also used : SMPPMessageReceiveHandler(com.zx.sms.connect.manager.smpp.SMPPMessageReceiveHandler) SMPPServerEndpointEntity(com.zx.sms.connect.manager.smpp.SMPPServerEndpointEntity) BusinessHandlerInterface(com.zx.sms.handler.api.BusinessHandlerInterface) ArrayList(java.util.ArrayList) EndpointManager(com.zx.sms.connect.manager.EndpointManager) SMPPServerChildEndpointEntity(com.zx.sms.connect.manager.smpp.SMPPServerChildEndpointEntity) Test(org.junit.Test)

Example 10 with EndpointManager

use of com.zx.sms.connect.manager.EndpointManager in project SMSGate by Lihuanghe.

the class ConnState method print.

@Override
public String print(String entityId) {
    StringBuilder sb = new StringBuilder();
    EndpointManager em = EndpointManager.INS;
    if (StringUtils.isEmpty(entityId)) {
        Set<EndpointEntity> enlist = em.allEndPointEntity();
        for (EndpointEntity e : enlist) {
            sb.append(e.getId() + ":\n");
            sb.append(printOne(e));
        }
    } else {
        EndpointEntity e = em.getEndpointEntity(entityId);
        if (e != null) {
            sb.append(e.getId() + ":\n");
            sb.append(printOne(e));
        }
    }
    return sb.toString();
}
Also used : EndpointManager(com.zx.sms.connect.manager.EndpointManager) EndpointEntity(com.zx.sms.connect.manager.EndpointEntity)

Aggregations

EndpointManager (com.zx.sms.connect.manager.EndpointManager)10 Test (org.junit.Test)9 BusinessHandlerInterface (com.zx.sms.handler.api.BusinessHandlerInterface)7 ArrayList (java.util.ArrayList)7 EndpointEntity (com.zx.sms.connect.manager.EndpointEntity)2 AbstractBusinessHandler (com.zx.sms.handler.api.AbstractBusinessHandler)2 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)2 CMPPEndpointManager (com.zx.sms.connect.manager.CMPPEndpointManager)1 SMPPMessageReceiveHandler (com.zx.sms.connect.manager.smpp.SMPPMessageReceiveHandler)1 SMPPServerChildEndpointEntity (com.zx.sms.connect.manager.smpp.SMPPServerChildEndpointEntity)1 SMPPServerEndpointEntity (com.zx.sms.connect.manager.smpp.SMPPServerEndpointEntity)1 SgipReportRequestMessageHandler (com.zx.sms.handler.sgip.SgipReportRequestMessageHandler)1