当前位置: 首页>>代码示例>>Java>>正文


Java MqttConnAckMessage类代码示例

本文整理汇总了Java中io.netty.handler.codec.mqtt.MqttConnAckMessage的典型用法代码示例。如果您正苦于以下问题:Java MqttConnAckMessage类的具体用法?Java MqttConnAckMessage怎么用?Java MqttConnAckMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MqttConnAckMessage类属于io.netty.handler.codec.mqtt包,在下文中一共展示了MqttConnAckMessage类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCONNECTION_REFUSED_SERVER_UNAVAILABLE

import io.netty.handler.codec.mqtt.MqttConnAckMessage; //导入依赖的package包/类
@Test
public void testCONNECTION_REFUSED_SERVER_UNAVAILABLE() throws Exception {
	ServiceChecker prev = Plugins.INSTANCE.put(ServiceChecker.class, new ServiceChecker() {
		@Override
		public Plugin clone() {
			return this;
		}

		@Override
		public boolean isServiceAvailable() {
			return false;
		}
	});

	MqttConnAckMessage ret = executeNormalChannelRead0(TestUtil.newClientId(), true, null);

	Assert.assertEquals(ret.variableHeader().connectReturnCode(),
			MqttConnectReturnCode.CONNECTION_REFUSED_SERVER_UNAVAILABLE);

	Plugins.INSTANCE.put(ServiceChecker.class, prev);
}
 
开发者ID:anyflow,项目名称:lannister,代码行数:22,代码来源:ConnectReceiverTest.java

示例2: testCONNECTION_REFUSED_NOT_AUTHORIZED

import io.netty.handler.codec.mqtt.MqttConnAckMessage; //导入依赖的package包/类
@Test
public void testCONNECTION_REFUSED_NOT_AUTHORIZED() throws Exception {
	Authorizer prev = Plugins.INSTANCE.put(Authorizer.class, new Authorizer() {
		@Override
		public Plugin clone() {
			return this;
		}

		@Override
		public boolean isAuthorized(String clientId, String username) {
			return false;
		}
	});

	MqttConnAckMessage ret = executeNormalChannelRead0(TestUtil.newClientId(), true, null);

	Assert.assertEquals(ret.variableHeader().connectReturnCode(),
			MqttConnectReturnCode.CONNECTION_REFUSED_NOT_AUTHORIZED);

	Plugins.INSTANCE.put(Authorizer.class, prev);
}
 
开发者ID:anyflow,项目名称:lannister,代码行数:22,代码来源:ConnectReceiverTest.java

示例3: executeNormalChannelRead0

import io.netty.handler.codec.mqtt.MqttConnAckMessage; //导入依赖的package包/类
private MqttConnAckMessage executeNormalChannelRead0(String clientId, boolean cleanSession, ChannelId channelId)
		throws Exception {
	MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.CONNECT, false, MqttQoS.AT_MOST_ONCE, false,
			10);
	MqttConnectVariableHeader variableHeader = new MqttConnectVariableHeader("MQTT", 4, true, true, true, 0, true,
			cleanSession, 60);
	MqttConnectPayload payload = new MqttConnectPayload(clientId, "willtopic", "willmessage", "username",
			"password");

	MqttConnectMessage msg = new MqttConnectMessage(fixedHeader, variableHeader, payload);

	ChannelId cid = channelId == null ? TestUtil.newChannelId(clientId, false) : channelId;

	EmbeddedChannel channel = new EmbeddedChannel(cid, new ConnectReceiver());

	channel.writeInbound(msg);

	return channel.readOutbound();
}
 
开发者ID:anyflow,项目名称:lannister,代码行数:20,代码来源:ConnectReceiverTest.java

示例4: connack

import io.netty.handler.codec.mqtt.MqttConnAckMessage; //导入依赖的package包/类
public static MqttConnAckMessage connack(MqttConnectReturnCode returnCode, boolean sessionPresent) {
	MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.CONNACK, false, MqttQoS.AT_MOST_ONCE, false,
			2);
	MqttConnAckVariableHeader variableHeader = new MqttConnAckVariableHeader(returnCode, sessionPresent);

	return new MqttConnAckMessage(fixedHeader, variableHeader);
}
 
