/// <summary>
 /// Init constructor.
 /// </summary>
 public HandshakeRequest(BayeuxConnectionTypes supportedConnectionTypes, IJSonWritable data, IJSonWritable ext)
     : base (MetaChannel, data, ext)
 {
     Version = new Version(1, 0);
     MinimumVersion = Version;
     SupportedConnectionTypes = supportedConnectionTypes;
 }
        /// <summary>
        /// Init constructor.
        /// </summary>
        public PublishRequest(string clientID, string channel, IJSonWritable eventData, IJSonWritable data, IJSonWritable ext)
            : base (channel, data, ext)
        {
            if (!BayeuxChannel.IsValid(channel))
                throw new ArgumentException("Channel failed a standard validation", "channel");

            ClientID = clientID;
            EventData = eventData;
        }
        /// <summary>
        /// Init constructor.
        /// </summary>
        public SubscribeRequest(string clientID, string subscriptionChannel, IJSonWritable data, IJSonWritable ext)
            : base(MetaChannel, data, ext)
        {
            if (!BayeuxChannel.IsValid(subscriptionChannel))
                throw new ArgumentException("SubscriptionChannel failed a standard validation", "subscriptionChannel");

            ClientID = clientID;
            SubscriptionChannel = subscriptionChannel;
        }
        /// <summary>
        /// Init constructor.
        /// </summary>
        public ConnectRequest(string clientID, BayeuxConnectionTypes connectionType, IJSonWritable data, IJSonWritable ext)
            : base (MetaChannel, data, ext)
        {
            if (string.IsNullOrEmpty(clientID))
                throw new ArgumentException("ClientID can not be empty", "clientID");

            ClientID = clientID;
            ConnectionType = connectionType;
        }
Example #5
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        public BayeuxRequest(string channel, IJSonWritable data, IJSonWritable ext)
        {
            FormattedOutput = true;
            RequestMethod = HttpDataSource.MethodPost;
            Channel = channel;

            _id++;
            ID = _id.ToString(CultureInfo.InvariantCulture);
            _data = data;
            _ext = ext;
        }
        /// <summary>
        /// Sends publish request to the server.
        /// </summary>
        public void Publish(IJSonWritable data, IJSonWritable ext, string channel, IJSonWritable eventData, bool asynchronous)
        {
            if (_state != BayeuxConnectionState.Connected)
                throw new InvalidOperationException("Not connected to the server - handshake must be performed first");

            SendRequest(new PublishRequest(ClientID, channel, eventData, data, ext), asynchronous);
        }
        /// <summary>
        /// Sends unsubscription request to the server.
        /// </summary>
        public void Unsubscribe(IJSonWritable data, IJSonWritable ext, string channel, bool asynchronous)
        {
            if (_state != BayeuxConnectionState.Connected)
                throw new InvalidOperationException("Not connected to the server - handshake must be performed first");

            if (!Subscribed(channel))
                throw new BayeuxException(string.Format(CultureInfo.InvariantCulture, "Not subscribed to channel: '{0}'", channel));

            SendRequest(new UnsubscribeRequest(ClientID, channel, data, ext), asynchronous);
        }
        /// <summary>
        /// Sends disconnect request to the server.
        /// </summary>
        public void Disconnect(IJSonWritable data, IJSonWritable ext, bool asynchronous)
        {
            if (_state != BayeuxConnectionState.Connected)
                throw new InvalidOperationException("Not connected to the server - handshake must be performed first");

            SendRequest(new DisconnectRequest(ClientID, data, ext), asynchronous);
        }
 /// <summary>
 /// Sends handshake request to the server.
 /// </summary>
 public void Handshake(BayeuxConnectionTypes supportedConnectionTypes, IJSonWritable data, string userName, string password, bool asynchronous)
 {
     Handshake(supportedConnectionTypes, data, new BayeuxHandshakeExtension(userName, password), asynchronous);
 }
        /// <summary>
        /// Sends handshake request to the server.
        /// </summary>
        public void Handshake(BayeuxConnectionTypes supportedConnectionTypes, IJSonWritable data, IJSonWritable ext, bool asynchronous)
        {
            // if there is another Handshake request executed in background, try to cancel it first:
            if (_state == BayeuxConnectionState.Connecting)
                Cancel(); // <-- this should reset the state to Disconnected!

            if (_state != BayeuxConnectionState.Disconnected)
                throw new InvalidOperationException("Connecting or already connected to bayeux server! Disconnect first");

            _state = BayeuxConnectionState.Connecting;
            SendRequest(new HandshakeRequest(supportedConnectionTypes, data, ext), asynchronous);
        }
Example #11
0
 public void Write(IJSonWritable o)
 {
     _output.Write(o);
 }
 /// <summary>
 /// Init constructor.
 /// </summary>
 public HandshakeRequest(IJSonWritable data, IJSonWritable extData)
     : this(BayeuxConnectionTypes.LongPolling | BayeuxConnectionTypes.CallbackPolling | BayeuxConnectionTypes.Iframe, data, extData)
 {
 }
Example #13
0
 public void Write(IJSonWritable o)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Init constructor.
 /// </summary>
 public DisconnectRequest(string clientID, IJSonWritable data, IJSonWritable ext)
     : base (MetaChannel, data, ext)
 {
     ClientID = clientID;
 }
 /// <summary>
 /// Sends subscription request to the server.
 /// </summary>
 public void Publish(string channel, IJSonWritable eventData)
 {
     Publish(null, null, channel, eventData, true);
 }
 /// <summary>
 /// Sends subscription request to the server in a synchronous way.
 /// Useful only when testing as blocks the current thread.
 /// </summary>
 public void PublishSync(string channel, IJSonWritable eventData)
 {
     Publish(null, null, channel, eventData, false);
 }
Example #17
0
        /// <summary>
        /// Writes a serializable object as JSON string.
        /// </summary>
        public void Write(IJSonWritable o)
        {
            if (o == null)
                throw new ArgumentNullException("o");

            o.Write(this);
        }