示例#1
0
        protected override void Initialize(IMessageSerializer messageSerializer)
        {
            try
            {
                this.socket = new ClientWebSocket();
                this.socket.ConnectAsync(new Uri(serverUrl), CancellationToken.None).Wait();
            }
            catch (AggregateException ex)
            {
                var wsException = ex.InnerExceptions.FirstOrDefault() as WebSocketException;
                if (wsException != null)
                {
                    Logger.Write(LogLevel.Warning,
                                 string.Format("Failed to connect to WebSocket server. Error was '{0}'", wsException.Message));
                }

                throw;
            }

            this.inputStream  = new ClientWebSocketStream(socket);
            this.outputStream = new ClientWebSocketStream(socket);

            // Set up the message reader and writer
            this.MessageReader =
                new MessageReader(
                    this.inputStream,
                    messageSerializer);

            this.MessageWriter =
                new MessageWriter(
                    this.outputStream,
                    messageSerializer);
        }
        protected override void Initialize(IMessageSerializer messageSerializer)
        {
            try
            {
                this.socket = new ClientWebSocket();
                this.socket.ConnectAsync(new Uri(serverUrl), CancellationToken.None).Wait();
            }
            catch (AggregateException ex)
            {
                var wsException= ex.InnerExceptions.FirstOrDefault() as WebSocketException;
                if (wsException != null)
                {
                    Logger.Write(LogLevel.Warning,
                        string.Format("Failed to connect to WebSocket server. Error was '{0}'", wsException.Message));
                   
                }

                throw;
            }
            
            this.inputStream = new ClientWebSocketStream(socket);
            this.outputStream = new ClientWebSocketStream(socket);

            // Set up the message reader and writer
            this.MessageReader =
                new MessageReader(
                    this.inputStream,
                    messageSerializer);

            this.MessageWriter =
                new MessageWriter(
                    this.outputStream,
                    messageSerializer);
        }
示例#3
0
        protected override void Initialize(IMessageSerializer messageSerializer)
        {
            this.socket       = new ClientWebSocket();
            this.inputStream  = new ClientWebSocketStream(socket);
            this.outputStream = new ClientWebSocketStream(socket);

            // Set up the message reader and writer
            this.MessageReader =
                new MessageReader(
                    this.inputStream,
                    messageSerializer);

            this.MessageWriter =
                new MessageWriter(
                    this.outputStream,
                    messageSerializer);
        }