flutter_ar_server 0.0.1
flutter_ar_server: ^0.0.1 copied to clipboard
A robust Flutter package that integrates WebSocket communication, MongoDB storage, and secure data handling for augmented reality (AR) applications. It is designed to support AR-driven features such [...]
flutter_ar_server #
flutter_ar_server is a Flutter package that provides a robust server-side implementation for handling augmented reality (AR) functionalities, including WebSocket communication, MongoDB integration, HTTP requests, and secure data storage. This package is designed to support AR-based applications for various use cases, including reporting electrical faults, viewing 3D models, and other AR-driven operations.
Features #
- WebSocket Communication: Real-time communication with clients using WebSocket.
- MongoDB Integration: Store and retrieve AR objects and related data using MongoDB.
- HTTP Requests: Send and receive HTTP POST requests to interact with external APIs.
- Secure Data Storage: Use Flutter Secure Storage for storing sensitive data securely.
- AR Applications: Supports features like reporting electrical faults and viewing houses in 3D.
Installation #
Add the following line to your pubspec.yaml under dependencies:
dependencies:
flutter_ar_server: ^0.1.0
Then, run:
bash Copy code flutter pub get Usage
- Initialize the Server You can initialize the AR server with WebSocket and MongoDB connections:
dart Copy code import 'package:flutter_ar_server/flutter_ar_server.dart';
void main() { final arServer = ARServer('ws://localhost:3000', 'mongodb://localhost:27017/ar_db');
arServer.initialize(); } 2. Send and Receive WebSocket Messages To send a message over WebSocket:
dart Copy code arServer.sendMessage('Hello from AR Server'); To listen for incoming messages:
dart Copy code arServer.channel.stream.listen((message) { print('Received: $message'); }); 3. Save AR Object to MongoDB Save AR object data to MongoDB:
dart Copy code final arObject = { 'name': 'TestObject', 'position': {'x': 1, 'y': 2, 'z': 3} };
await arServer.saveARObject(arObject); 4. Handle HTTP POST Requests Send a POST request to an endpoint:
dart Copy code final endpoint = 'http://localhost:3000/ar-data'; final data = {'object': 'TestObject', 'position': {'x': 1, 'y': 2, 'z': 3}};
await arServer.sendPostRequest(endpoint, data); 5. Close Connections To properly close WebSocket and MongoDB connections:
dart Copy code arServer.close(); Example Here’s a full example of how to use flutter_ar_server:
dart Copy code import 'package:flutter_ar_server/flutter_ar_server.dart';
void main() { final arServer = ARServer('ws://localhost:3000', 'mongodb://localhost:27017/ar_db');
arServer.initialize();
arServer.channel.stream.listen((message) { print('Received: $message'); });
final arObject = { 'name': 'TestObject', 'position': {'x': 1, 'y': 2, 'z': 3} };
arServer.saveARObject(arObject);
final endpoint = 'http://localhost:3000/ar-data'; final data = {'object': 'TestObject', 'position': {'x': 1, 'y': 2, 'z': 3}};
arServer.sendPostRequest(endpoint, data);
arServer.close(); } Testing To run the tests for this package:
Copy code
flutter test
Example Test File
Here's an example test file:
dart Copy code import 'package:test/test.dart'; import 'package:mocktail/mocktail.dart'; import 'package:flutter_ar_server/flutter_ar_server.dart';
void main() { // Your test cases here } Contributing Contributions are welcome! Please open an issue or submit a pull request for any bugs or feature requests.
License This project is licensed under the MIT License - see the LICENSE file for details.
Issues If you encounter any issues, please feel free to open an issue on GitHub.
Contact For more information, contact Anesu Ndava.
markdown Copy code
How to Use the Document #
- Save this content as
README.mdin the root directory of your package. - Customize the GitHub links and contact information as needed.
- After making any changes, commit and push the
README.mdfile to your repository.