sponge_client_dart 1.18.0 copy "sponge_client_dart: ^1.18.0" to clipboard
sponge_client_dart: ^1.18.0 copied to clipboard

Sponge client for Dart. It simplifies connecting to a remote Sponge service.

example/example.dart

// Copyright 2018 The Sponge authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:sponge_client_dart/sponge_client_dart.dart';

void main() async {
  // Create a new client for an anonymous user.
  var client = SpongeClient(SpongeClientConfiguration('http://localhost:8888'));

  // Get the Sponge Remote API version.
  var version = await client.getVersion();
  print('Sponge Remote API version: $version.');

  // Get actions metadata.
  var actionsMeta = await client.getActions();
  print('Available action count: ${actionsMeta.length}.');

  // Call the action with arguments.
  String upperCaseText = await client.call('UpperCase', args: ['Text to upper case']);
  print('Upper case text: $upperCaseText.');

  // Send a new event to the Sponge engine.
  var eventId = await client.send('alarm',
      attributes: {'source': 'Dart client', 'message': 'Something happened'});
  print('Sent event id: $eventId.');

  // Create a new client for a named user.
  client = SpongeClient(
    SpongeClientConfiguration('http://localhost:8888')
      ..username = 'john'
      ..password = 'password',
  );
}
0
likes
40
pub points
0%
popularity

Publisher

unverified uploader

Sponge client for Dart. It simplifies connecting to a remote Sponge service.

Repository (GitHub)
View/report issues

License

Apache-2.0 (LICENSE)

Dependencies

collection, dio, equatable, intl, logging, meta, quiver, synchronized, timezone

More

Packages that depend on sponge_client_dart