first approch failed with mqqt broker on drone: problem the websocket port don't work (can't be reach)
parent
a01fe4120b
commit
6723e88c37
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,92 @@
|
||||
// import { Alert } from 'react-native';
|
||||
// import initialize from '../../lib';
|
||||
// import * as Paho from '../../lib/paho-mqtt';
|
||||
|
||||
// initialize();
|
||||
|
||||
// class MqttClient {
|
||||
// client: any;
|
||||
// callbacks: { [key: string]: (payloadString: string) => void };
|
||||
// onSuccessHandler?: () => void;
|
||||
// onConnectionLostHandler?: () => void;
|
||||
// isConnected: boolean;
|
||||
|
||||
// constructor() {
|
||||
// const clientId = 'ReactNativeMqtt';
|
||||
|
||||
// this.client = new Paho.Client('127.0.0.1', 9001, clientId);
|
||||
// this.client.onMessageArrived = this.onMessageArrived.bind(this);
|
||||
// this.callbacks = {};
|
||||
// this.onSuccessHandler = undefined;
|
||||
// this.onConnectionLostHandler = undefined;
|
||||
// this.isConnected = false;
|
||||
// }
|
||||
|
||||
// onConnect = (
|
||||
// onSuccessHandler: () => void,
|
||||
// onConnectionLostHandler: () => void,
|
||||
// ) => {
|
||||
// this.onSuccessHandler = onSuccessHandler;
|
||||
// this.onConnectionLostHandler = onConnectionLostHandler;
|
||||
// this.client.onConnectionLost = () => {
|
||||
// this.isConnected = false;
|
||||
// onConnectionLostHandler();
|
||||
// };
|
||||
|
||||
// this.client.connect({
|
||||
// timeout: 10,
|
||||
// onSuccess: () => {
|
||||
// this.isConnected = true;
|
||||
// onSuccessHandler();
|
||||
// },
|
||||
// useSSL: false,
|
||||
// onFailure: this.onError.bind(this),
|
||||
// reconnect: true,
|
||||
// keepAliveInterval: 20,
|
||||
// cleanSession: true,
|
||||
// });
|
||||
// };
|
||||
|
||||
// onError = ({ errorMessage }: { errorMessage: string }) => {
|
||||
// console.log(errorMessage);
|
||||
// this.isConnected = false;
|
||||
// Alert.alert('Failed', 'Failed to connect to MQTT', [
|
||||
// {
|
||||
// text: 'Cancel',
|
||||
// onPress: () => console.log('Cancel Pressed'),
|
||||
// style: 'cancel',
|
||||
// },
|
||||
// {
|
||||
// text: 'Try Again',
|
||||
// onPress: () =>
|
||||
// this.onConnect(
|
||||
// this.onSuccessHandler!,
|
||||
// this.onConnectionLostHandler!,
|
||||
// ),
|
||||
// },
|
||||
// ]);
|
||||
// };
|
||||
|
||||
// onMessageArrived = (message: Paho.Message) => {
|
||||
// const { payloadString, topic } = message;
|
||||
// console.log('onMessageArrived:', payloadString);
|
||||
// this.callbacks[topic](payloadString);
|
||||
// };
|
||||
|
||||
// onPublish = (topic: string, message: string) => {
|
||||
// this.client.publish(topic, message);
|
||||
// };
|
||||
|
||||
// onSubscribe = (topic: string, callback: (payloadString: string) => void) => {
|
||||
// this.callbacks[topic] = callback;
|
||||
// this.client.subscribe(topic);
|
||||
// };
|
||||
|
||||
// unsubscribe = (topic: string) => {
|
||||
// delete this.callbacks[topic];
|
||||
// this.client.unsubscribe(topic);
|
||||
// };
|
||||
// }
|
||||
|
||||
// let client = new MqttClient();
|
||||
// export { client as MqttClient };
|
@ -0,0 +1,16 @@
|
||||
|
||||
// export default class ChatService {
|
||||
// private readonly mqtt_broker = '127.0.0.1';
|
||||
// private readonly mqtt_port = 9001;
|
||||
// private spotifyRequestHandler = new RequestHandler();
|
||||
// public token: string;
|
||||
|
||||
|
||||
// constructor(token: string) {
|
||||
// this.token = token;
|
||||
// }
|
||||
// public async getMusicById(idMusic: string): Promise<Music| null> {
|
||||
// }
|
||||
|
||||
|
||||
// }
|
Loading…
Reference in new issue