Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop pinger when connection close #2

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 4 additions & 24 deletions bin/surrealdb.dart
Expand Up @@ -6,33 +6,13 @@ void main(List<String> args) async {

client.connect();
await client.wait();
await client.use('test', 'test');
await client.use('ns', 'db');
await client.signin('root', 'root');

await client.create('person', TestModel(false, 'title'));
final delete = await client.query('DELETE user:5');

var person = await client.create('person', {
'title': 'Founder & CEO',
'name': {
'first': 'Tobie',
'last': 'Morgan Hitchcock',
},
'marketing': false,
});
print(person);

List<Map<String, Object?>> persons = await client.select('person');

final groupBy = await client.query(
'SELECT marketing, count() FROM type::table(\$tb) GROUP BY marketing',
{
'tb': 'person',
},
);

print(groupBy);

print(persons.length);
print(delete);
client.close();
}

class AMODEL {
Expand Down
2 changes: 2 additions & 0 deletions lib/src/surrealdb.dart
Expand Up @@ -22,6 +22,8 @@ class SurrealDB {

/// Closes the persistent connection to the database.
void close() {
_pinger?.stop();
_pinger = null;
_wsService.disconnect();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/ws.dart
Expand Up @@ -102,7 +102,7 @@ class WSService {
final ws = _ws;

if (ws == null) {
return (completer..completeError('ws not connected')).future;
return (completer..completeError('websocket not connected')).future;
}

var id = getNextId();
Expand Down