开发者ID:anyflow,项目名称:lannister,代码行数:8,代码来源:MqttMessageFactory.java

示例5: testCleanSessionWithoutClientIdReturnFalse

import io.netty.handler.codec.mqtt.MqttConnAckMessage; //导入依赖的package包/类
@Test
public void testCleanSessionWithoutClientIdReturnFalse() throws Exception {
	Settings.INSTANCE.setProperty("mqttserver.acceptEmptyClientId", "false");
	MqttConnAckMessage ret = executeNormalChannelRead0("", true, null);

	Assert.assertEquals(MqttConnectReturnCode.CONNECTION_REFUSED_IDENTIFIER_REJECTED,
			ret.variableHeader().connectReturnCode());
	Settings.INSTANCE.setProperty("mqttserver.acceptEmptyClientId", "true");
}
 
开发者ID:anyflow,项目名称:lannister,代码行数:10,代码来源:ConnectReceiverTest.java

示例6: nonCleanSession

import io.netty.handler.codec.mqtt.MqttConnAckMessage; //导入依赖的package包/类
@Test
public void nonCleanSession() throws Exception {
	String clientId = TestUtil.newClientId();

	MqttConnAckMessage ret = executeNormalChannelRead0(clientId, false, null);

	Assert.assertEquals(ret.variableHeader().connectReturnCode(), MqttConnectReturnCode.CONNECTION_ACCEPTED);
}
 
开发者ID:anyflow,项目名称:lannister,代码行数:9,代码来源:ConnectReceiverTest.java

示例7: assertEqualsConnAck

import io.netty.handler.codec.mqtt.MqttConnAckMessage; //导入依赖的package包/类
static void assertEqualsConnAck(String msg, MqttConnectReturnCode expectedCode, Object connAck) {
    assertTrue("connAck is not an instance of ConnAckMessage", connAck instanceof MqttConnAckMessage);
    MqttConnAckMessage connAckMsg = (MqttConnAckMessage) connAck;

    if (msg == null)
        assertEquals(expectedCode, connAckMsg.variableHeader().connectReturnCode());
    else
        assertEquals(msg, expectedCode, connAckMsg.variableHeader().connectReturnCode());
}
 
开发者ID:andsel,项目名称:moquette,代码行数:10,代码来源:NettyChannelAssertions.java

示例8: createMqttConnAckMsg

import io.netty.handler.codec.mqtt.MqttConnAckMessage; //导入依赖的package包/类
private MqttConnAckMessage createMqttConnAckMsg(MqttConnectReturnCode returnCode) {
  MqttFixedHeader mqttFixedHeader = new MqttFixedHeader(CONNACK, false, AT_MOST_ONCE, false, 0);
  MqttConnAckVariableHeader mqttConnAckVariableHeader = new MqttConnAckVariableHeader(returnCode, true);
  return new MqttConnAckMessage(mqttFixedHeader, mqttConnAckVariableHeader);
}
 
开发者ID:osswangxining,项目名称:iothub,代码行数:6,代码来源:MqttTransportHandler.java

示例9: connect

import io.netty.handler.codec.mqtt.MqttConnAckMessage; //导入依赖的package包/类
public MqttConnectReturnCode connect() throws InterruptedException {

		Class<? extends SocketChannel> socketChannelClass;

		if (Literals.NETTY_EPOLL.equals(Settings.INSTANCE.nettyTransportMode())) {
			group = new EpollEventLoopGroup(1, new DefaultThreadFactory("client"));
			socketChannelClass = EpollSocketChannel.class;
		}
		else {
			group = new NioEventLoopGroup(1, new DefaultThreadFactory("client"));
			socketChannelClass = NioSocketChannel.class;
		}

		bootstrap.group(group).channel(socketChannelClass).handler(new ChannelInitializer<SocketChannel>() {
			@Override
			protected void initChannel(SocketChannel ch) throws Exception {
				if ("mqtts".equalsIgnoreCase(uri.getScheme())) {
					SslContext sslCtx = SslContextBuilder.forClient().trustManager(trustManagerFactory).build();

					ch.pipeline().addLast(sslCtx.newHandler(ch.alloc(), uri.getHost(), uri.getPort()));
				}

				ch.pipeline().addLast(MqttDecoder.class.getName(), new MqttDecoder());
				ch.pipeline().addLast(MqttEncoder.class.getName(), MqttEncoder.INSTANCE);
				ch.pipeline().addLast(MqttPacketReceiver.class.getName(),
						new MqttPacketReceiver(MqttClient.this, receiver, sharedObject));
			}
		});

		channel = bootstrap.connect(uri.getHost(), uri.getPort()).sync().channel();

		normalizeMessage(options.will());
		send(MqttMessageFactory.connect(options));

		synchronized (sharedObject.locker()) {
			int timeout = Settings.INSTANCE.getInt("mqttclient.responseTimeoutSeconds", 15);

			sharedObject.locker().wait(timeout * 1000);
		}
		if (sharedObject.receivedMessage() == null) { return null; }

		return ((MqttConnAckMessage) sharedObject.receivedMessage()).variableHeader().connectReturnCode();
	}
 
