Exemplo n.º 1
0
        public SharedObjectsClient(string namespaceUri, NamespaceLifetime namespaceLifetime, INotifyPropertyChanged principalObject, Dispatcher dispatcher)
        {
            Uri uri = new Uri(namespaceUri);

            if (dispatcher == null)
            {
#if IL2JS
                this.Dispatcher = null;
#elif SILVERLIGHT
                // The Silverlight Client will extract the curernt dispatcher by accessing the RootVisual
                if (Application.Current != null && Application.Current.RootVisual != null && Application.Current.RootVisual.Dispatcher != null)
                {
                    this.Dispatcher = Application.Current.RootVisual.Dispatcher;
                }
                else
                {
                    // if we did not get the Dispatcher throw an exception
                    throw new InvalidOperationException("The SharedObject client must be initialized after the RootVisual has been loaded");
                }
#else
                this.Dispatcher = Dispatcher.CurrentDispatcher;
#endif
            }
            else
            {
                this.Dispatcher = dispatcher;
            }

            // The Namespace is the path
            string namespaceName = uri.GetComponents(UriComponents.Path, UriFormat.Unescaped);
            string endPoint      = uri.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped);

            if (string.IsNullOrEmpty(namespaceName))
            {
                throw new ArgumentException("namespaceUri", "Invalid namespace Uri specified");
            }

            this.Namespace         = namespaceName;
            this.NamespaceLifetime = namespaceLifetime;

            this.CollectionsManager = new CollectionsManager(this);
            this.ObjectsManager     = new ObjectsManager(this);
            this.SharedInterlocked  = new SharedInterlocked(this);

            this.principalObject = principalObject;

            this.ticksLastMessageReceived = DateTime.Now.Ticks;

            this.globalListeningChannelName = Channels.GetGlobalListeningName();
            this.publishUpdatesChannelName  = Channels.GetPublishUpdatesName(this.Namespace);

            this.Channel = new EventLinkChannel(new Uri(endPoint), namespaceName, OnErrorStateChanged);
        }
Exemplo n.º 2
0
        public ClientConnectPayload(string subscriptionId, Guid clientId, string sharedObjectNamespace, NamespaceLifetime sharedObjectNamespaceLifetime, INotifyPropertyChanged principalObject)
            : base(clientId)
        {
            SubscriptionId = subscriptionId;
            SharedObjectNamespace = sharedObjectNamespace;
            SharedObjectNamespaceLifetime = sharedObjectNamespaceLifetime;
            this.SenderVersion = ProtocolVersion;

            if (principalObject != null)
            {
                Guid objectId = Guid.NewGuid();
                this.PrincipalPayload = new ObjectPayload(ClientId, principalObject, objectId, objectId.ToString());
            }
        }
Exemplo n.º 3
0
 public ClientConnectPayload(string subscriptionId, Guid clientId, string sharedObjectNamespace, NamespaceLifetime sharedObjectNamespaceLifetime)
     : this(subscriptionId, clientId, sharedObjectNamespace, sharedObjectNamespaceLifetime, null)
 {
 }
Exemplo n.º 4
0
 public SharedObjectsClient(string namespaceUri, NamespaceLifetime namespaceLifetime, INotifyPropertyChanged principalObject)
     : this(namespaceUri, namespaceLifetime, principalObject, null)
 {
 }
Exemplo n.º 5
0
 public SharedObjectsClient(string namespaceUri, NamespaceLifetime namespaceLifetime)
     : this(namespaceUri, namespaceLifetime, null, null)
 {
 }