Example #1
0
        /// <summary>
        /// Sends a message to the server.
        /// </summary>
        /// <param name="message">Message to be sent</param>
        /// <exception cref="CommunicationStateException">Throws a CommunicationStateException if client is not connected to the server.</exception>
        public void SendMessage(ICJiaMessage message)
        {
            if (CommunicationState != CommunicationStates.Connected)
            {
                throw new CommunicationStateException("Client is not connected to the server.");
            }

            _communicationChannel.SendMessage(message);
        }
Example #2
0
        /// <summary>
        /// Sends a message to the server.
        /// </summary>
        /// <param name="message">Message to be sent</param>
        /// <exception cref="CommunicationStateException">
        /// Throws a CommunicationStateException if client is not connected to the server.
        /// </exception>
        public void SendMessage(IScsMessage message, byte priority)
        {
            if (CommunicationState != CommunicationStates.Connected)
            {
                throw new CommunicationStateException("Client is not connected to the server.");
            }

            _communicationChannel.SendMessage(message, priority);
        }
Example #3
0
        public void Listen(Func <TQuery, TResponse> processFunc)
        {
            var disposable = _queryChannel.MessageStream
                             .Where(m => m != null && m.GetType() == typeof(TQuery))
                             .Cast <TQuery>()
                             .Subscribe(m => _compositeDisposable.Add(_responseChannel.SendMessage(processFunc(m)).Subscribe()));

            _compositeDisposable.Add(disposable);
        }
Example #4
0
 public IObservable <TResponse> Query(TQuery parameter)
 {
     return(Observable.Create <TResponse>(
                observer =>
     {
         return new CompositeDisposable
         {
             _responseChannel.MessageStream
             .Where(m => m != null && m.GetType() == typeof(TResponse))
             .Cast <TResponse>()
             .Where(m => m.Id == parameter.Id)
             .Subscribe(observer),
             _queryChannel.SendMessage(parameter).Subscribe()
         };
     }));
 }
Example #5
0
        /// <summary>
        /// Handles MessageReceived event of _communicationChannel object.
        ///
        /// </summary>
        /// <param name="sender">Source of event</param><param name="e">Event arguments</param>
        private void CommunicationChannel_MessageReceived(object sender, MessageEventArgs e)
        {
            IScsMessage message = e.Message;

            if (message is ScsPingMessage)
            {
                ICommunicationChannel communicationChannel = this._communicationChannel;
                ScsPingMessage        scsPingMessage1      = new ScsPingMessage();
                scsPingMessage1.RepliedMessageId = message.MessageId;
                ScsPingMessage scsPingMessage2 = scsPingMessage1;
                communicationChannel.SendMessage((IScsMessage)scsPingMessage2);
            }
            else
            {
                this.OnMessageReceived(message);
            }
        }
Example #6
0
 /// <summary>
 /// Sends a message to the client.
 /// </summary>
 /// <param name="message">Message to be sent</param>
 public void SendMessage(IScsMessage message)
 {
     _communicationChannel.SendMessage(message);
 }
Example #7
0
 /// <summary>
 /// Sends a message to the client.
 /// </summary>
 /// <param name="message">Message to be sent</param>
 public void SendMessage(IScsMessage message, byte priority)
 {
     _communicationChannel.SendMessage(message, priority);
 }
Example #8
0
 /// <summary>
 /// Sends a message to the client.
 /// </summary>
 /// <param name="message">Message to be sent</param>
 public void SendMessage(string message)
 {
     _communicationChannel.SendMessage(message);
 }
Example #9
0
 public void OnNext(T value)
 {
     _publishChannel.SendMessage(value).Subscribe();
 }