riptide 0.2.0 copy "riptide: ^0.2.0" to clipboard
riptide: ^0.2.0 copied to clipboard

Dart port of the Riptide library from Tom Weiland. This port provides functionality for establishing connections with clients and servers using the Riptide protocol.

example/main.dart

import 'dart:io';

import 'package:riptide/riptide.dart';

enum ClientToServerId { serverTest }

enum ServerToClientId { clientTest }

void createClient() {
  Client client = Client();
  client.connect(InternetAddress('127.0.0.1'), 7777);

  client.registerMessageHandler(ServerToClientId.clientTest.index,
      (Message message) {
    print(message);
  });

  client.clientConnected.subscribe((args) {
    // send a test message to the server on connection
    Message message = Message.createFromInt(
        MessageSendMode.reliable, ClientToServerId.serverTest.index);
    message.addString('Hello Server!');
    client.send(message);
  });
}

void createServer() {
  Server server = Server();
  server.start(7777, 10);

  server.registerMessageHandler(ClientToServerId.serverTest.index,
      (fromClientID, message) {
    print("received message from client $fromClientID");
  });

  server.clientConnected.subscribe((args) {
    // send a test message to each connecting client
    Message message = Message.createFromInt(
        MessageSendMode.reliable, ServerToClientId.clientTest.index);
    message.addString('Hello Client!');
    server.send(message, args!.client.id);
  });
}
1
likes
160
pub points
0%
popularity

Publisher

verified publisherjaykaycooperations.com

Dart port of the Riptide library from Tom Weiland. This port provides functionality for establishing connections with clients and servers using the Riptide protocol.

Repository (GitHub)
View/report issues

Topics

#network

Documentation

API reference

License

MIT (license)

Dependencies

collection, intl

More

Packages that depend on riptide