konsultaner / connectanum-dart

This is a WAMP client (Web Application Messaging Protocol) implementation for the dart language and flutter projects.
MIT License
22 stars 14 forks source link

not connect websocket #56

Closed muhsin-pt closed 1 year ago

muhsin-pt commented 1 year ago

void main() async { // Start a client that connects without the usage of an authentication process final client1 = Client( // The realm to connect to // We choose WebSocket transport transport: WebSocketTransport( 'wss://...........8080/wss2/', // if you want to use msgpack instead of JSON just import the serializer // from package:connectanum/msgpack.dart and use WebSocketSerialization.SERIALIZATION_MSGPACK Serializer(), WebSocketSerialization.serializationJson,

{"Sec-WebSocket-Protocol": "wamp"},

));

late Session session1; try { // connect to the router and start the wamp layer session1 = await client1 .connect( options: ClientConnectOptions( reconnectCount: 3, // Default is 3 reconnectTime: const Duration( milliseconds: 200) // default is null, so immediately // you may add ping pong options here as well )) .first;

log("Connected>>>");
// if you want to change the options after each reconnect, use this event
client1.onNextTryToReconnect.listen((passedOptions) {
  // enlarge the time to wait after each reconnect by 500ms
  passedOptions.reconnectTime = Duration(
      milliseconds: passedOptions.reconnectTime!.inMilliseconds + 500);
});
// register a method that may be called by other clients
final registered = await session1.register('order');
registered.onInvoke((invocation) => invocation.respondWith());
// subscribe to a topic that my be published by other clients
final subscription = await session1.subscribe('order');
subscription.eventStream!.listen((event) => print(event.arguments![0]));
await subscription.onRevoke.then((reason) =>
    print('The server has killed my subscription due to: $reason'));

} on Abort catch (abort) { // if the serve does not allow this client to receive a session // the server will cancel the initializing process with an abort print(abort.message!.message); } runApp(const MyApp()); }

konsultaner commented 1 year ago

Could you specify your issue?

muhsin-pt commented 1 year ago

all done