admin 管理员组文章数量: 887021
2023年12月18日发(作者:全部代码)
* @param BinSoulNetMqttPacketConnectRequestPacket $request* @param ImiServerMQTTMessageReceiveData $receiveData* @return BinSoulNetMqttPacketConnectResponsePacket|null*/public function connect(ConnectRequestPacket $request, ReceiveData $receiveData): ?ConnectResponsePacket{$success = 'root' === $request->getUsername() && '123456' === $request->getPassword();$response = new ConnectResponsePacket;if($success){$response->setReturnCode(0);}else{$response->setReturnCode(4);}return $response;}/*** 断开连接** @param BinSoulNetMqttPacketDisconnectRequestPacket $request* @param ImiServerMQTTMessageReceiveData $receiveData* @return void*/public function disconnect(DisconnectRequestPacket $request, ReceiveData $receiveData): void{}/*** Ping** @param BinSoulNetMqttPacketPingRequestPacket $request* @param ImiServerMQTTMessageReceiveData $receiveData* @return BinSoulNetMqttPacketPingResponsePacket|null
*/public function ping(PingRequestPacket $request, ReceiveData $receiveData): ?PingResponsePacket{return new PingResponsePacket;}/*** 发布** @param BinSoulNetMqttPacketPublishRequestPacket $request* @param ImiServerMQTTMessageReceiveData $receiveData* @returnBinSoulNetMqttPacketPublishAckPacket|BinSoulNetMqttPacketPublishReceivedPacket|BinSoulNetMqttPacketPublis*/public function publish(PublishRequestPacket $request, ReceiveData $receiveData){switch($request->getTopic()){case 'a':$response = new PublishAckPacket;break;case 'b':$response = new PublishReceivedPacket;break;case 'c':$response = new PublishReleasePacket;break;case 'd':$response = new PublishCompletePacket;break;}$response->setIdentifier($request->getIdentifier());return $response;}/**
* 订阅** @param BinSoulNetMqttPacketSubscribeRequestPacket $request* @param ImiServerMQTTMessageReceiveData $receiveData* @return BinSoulNetMqttPacketSubscribeResponsePacket|null*/public function subscribe(SubscribeRequestPacket $request, ReceiveData $receiveData): ?SubscribeResponsePacket{$response = new SubscribeResponsePacket;$response->setIdentifier($request->getIdentifier());$response->setReturnCodes([0]);return $response;}/*** 取消订阅** @param BinSoulNetMqttPacketUnsubscribeRequestPacket $request* @param ImiServerMQTTMessageReceiveData $receiveData* @return BinSoulNetMqttPacketUnsubscribeResponsePacket|null*/public function unsubscribe(UnsubscribeRequestPacket $request, ReceiveData $receiveData): ?UnsubscribeResponsePacket{$response = new UnsubscribeResponsePacket;$response->setIdentifier($request->getIdentifier());return $response;}}
版权声明:本文标题:mqtt服务器搭建php,MQTT服务端 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1702866794h433845.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论