Skip to content

Commit

Permalink
Merge pull request #6 from uhst/release/v0.0.1-nullsafety.0
Browse files Browse the repository at this point in the history
Release/v0.0.1 nullsafety.0
  • Loading branch information
Arenukvern authored Feb 7, 2021
2 parents 645fcc5 + fe9ec00 commit 1ea22ab
Show file tree
Hide file tree
Showing 119 changed files with 4,661 additions and 2 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/doc.workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: flutter_uhst_example
on:
push:
branches:
- main
jobs:
build:
name: Publishing flutter_uhst_example to GitHub pages
env:
my_secret: ${{secrets.COMMIT_SECRET}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: subosito/flutter-action@v1
with:
channel: "dev"
- run: flutter config --enable-web
- run: |
cd example
flutter pub get
flutter build web --release --no-sound-null-safety
cd build/web
git init
# type configurations: your user.email and user.name followed lines
# git config --global user.email your_email
# git config --global user.name your_name
git config --global user.email ${{secrets.USER_EMAIL}}
git config --global user.name ${{secrets.USER_NAME}}
git status
# change this remote url for examle your remote url is then the following:
git remote add origin https://${{secrets.COMMIT_SECRET}}@github.com/uhst/uhst-client-flutter.git
git checkout -b gh-pages
git add --all
git commit -m "update"
git push origin gh-pages -f
75 changes: 75 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,78 @@ doc/api/
*.js_
*.js.deps
*.js.map

# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
build/

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Flutter.podspec
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/Flutter/flutter_export_environment.sh
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: dart

dart:
# - 2.10.0
# Disabling stable for now since we rely on a null safety version of test.
- dev

dart_task:
- test
- dartfmt
- dartanalyzer

# Only building main means that we don't run two builds for each pull request.
branches:
only: [main]

cache:
directories:
- $HOME/.pub-cache
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 0.0.1-nullsafety.0

- Initial development release.
203 changes: 201 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,201 @@
# uhst-client-flutter
User Hosted Secure Transmission (UHST) for Flutter in Dart
# Uhst

> User Hosted Secure Transmission (uhst) for Flutter in Dart
[![Pub](https://img.shields.io/pub/v/uhst.svg)](https://pub.dartlang.org/packages/uhst)
[![Gitter](https://badges.gitter.im/uhst/community.svg)](https://gitter.im/uhst/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![GitHub](https://img.shields.io/github/license/uhst/uhst-client-flutter)](LICENSE)

## About

Uhst is client library for the User Hosted Secure Transmission framework.

It is able to:

- send messages from client and listen messages broadcasted from host
- broadcast messages by host
- listen messages from multiple clients by host

You can see [an implemented example](http://docs.uhst.io/uhst-client-flutter/) and source for it [on GitHub](https://github.com/uhst/uhst-client-flutter/tree/next/example)

Please notice current version limitations:

- it supports string typed messages only.
- require server with Uhst implemented protocol. PLease see an example of ready to go server [on GitHub](https://github.com/uhst/uhst-server-node).

### Support and discussions

Join us on [Gitter](https://gitter.im/uhst/community?utm_source=share-link&utm_medium=link&utm_campaign=share-link) or StackOverflow .

## Usage

Assuming you have loaded the library, first create a new instance:

```dart
var uhst = Uhst();
```

Refer to the documentation to learn about the options you can pass
(including your own API / signalling server URL, WebRTC configuration, etc.) .

### Host

Host in UHST is a peer which every other peer connects to.
This concept is similar to listen-server in multiplayer games.

Please be sure, before reconnecting to another host, to close previous connection.

The simplest way to create a new host is:

```dart
var host = uhst.host("testHost");
host?.disconnect();
host
?..onReady(handler: ({required String hostId}) {
setState(() {
hostMessages.add('Host Ready! Using $hostId');
print('host is ready!');
_hostIdController.text = hostId;
});
})
..onError(handler: ({required Error error}) {
print('error received! $error');
if (error is HostIdAlreadyInUse) {
// this is expected if you refresh the page
// connection is still alive on the meeting point
// just need to wait
setState(() {
hostMessages
.add('HostId already in use, retrying in 15 seconds...!');
});
} else {
setState(() {
hostMessages.add(error.toString());
});
}
})
..onConnection(handler: ({required UhstSocket uhstSocket}) {
uhstSocket.onDiagnostic(handler: ({required String message}) {
setState(() {
hostMessages.add(message);
});
});
uhstSocket.onMessage(handler: ({required Message? message}) {
setState(() {
hostMessages
.add("Host received: ${message?.body} ${message?.type}");
var payload = message?.payload;
if (payload != null) host?.broadcastString(message: payload);
});
});
uhstSocket.onOpen(handler: ({required String? data}) {
// uhstSocket.sendString(message: 'Host sent message!');
});
});
}
```

Note that your requested host id may not be accepted by the signalling server,
you should always use the `hostId` you get after receiving a `ready`
event when connecting to the host.

### Client

To connect to a host from another browser use the same `hostId`
you received during `onReady` event.

Please be sure, before reconnecting to another host, to close previous connection.

```dart
var client = uhst.join("testHost");
client?.close();
client
?..onOpen(handler: ({required String data}) {
setState(() {
client?.sendString(message: 'Hello host!');
});
})
..onMessage(handler: ({required Message? message}) {
setState(() {
clientMessages.add('Client received: $message');
});
})
..onError(handler: ({required Error error}) {
if (error is InvalidHostId || error is InvalidClientOrHostId) {
setState(() {
clientMessages.add('Invalid hostId!');
});
} else {
setState(() {
clientMessages.add(error.toString());
});
}
})
..onDiagnostic(handler: ({required String message}) {
setState(() {
clientMessages.add(message);
});
});
```

The UHST client interface is similar to the HTML5 WebSocket interface,
but instead of a dedicated server, one peer acts as a host for other peers to join.

Once a client and a host have connected they can exchange messages asynchronously.
Arbitrary number of clients can connect to the same host but clients
cannot send messages to each other, they can only communicate with the host.

## Documentation

Visit our website for more complete documentation: [https://docs.uhst.io](https://docs.uhst.io).

### Styling

This project uses (Dart documentation style guidlines)[https://dart.dev/guides/language/effective-dart/documentation]

### Generation

The project uses (dartdoc)[https://github.com/dart-lang/dartdoc#dartdoc]

If you don't have installed dartdoc, then to install the latest version of dartdoc compatible with your SDK run:

- `pub global activate dartdoc`
- for Flutter Snap version run `flutter pub global activate dartdoc`

To generate documentation

- run `dartdoc`
- for Flutter Snap version run `flutter pub global run dartdoc:dartdoc`

### View

An easy way to run an HTTP server locally is to use the dhttpd package. For example:

```shell
$ pub global activate dhttpd
$ dhttpd --path doc/api
```

for Flutter Snap

```shell
$ flutter pub global activate dhttpd
$ flutter pub global run dhttpd:dhttpd --path doc/api
```

## Contributing

This project is maintained by a community of developers. Contributions are welcome and appreciated.
You can find UHST on GitHub; feel free to start an issue or create a pull requests:<br>
[https://github.com/uhst/uhst-client-flutter](https://github.com/uhst/uhst-client-flutter).

## License

Copyright (c) 2020 Uhst
Licensed under [MIT License](LICENSE).
46 changes: 46 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
Loading

0 comments on commit 1ea22ab

Please sign in to comment.