开发者ID:anyflow,项目名称:lannister,代码行数:44,代码来源:MqttClient.java

示例10: testDefaultChannelRead0

import io.netty.handler.codec.mqtt.MqttConnAckMessage; //导入依赖的package包/类
@Test
public void testDefaultChannelRead0() throws Exception {
	MqttConnAckMessage ret = executeNormalChannelRead0(TestUtil.newClientId(), true, null);

	Assert.assertEquals(ret.variableHeader().connectReturnCode(), MqttConnectReturnCode.CONNECTION_ACCEPTED);
}
 
开发者ID:anyflow,项目名称:lannister,代码行数:7,代码来源:ConnectReceiverTest.java

示例11: testCleanSessionWithoutClientIdReturnTrue

import io.netty.handler.codec.mqtt.MqttConnAckMessage; //导入依赖的package包/类
@Test
public void testCleanSessionWithoutClientIdReturnTrue() throws Exception {
	MqttConnAckMessage ret = executeNormalChannelRead0("", true, null);

	Assert.assertEquals(MqttConnectReturnCode.CONNECTION_ACCEPTED, ret.variableHeader().connectReturnCode());
}
 
开发者ID:anyflow,项目名称:lannister,代码行数:7,代码来源:ConnectReceiverTest.java

示例12: createConnAckMessage

import io.netty.handler.codec.mqtt.MqttConnAckMessage; //导入依赖的package包/类
private static MqttConnAckMessage createConnAckMessage(MqttConnectReturnCode code) {
    MqttFixedHeader mqttFixedHeader =
            new MqttFixedHeader(MqttMessageType.CONNACK, false, MqttQoS.AT_MOST_ONCE, false, 2);
    MqttConnAckVariableHeader mqttConnAckVariableHeader = new MqttConnAckVariableHeader(code, true);
    return new MqttConnAckMessage(mqttFixedHeader, mqttConnAckVariableHeader);
}
 
开发者ID:blynkkk,项目名称:blynk-server,代码行数:7,代码来源:MqttHardwareLoginHandler.java

示例13: sendConnack

import io.netty.handler.codec.mqtt.MqttConnAckMessage; //导入依赖的package包/类
void sendConnack(MqttConnectReturnCode returnCode) {
   MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.CONNACK, false, MqttQoS.AT_MOST_ONCE, false, 0);
   MqttConnAckVariableHeader varHeader = new MqttConnAckVariableHeader(returnCode, true);
   MqttConnAckMessage message = new MqttConnAckMessage(fixedHeader, varHeader);
   sendToClient(message);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:7,代码来源:MQTTProtocolHandler.java

示例14: cleanSessionOnSameClientIdSession

import io.netty.handler.codec.mqtt.MqttConnAckMessage; //导入依赖的package包/类
@Test
public void cleanSessionOnSameClientIdSession() throws Exception {
	String clientId = TestUtil.newClientId();

	executeNormalChannelRead0(clientId, true, null);

	MqttConnAckMessage ret = executeNormalChannelRead0(clientId, true, null);

	Assert.assertEquals(ret.variableHeader().connectReturnCode(), MqttConnectReturnCode.CONNECTION_ACCEPTED);
}
 
开发者ID:anyflow,项目名称:lannister,代码行数:11,代码来源:ConnectReceiverTest.java


注:本文中的io.netty.handler.codec.mqtt.MqttConnAckMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。