public async Task Connect_send_receive_and_disconnect()
        {
            // arrange
            _fayeServerProcess.StartThinServer();
            var socket = new WebSocketClient(uri: TEST_SERVER_URL);

            SetupWebSocket(socket);
            InstantiateTransportClient();
            _connection = await _client.Connect();

            var tcs = new TaskCompletionSource <string>();

            _connection.MessageReceived += (sender,
                                            args) => tcs.SetResult(args.Message);
            // act
            _connection.Send(TestMessageStr);
            var response = await tcs.Task.WithTimeout(s => s,
                                                      5.Seconds());

            // assert
            dynamic responseObj = JsonConvert.DeserializeObject <JArray>(response)[0];
            bool    successful  = responseObj.successful;

            successful
            .Should()
            .BeTrue();
        }
Пример #2
0
        public async Task <IFayeConnection> Connect()
        {
            _logger.Info("Opening up initial connection to endpoint");
            _transportConnection = await _transportClient.Connect();

            var handshakeResponse = await Handshake();

            SendConnect(handshakeResponse.ClientId,
                        _transportConnection);
            _logger.Info("Initial connection established");
            return(new FayeConnection(connection: _transportConnection,
                                      handshakeResponse: handshakeResponse,
                                      messageCounter: MessageCounter,
                                      advice: _advice,
                                      handshakeTimeout: HandshakeTimeout,
                                      connectionId: _connectionId));
        }
Пример #3
0
 public void Connect(string ip, string port, string protocol)
 {
     _transportClient.Connect(ip, int.Parse(port));
 }