riptide 0.1.3 copy "riptide: ^0.1.3" to clipboard
riptide: ^0.1.3 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
0
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

License

unknown (license)

Dependencies

collection, intl

More

Packages that depend on riptide